diff --git a/packages/api/src/schema/ai-api-schema.yaml b/packages/api/src/schema/ai-api-schema.yaml index d41c127ee..7d321b55c 100644 --- a/packages/api/src/schema/ai-api-schema.yaml +++ b/packages/api/src/schema/ai-api-schema.yaml @@ -28,7 +28,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "401": description: Unauthorized content: @@ -36,7 +36,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "422": description: Validation Error content: @@ -44,7 +44,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPValidationError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "500": description: Internal Server Error content: @@ -52,13 +52,13 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" default: description: Error content: application/json: schema: - $ref: "#/components/schemas/error" + $ref: "#/components/schemas/studio-api-error" security: - HTTPBearer: [] x-speakeasy-name-override: textToImage @@ -90,7 +90,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "401": description: Unauthorized content: @@ -98,7 +98,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "422": description: Validation Error content: @@ -106,7 +106,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPValidationError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "500": description: Internal Server Error content: @@ -114,13 +114,13 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" default: description: Error content: application/json: schema: - $ref: "#/components/schemas/error" + $ref: "#/components/schemas/studio-api-error" security: - HTTPBearer: [] x-speakeasy-name-override: imageToImage @@ -152,7 +152,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "401": description: Unauthorized content: @@ -160,7 +160,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "422": description: Validation Error content: @@ -168,7 +168,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPValidationError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "500": description: Internal Server Error content: @@ -176,13 +176,13 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" default: description: Error content: application/json: schema: - $ref: "#/components/schemas/error" + $ref: "#/components/schemas/studio-api-error" security: - HTTPBearer: [] x-speakeasy-name-override: imageToVideo @@ -214,7 +214,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "401": description: Unauthorized content: @@ -222,7 +222,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "422": description: Validation Error content: @@ -230,7 +230,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPValidationError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "500": description: Internal Server Error content: @@ -238,13 +238,13 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" default: description: Error content: application/json: schema: - $ref: "#/components/schemas/error" + $ref: "#/components/schemas/studio-api-error" security: - HTTPBearer: [] x-speakeasy-name-override: upscale @@ -276,7 +276,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "401": description: Unauthorized content: @@ -284,7 +284,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "413": description: Request Entity Too Large content: @@ -292,7 +292,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "422": description: Validation Error content: @@ -300,7 +300,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPValidationError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "500": description: Internal Server Error content: @@ -308,13 +308,13 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" default: description: Error content: application/json: schema: - $ref: "#/components/schemas/error" + $ref: "#/components/schemas/studio-api-error" security: - HTTPBearer: [] x-speakeasy-name-override: audioToText @@ -346,7 +346,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "401": description: Unauthorized content: @@ -354,7 +354,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "422": description: Validation Error content: @@ -362,7 +362,7 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPValidationError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" "500": description: Internal Server Error content: @@ -370,13 +370,13 @@ paths: schema: oneOf: - $ref: "#/components/schemas/HTTPError" - - $ref: "#/components/schemas/error" + - $ref: "#/components/schemas/studio-api-error" default: description: Error content: application/json: schema: - $ref: "#/components/schemas/error" + $ref: "#/components/schemas/studio-api-error" security: - HTTPBearer: [] x-speakeasy-name-override: segmentAnything2 @@ -860,6 +860,14 @@ components: - text title: chunk description: A chunk of text with a timestamp. + studio-api-error: + type: object + properties: + errors: + type: array + minItems: 1 + items: + type: string securitySchemes: HTTPBearer: type: http diff --git a/packages/api/src/schema/pull-ai-schema.js b/packages/api/src/schema/pull-ai-schema.js index 8de86f950..3bfe0325e 100644 --- a/packages/api/src/schema/pull-ai-schema.js +++ b/packages/api/src/schema/pull-ai-schema.js @@ -17,6 +17,19 @@ const schemaDir = path.resolve(__dirname, "."); const aiSchemaUrl = "https://raw.githubusercontent.com/livepeer/ai-worker/refs/heads/main/runner/gateway.openapi.yaml"; +const studioApiErrorSchema = { + type: "object", + properties: { + errors: { + type: "array", + minItems: 1, + items: { + type: "string", + }, + }, + }, +}; + const write = (dir, data) => { if (fs.existsSync(dir)) { const existing = fs.readFileSync(dir, "utf8"); @@ -44,14 +57,19 @@ const downloadAiSchema = async () => { delete schema.info; delete schema.servers; + // add studio-api-error schema + schema.components.schemas["studio-api-error"] = studioApiErrorSchema; + // patches to the paths section schema.paths = mapObject(schema.paths, (path, value) => { // prefix paths with /api/beta/generate path = `/api/beta/generate${path}`; // remove security field delete value.security; - // add $ref: "#/components/schemas/error" as oneOf to all of the error responses - const apiError = () => ({ $ref: "#/components/schemas/error" }); + // add Studio API error as oneOf to all of the error responses + const studioErrorRef = () => ({ + $ref: "#/components/schemas/studio-api-error", + }); value.post.responses = mapObject( value.post.responses, (statusCode, response) => { @@ -62,7 +80,10 @@ const downloadAiSchema = async () => { return [statusCode, response]; } response.content["application/json"].schema = { - oneOf: [response.content["application/json"].schema, apiError()], + oneOf: [ + response.content["application/json"].schema, + studioErrorRef(), + ], }; return [statusCode, response]; }, @@ -71,7 +92,7 @@ const downloadAiSchema = async () => { if (!value.post.responses["default"]) { value.post.responses["default"] = { description: "Error", - content: { "application/json": { schema: apiError() } }, + content: { "application/json": { schema: studioErrorRef() } }, }; } return [path, value];