Repository navigation
Validate with opis/json-schema, which supports OpenAPI 3.1 - #81
Merged
Merged
Conversation
Bodies are validated against JSON Schema 2020-12, and OpenAPI 3.0 documents are translated first: `nullable` and the boolean `exclusiveMinimum` and `exclusiveMaximum`. A mismatch carries `Schema\SchemaError`s rather than the engine's own arrays, so changing the engine again changes nothing for users. Validators get the document's OpenAPI version and translate what they need.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fourth part of the new shape for 3.0.
justinrainbow/json-schemadoes not support JSON Schema 2020-12, which is what OpenAPI 3.1 uses, so bodies are now validated withopis/json-schema.nullableaddsnullto thetype(and theenum), or wraps a schema without atypein ananyOf. The booleanexclusiveMinimum/exclusiveMaximumtake the bound's value. This replacesfixNullable(), which rewrote every document, 3.1 included. swagger-php's 3.0 null branch from fix(Schema): 3.0 output keepsnullableonly beside atypezircote/swagger-php#2251 verifies as well.Schema\SchemaErrors (pointer, keyword, message) rather than the engine's own arrays, so changing the engine again changes nothing for users. Messages are opis's now, for example "The required properties (name) are missing".Schema\SchemaValidator. It gets each schema as the document writes it, together with the document's OpenAPI version, and translates what it needs.Schema\OpenApi30Translatoris there for engines that only know JSON Schema. The loader no longer rewrites anything, andgetResponseSchemaUrlFor()is gone, since itsdata://URL only existed forjustinrainbow.The test fixture's references were not JSON pointers:
#components/schemas/user, without the/after#.justinrainbowresolved them anyway, opis does not. They are fixed in the fixture and the specs regenerated. A document with the same typo will report an unresolved reference after upgrading, which belongs in the upgrade notes.Twenty new cases cover the 3.0 translation and 3.1 documents, plus a custom validator and the loaded specification staying untouched. Checked locally with highest and lowest dependencies, opis 2.4 included.