-
Notifications
You must be signed in to change notification settings - Fork 60
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
Schema issues in documentation examples #97
Comments
The whole "JSON Schema v5" thing was a bit of a misunderstanding- that draft is mostly just draft-04 tidied up. the On the plus side (sort-of), unrecognized I'd advise against |
I know that v5 was a kind-of a misunderstanding, but anyway spec examples should really match the spec that they were created to illustrate…
This one is just a suggestion. However, why not? ISTM that most of the time people should use that instead of the default, so it would not be that bad if a few examples in the documentation do that. |
Mostly, because it's something of a footgun and makes your schemas difficult if not impossible to re-use. Which, particularly when using a pet example (implicitly referencing the inheritance in the petstore example) is best avoided. The re-use problems were mostly solved in OAS 3.1 / draft 2020-12 with
This impression is common among users of strictly typed languages and uncommon among users of dynamically typed languages. |
Then would it be possible to add
I do not buy this usual argument in full: if a dynamic person actually bothers to declare a schema, i.e. a type, I do not understand why they would stop midstream: they get all of the pain with only part of the benefit. |
@Bellangelo if you want the schema to only consider object valid, then somewhere there needs to be a |
Indeed, otherwise 3.141592653589793 would be a valid Also, ISTM that people tend to learn by looking at examples rather than reading documentations in depth, so having good examples helps. Moreover, AI generators which are expected to help programmers do only learn by example, if you feed them bad stuff they will produce bad stuff.
Maybe you could add a test expected to fail on an invalid input type ( About tests, so as to illustrate my point about { "id": 1234, "name": "Hobbes", "tags": "fierce tiger" } |
We are moving these examples to the learn.openapis.org site, so I am going to transfer this issue so it's easier to see what issues are for the separate examples like these and what are for the examples embedded in the spec. See this issue for the decision: |
Here are 3 possible issues in schemas used in the documentation examples, that could be fixed:
uriref
formats at the end should beuri-ref
to conform to JSON Schema v5?Pet
schema should have a"type": "object"
added, and maybe an"additionalProperties": false
.201
response schema should also have a"type": "object"
added, and maybe an"additionalProperties": false
.The text was updated successfully, but these errors were encountered: