Skip to content

Examples documentation #893

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

Merged
merged 6 commits into from
Feb 22, 2017
Merged

Examples documentation #893

merged 6 commits into from
Feb 22, 2017

Conversation

fehguy
Copy link
Contributor

@fehguy fehguy commented Feb 20, 2017

Documentation clarification for example, examples

versions/3.0.md Outdated
@@ -765,7 +765,7 @@ Field Name | Type | Description
<a name="parameterAllowReserved"></a>allowReserved | `boolean` | Determines whether the parameter value should allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only applies to parameters with an `in` value of `query`. The default value is `false`.
<a name="parameterSchema"></a>schema | [Schema Object](#schemaObject) | The schema defining the type used for the parameter.

For more complex scenarios a `content` object can be used to define the media-type and schema of the parameter.
For more complex scenarios a `content` object can be used to define the media-type and schema of the parameter. Note that because the `content` object provides the appropriate serialization between examples and content serialization strategies, the `example` is not allowed in the simple `schema` scenario.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we are removing support for example, examples for the simple schema case. @OAI/tdc make sure this makes sense!

The reasoning is that if examples are to be specified, there is no reason to avoid using the content object which gives explicit example format information

Copy link
Member

Choose a reason for hiding this comment

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

Ironically, we added "examples" to JSON Schema for draft 06 (which I know you're not moving to anytime soon if ever, just thought I'd mention it).

Copy link
Member

Choose a reason for hiding this comment

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

@fehguy I'm not sure I agree with this. If format is phonenumber, or postalCode you may want to include an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just kidding! Wanted to see if y'all were paying attention.

- name: Fluffy
petType: Cat
- name: Rover
petType: Frog
- {"name": "Rover", "petType": "Frog"}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two examples are semantically equivalent

Copy link
Contributor

Choose a reason for hiding this comment

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

I find the json encoding inside the YAML (while correct) to be confusing; I don't think it is done elsewhere in the 3.0 spec.


In locations where the field being provided an `example` is a scalar value _or_ has it's content-type definition determined by a higher-level construct (a response payload, for example, uses the `produces` attribute to select the correct message format), the plural `examples` shall be used, and the payload format be specified as a key to the example.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the move to requestBody, this didn't make sense anymore

@@ -1102,10 +1102,10 @@ application/json:
schema:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

inside a content object

Copy link
Member

Choose a reason for hiding this comment

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

Capturing a TDC discussion comment "I would expect that any tooling worth its salt would throw this out if it failed to parse, but that it would try to parse it."

@whitlockjc
Copy link
Member

Does it make sense to allow a description property for the examples scenario? If I have N different examples, I'm likely showing the different valid ways this request/response could be structured and it would be nice to have a description. Yes, this would mean an object for the example instead of a string/object but it could be really useful. Thoughts?

@darrelmiller
Copy link
Member

:shipit:

@webron
Copy link
Member

webron commented Feb 21, 2017

@whitlockjc - @darrelmiller brought the issue up during the call. While it makes sense, to avoid the extra layer we won't support it now. Maybe in future versions.

Other than that, LGTM.

@whitlockjc
Copy link
Member

:shipit:

versions/3.0.md Outdated
<a name="contentTypeExamples"></a>examples | [Examples Array](#examplesArray) | Examples of the content type.
<a name="contentTypeExample"></a>example | [Example Object](#exampleObject) | Example of the content type.
<a name="contentTypeExamples"></a>examples | [Examples Array](#examplesArray) | Examples of the content type. Each example in the Examples Array must be in the correct format as specified in the _content_ type. The `examples` object is mutually exclusive to the `example` object. Furthermore, if referencing a `schema` which contains an example, the `examples` value will _override_ the example provided by the schema.
<a name="contentTypeExample"></a>example | [Example Object](#exampleObject) | Example of the content type. The example object _must_ be in the correct format as specified in the _content_ type. The `example` object is mutually exclusive to the `examples` object. Furthermore, if referencing a `schema` which contains an example, the `example` value will _override_ the the example provided by the schema.
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought on the call Ron suggested softening the MUST to a SHOULD. (in the above para, use MUST not must as per rfc)

In all cases, the payload is expected to be compatible with the type schema for the value that it is accompanying.
Tooling Specifications may choose to validate compatibility automatically, and reject the example value(s) if they are not compatible.
In all cases, the payload is expected to be compatible with the type schema
for the value that it is accompanying. Tooling implementations may choose to
Copy link
Contributor

Choose a reason for hiding this comment

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

... more weight to using SHOULD instead of MUSt above.

@fehguy fehguy merged commit 1a0248c into OpenAPI.next Feb 22, 2017
@fehguy fehguy deleted the issue-589-examples branch February 22, 2017 17:29
AndersDJohnson pushed a commit to AndersDJohnson/OpenAPI-Specification that referenced this pull request Apr 8, 2019
Examples documentation Merging per @OAI/tdc call
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.

7 participants