Skip to content

Fix Workers Builds response envelope schema#44

Open
nicu-chiciuc wants to merge 1 commit into
cloudflare:mainfrom
nicu-chiciuc:fix-builds-apiresponse-result
Open

Fix Workers Builds response envelope schema#44
nicu-chiciuc wants to merge 1 commit into
cloudflare:mainfrom
nicu-chiciuc:fix-builds-apiresponse-result

Conversation

@nicu-chiciuc
Copy link
Copy Markdown

I couldn't figure out how to report an issue regarding this so I opened a PR.

Summary

Remove the shared result: object | null constraint from builds_APIResponse so Workers Builds endpoints can define their own response result shape.

Problem

I encountered this while generating runtime validators from the OpenAPI schema and validating Cloudflare API responses with Ajv.

builds_APIResponse currently defines result as:

result:
  nullable: true
  type: object

and also marks result as required.

Several Workers Builds operations compose this schema with an operation-specific schema using allOf. For example, listTriggersByScript composes builds_APIResponse with a schema that defines:

result:
  type: array
  items:
    $ref: '#/components/schemas/builds_TriggerResponse'

Under OpenAPI/JSON Schema semantics, allOf does not override fields from earlier schemas. The response must validate against every schema in the allOf list.

That makes the composed schema contradictory:

  • builds_APIResponse requires result to be an object or null.
  • listTriggersByScript requires result to 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 result from the shared builds_APIResponse envelope.

The shared schema still defines the common envelope fields:

  • success
  • errors
  • messages
  • result_info

Each operation-specific schema can then define the concrete result shape it actually returns.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant