Fix Workers Builds response envelope schema#44
Open
nicu-chiciuc wants to merge 1 commit into
Open
Conversation
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.
I couldn't figure out how to report an issue regarding this so I opened a PR.
Summary
Remove the shared
result: object | nullconstraint frombuilds_APIResponseso Workers Builds endpoints can define their own responseresultshape.Problem
I encountered this while generating runtime validators from the OpenAPI schema and validating Cloudflare API responses with Ajv.
builds_APIResponsecurrently definesresultas:and also marks
resultas required.Several Workers Builds operations compose this schema with an operation-specific schema using
allOf. For example,listTriggersByScriptcomposesbuilds_APIResponsewith a schema that defines:Under OpenAPI/JSON Schema semantics,
allOfdoes not override fields from earlier schemas. The response must validate against every schema in theallOflist.That makes the composed schema contradictory:
builds_APIResponserequiresresultto be an object or null.listTriggersByScriptrequiresresultto be an array.type: object.So a valid list response like this cannot validate against the published schema:
{ "success": true, "errors": [], "messages": [], "result": [] }Fix
This PR removes
resultfrom the sharedbuilds_APIResponseenvelope.The shared schema still defines the common envelope fields:
successerrorsmessagesresult_infoEach operation-specific schema can then define the concrete
resultshape it actually returns.References
allOfcomposition requires the instance to satisfy all composed schemas: https://spec.openapis.org/oas/v3.0.3#composition-and-inheritance-polymorphismnullable: trueonly allowsnullin addition to the specified type; it does not make the property optional or allow arrays fortype: object: https://spec.openapis.org/oas/v3.0.3#fixed-fields-20