Skip to content
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

Parameter serialization options #60

Open
bshamblen opened this issue Mar 15, 2019 · 2 comments
Open

Parameter serialization options #60

bshamblen opened this issue Mar 15, 2019 · 2 comments

Comments

@bshamblen
Copy link

bshamblen commented Mar 15, 2019

The OpenAPI 3.0 specification provides the ability to specify a parameter serialization style for objects, but I can't find a way to implement the "style": "deepObject" option when defining a parameter that's an object.

For example, the JSON-API specification indicates that sparse fieldset and pagination parameters should be sent in the following format:

/api/v1/examples?page[number]=1&page[size]=25

In order to accomplish this, I would define a parameter like this:

# @parameter page  [object<number:integer,size:integer>] Sets the current page and the page size

When I run that through SwaggerYard, the parameter structure that shows up in the JSON file looks like this:

{
  "name": "page",
  "description": "Sets the current page and the page size",
  "required": false,
  "in": "query",
  "schema": {
    "type": "object",
    "properties": {
      "number": {
        "type": "integer"
      },
      "size": {
        "type": "integer"
      }
    }
  }
}

In order for Swagger UI to serialize the object in the format that's necessary, I need to be able to specify the "style": "deepObject" option for the parameter above, but I don't see anything in the SwaggerYard documentation that would allow me to do it.

Is there a way for me to specify this option? Thanks for your help.

@nicksieger
Copy link
Collaborator

Looks like I missed that option when adding OpenAPI 3 support recently. Would you mind submitting a PR? The relevant area would probably be here in the OpenAPI class. Is that an option that needs to have configuration, or can we get by always setting "style": "deepObject" when the schema type for a parameter has properties?

@bshamblen
Copy link
Author

It looks like there are 4 possible values for the style option. Can you let me know if there’s a specific way you’d like the options handled. I’ll submit a PR early next week. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants