Skip to content

Update Examples Object #1028

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

Closed
wants to merge 4 commits into from
Closed

Conversation

DavidBiesack
Copy link
Contributor

Clarify that Examples Object may be used instead of Example Object.

Show JSON examples as well as YAML

Clarify the $ref values used in examples to remove ambiguity.
These are not references to external JSON/XML/TXT resources, but
rather are references to reusable examples in the current OpenAPI definition
or in an external OpenAPI definition's components/examples

This does not yet address issue #488 but cleans up Examples Object
a bit, which is needed whether we alter the OAS as per #488 .

Clarify that Examples Object may be used instead of Example Object.

Show JSON examples as well as YAML

Clarify the $ref values used in examples to remove ambiguity.
These are not references to external JSON/XML/TXT resources, but
rather are references to reusable examples in the current OpenAPI definition
or in an external OpenAPI definition's components/examples

This does not yet address issue OAI#488 but cleans up Examples Object
a bit, which is needed whether we alter the OAS as per OAI#488 .
versions/3.0.md Outdated
@@ -1128,20 +1128,20 @@ A request body with a referenced model definition.
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": [ "http://foo.bar/examples/user-example.json" ]
"examples": [ "http://foo.bar/other-api.yaml#/components/examples/user-example.json" ]
Copy link
Member

@whitlockjc whitlockjc Apr 4, 2017

Choose a reason for hiding this comment

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

I assume user-example.json is a property name for examples? Should user-example.json be application/json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. This was carried over from the original, but I can change the names if that will help avoid confusion.

Copy link
Member

Choose a reason for hiding this comment

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

The naming is definitely confusing, to me at least.. user-example.json reads like a file name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, good feedback - I've updated the PR, and also added a missing JSON block, and also named the /components/example/ items more uniformly.

I also fixed some cases where the spec
had /components/schemas/pet in some places, /components/schemas/Pet in others.

Remove .json, .xml other extensions from examples so they do not
look like file/resource names

Use components/examples/camelCase not hyphenated-names uniformly
`example` and `examples` are mutually exclusive.

Anywhere an `example` may be given (including in the Examples Object array),
a JSON Reference MAY be used, with the
Copy link
Member

Choose a reason for hiding this comment

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

For consistency, we should use Reference Object (linkfied) instead of JSON Reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm also going to move this paragraph to Example Object which is a better place for it.

@@ -2365,42 +2370,147 @@ for the value that it is accompanying. Tooling implementations MAY choose to
validate compatibility automatically, and reject the example value(s) if they
are not compatible.

Here is a single `example` in a model [Schema Object](#schemaObject):
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit, is "single" necessary here? Basically, you're saying "Here is an example within a model". Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to convert it to examples (and drop "single) since this is the Examples Object section, not Example Object.

$ref: "#/components/examples/identity"
```

Below is an `examples` array in a [Request Body Object](#requestBodyObject),
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, you've already documented examples to be an array so it seems unnecessary.

```

Below is an `examples` array in a [Request Body Object](#requestBodyObject),
showing two in-line examples and references
Copy link
Member

Choose a reason for hiding this comment

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

"in-line" should be "inline".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

@whitlockjc
Copy link
Member

Thanks for being patient with the nitpicks. :)

David Biesack added 2 commits April 5, 2017 09:59
Remove .json, .xml other extensions from examples so they do not
look like file/resource names

Use components/examples/camelCase not hyphenated-names uniformly

Move key descriptions (for $ref, schema constraints) and Example Object Example
from Examples Object into Example Object. Include some examples that
are just string values (ZipCode), an object (Address), and XML (SimpleXmlAddress)

Improve examples for Example Object, show definitions in components/examples.
Remove overly verbose examples from Examples Object
@DavidBiesack
Copy link
Contributor Author

Anyone willing to review and merge this (before the text has diverged too much making merge difficult)?

@DavidBiesack
Copy link
Contributor Author

May not be needed if the proposal in #1035 is accepted.

@DavidBiesack
Copy link
Contributor Author

Closing - #1035 addressed the changes in this PR

@DavidBiesack DavidBiesack deleted the issue-488 branch July 13, 2017 19:13
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