Skip to content

fix description for parameters in OpenAPI 3#223

Merged
sloria merged 5 commits intomarshmallow-code:devfrom
fMeow:marshmallow
Jun 9, 2018
Merged

fix description for parameters in OpenAPI 3#223
sloria merged 5 commits intomarshmallow-code:devfrom
fMeow:marshmallow

Conversation

@fMeow
Copy link
Copy Markdown
Contributor

@fMeow fMeow commented Jun 1, 2018

In OpenAPI3, desired output for query parameters is like this:

parameters:
- description: Password
  in: query
  name: password
  required: true
  schema: 
    type: string

However, only properties in, name and required are defined in the top level, while all other properties is moved under property schema, which conflicts with OpenAPI 3 specification.

Current output:

parameters:
- in: query
  name: password
  required: true
  schema: 
    type: string
    description: Password

So before moving all properties to schema, it's reasonable to check for description property and define description in top level of parameter object.

@sloria
Copy link
Copy Markdown
Member

sloria commented Jun 1, 2018

Thanks again @Guoli-Lyu . Can you add a test for this, too? Once that's added, this can be merged.

fMeow added 4 commits June 6, 2018 22:14
Deprecated and allowEmptyValue keyword is not supported yet. And the
better way maybe is to provide different function of schema2fiels
for different version, respectively.
@fMeow
Copy link
Copy Markdown
Contributor Author

fMeow commented Jun 6, 2018

I add test for descriptions in parameters and also requestBody, which in OpenAPI 2 is like this:

parameters:
- in: path
  name: name

@sloria

Copy link
Copy Markdown
Member

@sloria sloria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for adding the test. Just some minor revisions to the docs needed. I can make those myself before I merge.


https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject

For OpenAPI 3, only "query", "header", "path" or "cookie" is allowed for the location
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor revisions:

For OpenAPI 3, only "query", "header", "path" or "cookie" are allowed for the location of parameters. "requestBody" is used when fields are in the body.

This function always returns a list, with a parameter for each included field in the :class:`Schema <marshmallow.Schema>`.

@sloria sloria merged commit 1db29fe into marshmallow-code:dev Jun 9, 2018
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

Successfully merging this pull request may close these issues.

2 participants