| import "@typespec/http"; |
| import "@typespec/openapi3"; |
|
|
| using TypeSpec.Http; |
| using TypeSpec.OpenAPI; |
|
|
| namespace OpenMeter; |
|
|
| |
| |
| |
| |
| @error |
| @extension("x-go-type", "models.StatusProblem") |
| @extension( |
| "x-go-type-import", |
| #{ path: "github.com/openmeterio/openmeter/pkg/models" } |
| ) |
| @friendlyName("UnexpectedProblemResponse") |
| model Error { |
| @header contentType: "application/problem+json"; |
|
|
| |
| |
| |
| @example("about:blank") |
| type: url = "about:blank"; |
|
|
| |
| |
| |
| @example("Bad Request") |
| title: string; |
|
|
| |
| |
| |
| @minValue(400) |
| @maxValue(599) |
| @example(400) |
| status?: int16; |
|
|
| |
| |
| |
| @example("The request body must be a JSON object.") |
| detail: string; |
|
|
| |
| |
| |
| @example("urn:request:local/JMOlctsKV8-000001") |
| instance: url; |
|
|
| |
| |
| |
| @example(#{ |
| validationErrors: #[ |
| #{ code: "validation_error", message: "Validation error" } |
| ], |
| otherAttribute: "otherValue", |
| }) |
| extensions?: Record<unknown>; |
|
|
| |
| |
| |
| ...Record<unknown>; |
| } |
|
|
| alias CommonErrorsWithValidation = |
| | ValidationErrorResponse |
| | UnauthorizedError |
| | ForbiddenError |
| | InternalServerErrorError |
| | ServiceUnavailableError |
| | PreconditionFailedError |
| | Error; |
|
|
| alias CommonErrors = |
| | BadRequestError |
| | UnauthorizedError |
| | ForbiddenError |
| | InternalServerErrorError |
| | ServiceUnavailableError |
| | PreconditionFailedError |
| | Error; |
|
|
| |
| |
| |
| @error |
| @friendlyName("BadRequestProblemResponse") |
| model BadRequestError extends Error { |
| @statusCode _: 400; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("ValidationErrorProblemResponse") |
| model ValidationErrorResponse { |
| ...OmitProperties<BadRequestError, "extensions">; |
|
|
| |
| |
| |
| @visibility(Lifecycle.Read) |
| extensions?: { |
| validationErrors?: ValidationError[]; |
| }; |
| } |
|
|
| |
| |
| |
| @friendlyName("ValidationError") |
| model ValidationError { |
| |
| |
| |
| @visibility(Lifecycle.Read) |
| @example("addons/pro/ratecards/token/featureKey") |
| field: string; |
|
|
| |
| |
| |
| @visibility(Lifecycle.Read) |
| @example("invalid_feature_key") |
| code: string; |
|
|
| |
| |
| |
| @visibility(Lifecycle.Read) |
| @example("not found feature by key") |
| message: string; |
|
|
| |
| |
| |
| @visibility(Lifecycle.Read) |
| attributes?: Annotations; |
| } |
|
|
| |
| |
| |
| @friendlyName("ErrorExtension") |
| model ErrorExtension { |
| |
| |
| |
| @visibility(Lifecycle.Read) |
| @example("addons/pro/ratecards/token/featureKey") |
| field: string; |
|
|
| |
| |
| |
| @visibility(Lifecycle.Read) |
| @example("invalid_feature_key") |
| code: string; |
|
|
| |
| |
| |
| @visibility(Lifecycle.Read) |
| @example("not found feature by key") |
| message: string; |
|
|
| ...Record<unknown>; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("UnauthorizedProblemResponse") |
| model UnauthorizedError extends Error { |
| @statusCode _: 401; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("ForbiddenProblemResponse") |
| model ForbiddenError extends Error { |
| @statusCode _: 403; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("NotFoundProblemResponse") |
| model NotFoundError extends Error { |
| @statusCode _: 404; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("ConflictProblemResponse") |
| model ConflictError extends Error { |
| @statusCode _: 409; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("PreconditionFailedProblemResponse") |
| model PreconditionFailedError extends Error { |
| @statusCode _: 412; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("InternalServerErrorProblemResponse") |
| model InternalServerErrorError extends Error { |
| @statusCode _: 500; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("NotImplementedProblemResponse") |
| model NotImplementedError extends Error { |
| @statusCode _: 501; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("ServiceUnavailableProblemResponse") |
| model ServiceUnavailableError extends Error { |
| @statusCode _: 503; |
| } |
|
|
| |
| |
| |
| @error |
| @friendlyName("GatewayTimeoutProblemResponse") |
| model GatewayTimeoutError extends Error { |
| @statusCode _: 504; |
| } |
|
|