Issue #8941
closedmedia_type list filter doesn't work with ruby bindings, expects array which api doesn't support
Description
After upgrading to the pulp_container ruby bindings, when calling the list content_manifests_api and passing media_type as a filter, we get an error:
NoMethodError: undefined method `all?' for "application/vnd.docker.distribution.manifest.v1+json":String
all? is typically called on an array, and looking at the code does show the bindings are expecting an array:
allowable_values = ["application/vnd.docker.distribution.manifest.list.v2+json", "application/vnd.docker.distribution.manifest.v1+json", "application/vnd.docker.distribution.manifest.v2+json", "application/vnd.oci.image.index.v1+json", "application/vnd.oci.image.manifest.v1+json"]
if @api_client.config.client_side_validation && opts[:'media_type'] && !opts[:'media_type'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"media_type\", must include one of #{allowable_values}"
end
However if we try to pass an array, we get an error from the server
Response body: {"errors":["Invalid Filter: 'media_type[]'"]}
Updated by mdellweg over 3 years ago
From the api docs, i see:
cat api.json | jq '.paths."/pulp/api/v3/content/container/manifests/".get.parameters[]|select(.name=="media_type")'
{
"in": "query",
"name": "media_type",
"schema": {
"type": "array",
"items": {
"type": "string",
"enum": [
"application/vnd.docker.distribution.manifest.list.v2+json",
"application/vnd.docker.distribution.manifest.v1+json",
"application/vnd.docker.distribution.manifest.v2+json",
"application/vnd.oci.image.index.v1+json",
"application/vnd.oci.image.manifest.v1+json"
]
}
},
"explode": true,
"style": "form"
}
and this indeed asks for an array, so the bindings seem to be translated correctly.
However django_filter's MultipleChoiceFilter wants the params to just appear multiple times without the []
it seems:
https://django-filter.readthedocs.io/en/stable/ref/filters.html#multiplechoicefilter
Updated by mdellweg over 3 years ago
Also the openapi standard specifies arrays in querystrings by repeating the keyword without []
:
https://swagger.io/docs/specification/describing-parameters/#query-parameters
So i start to think the bindings are not rendering arrays correctly.
Updated by dkliban@redhat.com over 3 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to dkliban@redhat.com
- Sprint set to Sprint 99
Added by dkliban@redhat.com over 3 years ago
Updated by dkliban@redhat.com over 3 years ago
- Status changed from ASSIGNED to MODIFIED
Applied in changeset pulp:pulp-openapi-generator|b832d742298ce7c6fb2e4d091596ba200b8828fb.
Updated by dkliban@redhat.com over 3 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
- Sprint/Milestone set to 2.7.1
Fixed when bindings were released with 2.7.1 release.
Add Ruby templates to expose the 'params_encoder' config from Faraday
I opened a PR upstream with the same changes: https://github.com/OpenAPITools/openapi-generator/pull/9839
fixes: #8941 https://pulp.plan.io/issues/8941