Repository navigation
feat(Parser): read an OpenAPI 3.1 document into a Specification - #2387
Merged
Merged
Conversation
`Parser` reads a document, from a file or an array, with the parser for the version in its
`openapi` field. `Compiler\OpenApi31Parser` is the inverse of `OpenApi31Compiler`. Components
are filed by name, operations by path or webhook and method, and `$ref` stays a string. A
keyword the model cannot hold, or a value of the wrong type, is left out with a warning naming
its location.
Also `compilePaths()` writes an empty path item as `{}` rather than dropping the path.
A compiler now supports a version by its minor (`3.1.`), so a new patch release needs no change to a list.
Every Reference Object that takes a summary keeps it now, not only an example's.
DerManoMann
force-pushed
the
feat/parser
branch
from
November 12, 2026 00:27
00594de to
144cc63
Compare
Parses an OpenAPI 3.1 document and adds it after assembly. The attributes win: info, servers, security and externalDocs come from the document only where they are unset, and its paths, operations, components and tags go first, so the mergers keep the attribute's.
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.
Overview
Adds a parser that reads an OpenAPI 3.1 document back into a
Specification, the reverse of what the 3.1 compiler writes, andBuilder::withDocument()to add a hand-written document to what the attributes describe. Also two small compiler changes: an empty path is written as an empty path item, and a compiler supports any patch release of its minor version.Summary
openapifield. Only 3.1 has a parser so far. Any other version, or none, is read as 3.1, with a warning.x-extensions are kept, and so is asummarybeside a$ref.$defsorjsonSchemaDialect) is left out with a warning that names its location in the document. A value of the wrong type is also left out with a warning, except a number where a string belongs, which is read as that string (YAML readsversion: 1.0as a number).OpenApiException.Builder::withDocument()adds a hand-written 3.1 document to a spec or hybrid build, for example webhooks with no PHP code behind them. A$refcan point from the document to a schema built from a class, and the other way round. Where both describe the same thing, the attributes win:info,servers,securityandexternalDocscome from the document only where the attributes have none, and the mergers keep the attribute's path, operation, component or tag. Plugins get the same hook. Classic mode does not read documents and logs a warning.Builderreference and as a cookbook recipe.3.1.3no longer fails with "no compiler".