diff --git a/cli/test/client.test.ts b/cli/test/client.test.ts index d649ff4ca..e72189414 100644 --- a/cli/test/client.test.ts +++ b/cli/test/client.test.ts @@ -9,14 +9,14 @@ describe("error handling", () => { status: 400, code: "INVALID_REQUEST", message: "Bad request", - details: { field: "email" }, + details: { errors: [{ field: "email" }] }, }, }); const parsed = JSON.parse(stdout); expect(parsed.success).toBe(false); expect(parsed.error.code).toBe("INVALID_REQUEST"); - expect(parsed.error.details).toEqual({ field: "email" }); + expect(parsed.error.details).toEqual({ errors: [{ field: "email" }] }); // The whole error envelope must not be nested under details. expect(parsed.error.details.code).toBeUndefined(); }); diff --git a/mintlify/openapi.yaml b/mintlify/openapi.yaml index 0ae3a6da0..ecfdd1a2b 100644 --- a/mintlify/openapi.yaml +++ b/mintlify/openapi.yaml @@ -11303,6 +11303,22 @@ components: type: integer description: Maximum length in characters. example: 500 + FieldError: + type: object + required: + - field + description: One field-level validation failure. Field-validation errors on submit endpoints (e.g. `POST /customers`, `PATCH /customers/{id}`) emit an array of these under `details.errors` so platforms can render form-field-level UX for every failure in a single round-trip. + properties: + field: + type: string + description: Dot-notation path to the offending field. + example: taxIdentifier + constraint: + $ref: '#/components/schemas/FieldConstraint' + message: + type: string + description: Human-readable explanation of what's wrong with this field. + example: Value is not one of the allowed enum members. Error400: type: object required: @@ -11404,14 +11420,13 @@ components: description: Error message details: type: object - description: Additional error details. Shape varies by `code`. For field-validation errors on submit endpoints (e.g. `POST /customers`, `PATCH /customers/{id}`), `details.field` and `details.constraint` are populated so platforms can pre-validate their onboarding form before re-submitting. + description: Additional error details. Shape varies by `code`. For field-validation errors on submit endpoints (e.g. `POST /customers`, `PATCH /customers/{id}`), `details.errors[]` enumerates every invalid field so platforms can render form-field-level UX for the entire request in a single round-trip. properties: - field: - type: string - description: Dot-notation path to the offending field. Present on field-validation errors from submit endpoints. - example: taxIdentifier - constraint: - $ref: '#/components/schemas/FieldConstraint' + errors: + type: array + description: One entry per invalid field. Present on field-validation errors from submit endpoints. + items: + $ref: '#/components/schemas/FieldError' additionalProperties: true Error501: type: object diff --git a/openapi.yaml b/openapi.yaml index 0ae3a6da0..ecfdd1a2b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -11303,6 +11303,22 @@ components: type: integer description: Maximum length in characters. example: 500 + FieldError: + type: object + required: + - field + description: One field-level validation failure. Field-validation errors on submit endpoints (e.g. `POST /customers`, `PATCH /customers/{id}`) emit an array of these under `details.errors` so platforms can render form-field-level UX for every failure in a single round-trip. + properties: + field: + type: string + description: Dot-notation path to the offending field. + example: taxIdentifier + constraint: + $ref: '#/components/schemas/FieldConstraint' + message: + type: string + description: Human-readable explanation of what's wrong with this field. + example: Value is not one of the allowed enum members. Error400: type: object required: @@ -11404,14 +11420,13 @@ components: description: Error message details: type: object - description: Additional error details. Shape varies by `code`. For field-validation errors on submit endpoints (e.g. `POST /customers`, `PATCH /customers/{id}`), `details.field` and `details.constraint` are populated so platforms can pre-validate their onboarding form before re-submitting. + description: Additional error details. Shape varies by `code`. For field-validation errors on submit endpoints (e.g. `POST /customers`, `PATCH /customers/{id}`), `details.errors[]` enumerates every invalid field so platforms can render form-field-level UX for the entire request in a single round-trip. properties: - field: - type: string - description: Dot-notation path to the offending field. Present on field-validation errors from submit endpoints. - example: taxIdentifier - constraint: - $ref: '#/components/schemas/FieldConstraint' + errors: + type: array + description: One entry per invalid field. Present on field-validation errors from submit endpoints. + items: + $ref: '#/components/schemas/FieldError' additionalProperties: true Error501: type: object diff --git a/openapi/components/schemas/errors/Error400.yaml b/openapi/components/schemas/errors/Error400.yaml index 248011211..97bcaad55 100644 --- a/openapi/components/schemas/errors/Error400.yaml +++ b/openapi/components/schemas/errors/Error400.yaml @@ -101,15 +101,14 @@ properties: description: >- Additional error details. Shape varies by `code`. For field-validation errors on submit endpoints (e.g. `POST /customers`, `PATCH /customers/{id}`), - `details.field` and `details.constraint` are populated so platforms can - pre-validate their onboarding form before re-submitting. + `details.errors[]` enumerates every invalid field so platforms can render + form-field-level UX for the entire request in a single round-trip. properties: - field: - type: string + errors: + type: array description: >- - Dot-notation path to the offending field. Present on field-validation - errors from submit endpoints. - example: taxIdentifier - constraint: - $ref: ./FieldConstraint.yaml + One entry per invalid field. Present on field-validation errors from + submit endpoints. + items: + $ref: ./FieldError.yaml additionalProperties: true diff --git a/openapi/components/schemas/errors/FieldError.yaml b/openapi/components/schemas/errors/FieldError.yaml new file mode 100644 index 000000000..5b74061c0 --- /dev/null +++ b/openapi/components/schemas/errors/FieldError.yaml @@ -0,0 +1,19 @@ +type: object +required: + - field +description: >- + One field-level validation failure. Field-validation errors on submit + endpoints (e.g. `POST /customers`, `PATCH /customers/{id}`) emit an array of + these under `details.errors` so platforms can render form-field-level UX + for every failure in a single round-trip. +properties: + field: + type: string + description: Dot-notation path to the offending field. + example: taxIdentifier + constraint: + $ref: ./FieldConstraint.yaml + message: + type: string + description: Human-readable explanation of what's wrong with this field. + example: Value is not one of the allowed enum members.