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

added support for examples if no default. Also added support for properties when type is not an object #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jgabriels
Copy link

added support for examples if no default. Also added support for properties when type is not an object

@@ -86,6 +86,9 @@ function instantiatePrimitive (val) {
return val.default
}

if (val.example) {
return val.example
}
Copy link
Contributor

@michaelgwelch michaelgwelch Jul 26, 2022

Choose a reason for hiding this comment

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

I'd recommend checking example before default.

See "Common Mistakes" at https://swagger.io/docs/specification/describing-parameters/

There are two common mistakes ...

  • Using default to specify a sample value. This is not intended use of default and can lead to unexpected behavior in some Swagger tools. Use the example or examples keyword for this purpose instead. See Adding Examples.

So while default might be a fine example if nothing else is available, I'd default to example first and then the first entry in examples and then finally default. That's what I did in #86 for parameter parsing.

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