-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
The Parameter object needs an "examples" property #179
Comments
"body" parameters use schemas to describe their values, and the schema object has an example fields as well - https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#schemaExample. |
Good point. The Response object also has a Schema. Would it make sense to use the example field there instead of the "examples" property in the Response object? |
Possibly. However, the examples of the responses may also contain headers. Another point is that a request schema example may not be the same as a response schema example. The example field in the schema itself is intended for usage mostly as a request parameter. |
What about parameters that are not in the "body"? While those are simpler, it can be useful to be able to add examples to every required field (eg. to automatically generate curl examples). |
@JD557 - While I understand the use case, it doesn't serve Swagger's (current) goals. One can say that you can randomize a value based on the type and use that for the curl command. You can, in turn, argue that the same can be said about models. However, the examples are there mostly for documentation purposes to give the reader a clearer view of the model structure which can get fairly complex. You can't really say the same thing for primitives. |
+1 for automatic generation of curl examples. At the moment I'm having to use
I don't think this should contain examples because typically you want to put examples separate to the description of the field e.g:
In this scenario, I want to mention the example |
Link to parent #565 |
+1 |
+1 |
Please note that you don't need to add a new comment for a "+1" anymore – there is the reaction button (on the top left of each comment) which allow you to "vote" on a comment. (@etki) Only add a comment if it actually adds something. |
I believe that this is now fixed (see https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.md#examples-object) |
@JD557 - I don't believe so. I would have expected to see this example field in the schema object or the parameter object. The 'fixed fields' part of the schema object seems to suggest that this might be the case, but I only see examples of the usages of this schema provided for the requestBody, not for query parameters. So it's unclear to me if this is covered by the specification, and if so, what it might look like in real life. |
@tadhgpearson The Schema Object now has both So, I would say currently, if schema supports it and parameters support schema then transitively parameters support examples. Having said that, there is still work that needs doing on parameter, so this may change. |
Yep... so it looks something like this?
|
With the extra colon after example, yup. That's how I understand it to work. |
Parameter Object now has |
The Response object has a nice {"example": ExampleObject} property which makes it easy to document an operation's response. The Parameter object needs the same thing, particularly when the parameter type is "body". What kind of body is the operation expecting?
The text was updated successfully, but these errors were encountered: