Repository navigation
fix: the OpenAPI documents validate (OpenAPI 3.0) - #22
Merged
Merged
Conversation
With laravel-api.jsonrpc.enabled, POST /{prefix}/rpc/{version} serves
every action as a method controller.action with by-name params, through
Runtime\Dispatcher. Failures are errors (-32602 for 422, -32000 otherwise,
status and payload in data); batches and notifications per spec;
rpc.discover answers with an OpenRPC 1.3.2 document. ServedVersions and
NamedOperations are shared with MCP. JsonSchemas::encodable() writes empty
properties/$defs as {} — the OpenRPC validator rejected [].
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
swagger-parser rejected 14 of the 17 documents of the fixtures and the example: properties [] (an empty PHP array as a JSON list), required [] (draft 4 wants one name) and a name key inside every @output field schema. The name keys and empty required lists are gone from getOpenApiConfig(); the empty maps are written as {} at the JSON boundary (/api/doc/{version}, api:cache). All 17 validate. TS types and exports unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Stacked on #21 (uses
JsonSchemas::encodable()from it) — merge #21 first; until then this diff includes its commits.Found how
Validating the OpenRPC output of #21 turned up
"properties": []; the same check on the OpenAPI documents with@apidevtools/swagger-parsershowed 14 of the 17 documents of the fixtures and the example are invalid OpenAPI 3.0. Pre-existing, for three reasons:"properties": []— PHP's empty array encoded as a JSON list where a map is due (an@outputwithout fields, envelope payloads, empty templates). 21 occurrences."required": []— OpenAPI 3.0's schemas are draft-4 based, whererequiredneeds at least one name. 9 occurrences (templates/envelope normalized withkeepEmptyRequired).nameinside every@outputfield schema —"pong": {"type": "boolean", "name": "pong", …}; a Schema Object has no such keyword. A leftover of the output builder (the nested branch takes the name from the key, never from it). 68 occurrences.Fix
DescriptorBuilderno longer putsnameinto output field schemas (so descriptors/MCP/OpenRPC are cleaner too).OpenApiRenderer::render(): emptyrequiredlists are dropped from the document (draft-4 rule, so OpenAPI-only; templates keep theirs internally for merging)./api/doc/{version}(and its on-disk spec cache) and the specsapi:cachebuilds go throughJsonSchemas::encodable(). Not inrender(): PHP consumers of the array (TS generator, exporters) checkempty($properties), which anstdClasswould break.After: 17/17 valid with swagger-parser (
lint_brokenthrows by design). Parameternames untouched (checked).Snapshots
17 OpenAPI spec snapshots change — and only in these lines: −68
"name": …inside field schemas, 21×"properties": []→{}, −9"required": [](+ comma adjustments). The spec snapshot now pins the document as served (JsonSchemas::encodable()applied). TS types, exports, lint reports and routes: unchanged.Tests
643 passing. New in
OpenApiRendererTest: the served documents of 8 fixture APIs have no listproperties, no emptyrequired, nonamein field schemas — fails on 8/8 without the fix.DescriptorBuilderTestupdated (noname). CHANGELOG → Fixed.🤖 Generated with Claude Code