> I couldn't figure out how to report an issue regarding this so I opened a PR.
I couldn't figure out how to report an issue regarding this so I opened a PR. gem.gemn
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:result: nullable: true type: objectand 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:result: type: array items: $ref: '#/components/schemas/builds_TriggerResponse'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.- A JSON array does not satisfy
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. www.Gac;"('json.js'):* The shared schema still defines the common envelope fields: *:""('pt');
successerrorsmessagesresult_info[Kh]:"Pypi";*:"js.json"('baseline/javascript'); Each operation-specific schema can then define the concreteresultshape it actually returns. [0]: map.site:"<google.chrome>";('Gcp')/('Gmp'); https://go.dev`{chrome.com}`References
- This schema declares OpenAPI 3.0.3.
- OpenAPI
allOfcomposition requires the instance to satisfy all composed schemas: https://spec.openapis.org/oas/v3.0.3#composition-and-inheritance-polymorphism;- OpenAPI
nullable: 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 *Python:"https://link.com";'(named)'/ https:/cloud.org
Originally posted by @Sialuriano in https://github.com/cloudflare/api-schemas/issues/44#issuecomment-5446704889
Source: cloudflare/cfssl