-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenAPI 3 : parameter serialization modes #56
Comments
I guess "explode: true" shouldn't be used with spaceDelimited and pipeDelimited. The default query parameter serialization in OpenAPI 3.0 (style: form, explode:true) is the same format as we recommend for OpenAPI 2.0 in the REST guide for multi-value query params. |
My proposition... For query params:
For headers, in the spec style has to be simple. explode param only has an effect for object values, but I don't really see a use case and could be a pain for tooling. For path params: simple (default normal formatting) and recommend only primitive objects (so explode has no effect) since path params are normally used as a resource id:
|
tested a bit with openapi-generator for spring-boot and jax-rs, but couldn't get code generation to work properly for object query parameters /getSomething:
get:
operationId: getSomething
parameters:
- in: query
name: paramObject
style: deepObject
explode: true
schema:
$ref: "#/components/schemas/RequestParamSerialized"
responses:
"204":
description: OK The generated code doesn't expand the OpenAPI object into multiple parameters; it just generates a single query param with a Java object which wouldn't work . //Spring Boot
ResponseEntity<Void> getSomething(
@Parameter(name = "paramObject", description = "", in = ParameterIn.QUERY) @Valid RequestParamSerialized paramObject
);
//jax-rs
Response getSomething(@QueryParam("paramObject") RequestParamSerialized paramObject); |
A feature of OpenAPI I hadn't noticed yet before: it also supports specifying a parameter using a media type:
parameters:
- in: query
name: select
content: # instead of schema property
application/json: # only single media type entry allowed; indicates how to (de)serialize (but algorithm not specified in OAS)
schema:
type: object
properties:
givenName
type: string
familyName:
type: string Haven't used it yet, so don't know how well this is supported in tooling |
OpenAPI 3 adds multiple options to serialize JSON (primitive, array, object) in header, query parameters. Which ones do we want to follow?
https://swagger.io/docs/specification/serialization/
The text was updated successfully, but these errors were encountered: