UNPKG

@hey-api/openapi-ts

Version:

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.

1,124 lines (1,106 loc) • 361 kB
import fs from 'node:fs'; import ts from 'typescript'; interface EnumExtensions { /** * `x-enum-descriptions` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator. */ 'x-enum-descriptions'?: ReadonlyArray<string>; /** * `x-enum-varnames` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator. */ 'x-enum-varnames'?: ReadonlyArray<string>; /** * {@link https://github.com/RicoSuter/NSwag NSwag} generates `x-enumNames` field containing custom enum names. */ 'x-enumNames'?: ReadonlyArray<string>; } /** * This is the root object of the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-document OpenAPI document}. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. */ interface OpenApiV3_1_X { /** * An element to hold various schemas for the document. */ components?: ComponentsObject$1; /** * Additional external documentation. */ externalDocs?: ExternalDocumentationObject$2; /** * **REQUIRED**. Provides metadata about the API. The metadata MAY be used by tooling as required. */ info: InfoObject$2; /** * The default value for the `$schema` keyword within {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object Schema Objects} contained within this OAS document. This MUST be in the form of a URI. */ jsonSchemaDialect?: string; /** * **REQUIRED**. This string MUST be the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#versions version number} of the OpenAPI Specification that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling to interpret the OpenAPI document. This is _not_ related to the API {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#infoVersion `info.version`} string. */ openapi: '3.1.0' | '3.1.1'; /** * The available paths and operations for the API. */ paths?: PathsObject$2; /** * A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. To make security optional, an empty security requirement (`{}`) can be included in the array. */ security?: ReadonlyArray<SecurityRequirementObject$2>; /** * An array of Server Objects, which provide connectivity information to a target server. If the `servers` property is not provided, or is an empty array, the default value would be a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#server-object Server Object} with a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#serverUrl url} value of `/`. */ servers?: ReadonlyArray<ServerObject$1>; /** * A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object Operation Object} must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. */ tags?: ReadonlyArray<TagObject$2>; /** * The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. Closely related to the `callbacks` feature, this section describes requests initiated other than by an API call, for example by an out of band registration. The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses. An {@link https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.1/webhook-example.yaml example} is available. */ webhooks?: Record<string, PathItemObject$2 | ReferenceObject$2>; } /** * A map of possible out-of band callbacks related to the parent operation. Each value in the map is a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-item-object Path Item Object} that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the path item object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. * * To describe incoming requests from the API provider independent from another API call, use the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oasWebhooks `webhooks`} field. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * **Key Expression** * * The key that identifies the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-item-object Path Item Object} is a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtime-expressions runtime expression} that can be evaluated in the context of a runtime HTTP request/response to identify the URL to be used for the callback request. A simple example might be $request.body#/url. However, using a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtime-expressions runtime expression} the complete HTTP message can be accessed. This includes accessing any part of a body that a JSON Pointer {@link https://tools.ietf.org/html/rfc6901 RFC6901} can reference. * * For example, given the following HTTP request: * * ```http * POST /subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning HTTP/1.1 * Host: example.org * Content-Type: application/json * Content-Length: 187 * * { * "failedUrl" : "https://clientdomain.com/failed", * "successUrls" : [ * "https://clientdomain.com/fast", * "https://clientdomain.com/medium", * "https://clientdomain.com/slow" * ] * } * * 201 Created * Location: https://example.org/subscription/1 * ``` * * The following examples show how the various expressions evaluate, assuming the callback operation has a path parameter named `eventType` and a query parameter named `queryUrl`. * * | Expression | Value | * | -------- | ------- | * | $url | https://example.org/subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning | * | $method | POST | * | $request.path.eventType | myevent | * | $request.query.queryUrl | https://clientdomain.com/stillrunning | * | $request.header.content-Type | application/json | * | $request.body#/failedUrl | https://clientdomain.com/failed | * | $request.body#/successUrls/2 | https://clientdomain.com/medium | * | $response.header.Location | https://example.org/subscription/1 | * * **Callback Object Examples** * * The following example uses the user provided `queryUrl` query string parameter to define the callback URL. This is an example of how to use a callback object to describe a WebHook callback that goes with the subscription operation to enable registering for the WebHook. * * ```yaml * myCallback: * '{$request.query.queryUrl}': * post: * requestBody: * description: Callback payload * content: * 'application/json': * schema: * $ref: '#/components/schemas/SomePayload' * responses: * '200': * description: callback successfully processed * ``` * * The following example shows a callback where the server is hard-coded, but the query string parameters are populated from the `id` and `email` property in the request body. * * ```yaml * transactionCallback: * 'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}': * post: * requestBody: * description: Callback payload * content: * 'application/json': * schema: * $ref: '#/components/schemas/SomePayload' * responses: * '200': * description: callback successfully processed * ``` */ interface CallbackObject$1 { /** * A Path Item Object, or a reference to one, used to define a callback request and expected responses. A {@link https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/callback-example.yaml complete example} is available. */ [expression: string]: PathItemObject$2 | ReferenceObject$2; } /** * Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * All the fixed fields declared above are objects that MUST use keys that match the regular expression: `^[a-zA-Z0-9\.\-_]+$`. * * Field Name Examples: * * ``` * User * User_1 * User_Name * user-name * my.org.User * ``` * * **Components Object Example** * * ```yaml * components: * schemas: * GeneralError: * type: object * properties: * code: * type: integer * format: int32 * message: * type: string * Category: * type: object * properties: * id: * type: integer * format: int64 * name: * type: string * Tag: * type: object * properties: * id: * type: integer * format: int64 * name: * type: string * parameters: * skipParam: * name: skip * in: query * description: number of items to skip * required: true * schema: * type: integer * format: int32 * limitParam: * name: limit * in: query * description: max records to return * required: true * schema: * type: integer * format: int32 * responses: * NotFound: * description: Entity not found. * IllegalInput: * description: Illegal input for operation. * GeneralError: * description: General Error * content: * application/json: * schema: * $ref: '#/components/schemas/GeneralError' * securitySchemes: * api_key: * type: apiKey * name: api_key * in: header * petstore_auth: * type: oauth2 * flows: * implicit: * authorizationUrl: https://example.org/api/oauth/dialog * scopes: * write:pets: modify pets in your account * read:pets: read your pets * ``` */ interface ComponentsObject$1 { /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object Callback Objects}. */ callbacks?: Record<string, CallbackObject$1 | ReferenceObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#example-object Example Objects}. */ examples?: Record<string, ExampleObject$2 | ReferenceObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#header-object Header Objects}. */ headers?: Record<string, HeaderObject$2 | ReferenceObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#link-object Link Objects}. */ links?: Record<string, LinkObject$1 | ReferenceObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object Parameter Objects}. */ parameters?: Record<string, ParameterObject$2 | ReferenceObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-item-object Path Item Object}. */ pathItems?: Record<string, PathItemObject$2 | ReferenceObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#request-body-object Request Body Objects}. */ requestBodies?: Record<string, RequestBodyObject$1 | ReferenceObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#response-object Response Objects}. */ responses?: Record<string, ResponseObject$2 | ReferenceObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object Schema Objects}. */ schemas?: Record<string, SchemaObject$2>; /** * An object to hold reusable {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-scheme-object Security Scheme Objects}. */ securitySchemes?: Record<string, SecuritySchemeObject$2 | ReferenceObject$2>; } /** * Contact information for the exposed API. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * @example * ```yaml * name: API Support * url: https://www.example.com/support * email: support@example.com * ``` */ interface ContactObject$2 { /** * The email address of the contact person/organization. This MUST be in the form of an email address. */ email?: string; /** * The identifying name of the contact person/organization. */ name?: string; /** * The URL pointing to the contact information. This MUST be in the form of a URL. */ url?: string; } /** * When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the document of an alternative schema based on the value associated with it. * * When using the discriminator, _inline_ schemas will not be considered. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * The discriminator object is legal only when using one of the composite keywords `oneOf`, `anyOf`, `allOf`. * * In OAS 3.0, a response payload MAY be described to be exactly one of any number of types: * * ```yaml * MyResponseType: * oneOf: * - $ref: '#/components/schemas/Cat' * - $ref: '#/components/schemas/Dog' * - $ref: '#/components/schemas/Lizard' * ``` * * which means the payload _MUST_, by validation, match exactly one of the schemas described by `Cat`, `Dog`, or `Lizard`. In this case, a discriminator MAY act as a "hint" to shortcut validation and selection of the matching schema which may be a costly operation, depending on the complexity of the schema. We can then describe exactly which field tells us which schema to use: * * ```yaml * MyResponseType: * oneOf: * - $ref: '#/components/schemas/Cat' * - $ref: '#/components/schemas/Dog' * - $ref: '#/components/schemas/Lizard' * discriminator: * propertyName: petType * ``` * * The expectation now is that a property with name `petType` _MUST_ be present in the response payload, and the value will correspond to the name of a schema defined in the OAS document. Thus the response payload: * * ```json * { * "id": 12345, * "petType": "Cat" * } * ``` * * Will indicate that the `Cat` schema be used in conjunction with this payload. * * In scenarios where the value of the discriminator field does not match the schema name or implicit mapping is not possible, an optional `mapping` definition MAY be used: * * ```yaml * MyResponseType: * oneOf: * - $ref: '#/components/schemas/Cat' * - $ref: '#/components/schemas/Dog' * - $ref: '#/components/schemas/Lizard' * - $ref: 'https://gigantic-server.com/schemas/Monster/schema.json' * discriminator: * propertyName: petType * mapping: * dog: '#/components/schemas/Dog' * monster: 'https://gigantic-server.com/schemas/Monster/schema.json' * ``` * * Here the discriminator _value_ of `dog` will map to the schema `#/components/schemas/Dog`, rather than the default (implicit) value of `Dog`. If the discriminator _value_ does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Mapping keys MUST be string values, but tooling MAY convert response values to strings for comparison. * * When used in conjunction with the `anyOf` construct, the use of the discriminator can avoid ambiguity where multiple schemas may satisfy a single payload. * * In both the `oneOf` and `anyOf` use cases, all possible schemas MUST be listed explicitly. To avoid redundancy, the discriminator MAY be added to a parent schema definition, and all schemas comprising the parent schema in an `allOf` construct may be used as an alternate schema. * * For example: * * ```yaml * components: * schemas: * Pet: * type: object * required: * - petType * properties: * petType: * type: string * discriminator: * propertyName: petType * mapping: * dog: Dog * Cat: * allOf: * - $ref: '#/components/schemas/Pet' * - type: object * # all other properties specific to a `Cat` * properties: * name: * type: string * Dog: * allOf: * - $ref: '#/components/schemas/Pet' * - type: object * # all other properties specific to a `Dog` * properties: * bark: * type: string * Lizard: * allOf: * - $ref: '#/components/schemas/Pet' * - type: object * # all other properties specific to a `Lizard` * properties: * lovesRocks: * type: boolean * ``` * * a payload like this: * * ```json * { * "petType": "Cat", * "name": "misty" * } * ``` * * will indicate that the `Cat` schema be used. Likewise this schema: * * ```json * { * "petType": "dog", * "bark": "soft" * } * ``` * * will map to `Dog` because of the definition in the `mapping` element. */ interface DiscriminatorObject$1 { /** * An object to hold mappings between payload values and schema names or references. */ mapping?: Record<string, string>; /** * **REQUIRED**. The name of the property in the payload that will hold the discriminator value. */ propertyName: string; } /** * A single encoding definition applied to a single schema property. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * @example * ```yaml * requestBody: * content: * multipart/form-data: * schema: * type: object * properties: * id: * # default is text/plain * type: string * format: uuid * address: * # default is application/json * type: object * properties: {} * historyMetadata: * # need to declare XML format! * description: metadata in XML format * type: object * properties: {} * profileImage: {} * encoding: * historyMetadata: * # require XML Content-Type in utf-8 encoding * contentType: application/xml; charset=utf-8 * profileImage: * # only accept png/jpeg * contentType: image/png, image/jpeg * headers: * X-Rate-Limit-Limit: * description: The number of allowed requests in the current period * schema: * type: integer * ``` */ interface EncodingObject$1 { /** * Determines whether the parameter value SHOULD allow reserved characters, as defined by {@link https://tools.ietf.org/html/rfc3986#section-2.2 RFC3986} `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encodingContentType `contentType`} (implicit or explicit) SHALL be ignored. */ allowReserved?: boolean; /** * The Content-Type for encoding a specific property. Default value depends on the property type: for `object` - `application/json`; for `array` – the default is defined based on the inner type; for all other cases the default is `application/octet-stream`. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types. */ contentType?: string; /** * When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encodingStyle `style`} is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encodingContentType `contentType`} (implicit or explicit) SHALL be ignored. */ explode?: boolean; /** * A map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a `multipart`. */ headers?: Record<string, HeaderObject$2 | ReferenceObject$2>; /** * Describes how a specific property value will be serialized depending on its type. See {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object Parameter Object} for details on the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterStyle `style`} property. The behavior follows the same values as `query` parameters, including default values. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encodingContentType `contentType`} (implicit or explicit) SHALL be ignored. */ style?: | 'deepObject' | 'form' | 'label' | 'matrix' | 'pipeDelimited' | 'simple' | 'spaceDelimited'; } /** * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * In all cases, the example value is expected to be compatible with the type schema of its associated value. Tooling implementations MAY choose to validate compatibility automatically, and reject the example value(s) if incompatible. * * Example Object Examples * * In a request body: * * @example * ```yaml * requestBody: * content: * 'application/json': * schema: * $ref: '#/components/schemas/Address' * examples: * foo: * summary: A foo example * value: {"foo": "bar"} * bar: * summary: A bar example * value: {"bar": "baz"} * 'application/xml': * examples: * xmlExample: * summary: This is an example in XML * externalValue: 'https://example.org/examples/address-example.xml' * 'text/plain': * examples: * textExample: * summary: This is a text example * externalValue: 'https://foo.bar/examples/address-example.txt' * ``` * * In a parameter: * * @example * ```yaml * parameters: * - name: 'zipCode' * in: 'query' * schema: * type: 'string' * format: 'zip-code' * examples: * zip-example: * $ref: '#/components/examples/zip-example' * ``` * * In a response: * * @example * ```yaml * responses: * '200': * description: your car appointment has been booked * content: * application/json: * schema: * $ref: '#/components/schemas/SuccessResponse' * examples: * confirmation-success: * $ref: '#/components/examples/confirmation-success' * ``` */ interface ExampleObject$2 { /** * Long description for the example. {@link https://spec.commonmark.org/ CommonMark syntax} MAY be used for rich text representation. */ description?: string; /** * A URI that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. See the rules for resolving {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#relative-references-in-uris Relative References}. */ externalValue?: string; /** * Short description for the example. */ summary?: string; /** * Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. */ value?: unknown; } /** * Allows referencing an external resource for extended documentation. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * @example * ```yaml * description: Find more info here * url: https://example.com * ``` */ interface ExternalDocumentationObject$2 { /** * A description of the target documentation. {@link https://spec.commonmark.org/ CommonMark syntax} MAY be used for rich text representation. */ description?: string; /** * **REQUIRED**. The URL for the target documentation. This MUST be in the form of a URL. */ url: string; } /** * The Header Object follows the structure of the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object Parameter Object} with the following changes: * * 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. * 1. `in` MUST NOT be specified, it is implicitly in `header`. * 1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterStyle `style`}). * * @example * ```yaml * description: The number of allowed requests in the current period * schema: * type: integer * ``` */ type HeaderObject$2 = Omit<ParameterObject$2, 'in' | 'name'>; /** * The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * @example * ```yaml * title: Sample Pet Store App * summary: A pet store manager. * description: This is a sample server for a pet store. * termsOfService: https://example.com/terms/ * contact: * name: API Support * url: https://www.example.com/support * email: support@example.com * license: * name: Apache 2.0 * url: https://www.apache.org/licenses/LICENSE-2.0.html * version: 1.0.1 * ``` */ interface InfoObject$2 { /** * The contact information for the exposed API. */ contact?: ContactObject$2; /** * A description of the API. {@link https://spec.commonmark.org/ CommonMark syntax} MAY be used for rich text representation. */ description?: string; /** * The license information for the exposed API. */ license?: LicenseObject$2; /** * A short summary of the API. */ summary?: string; /** * A URL to the Terms of Service for the API. This MUST be in the form of a URL. */ termsOfService?: string; /** * **REQUIRED**. The title of the API. */ title: string; /** * **REQUIRED**. The version of the OpenAPI document (which is distinct from the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oasVersion OpenAPI Specification version} or the API implementation version). */ version: string; } /** * License information for the exposed API. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * @example * ```yaml * name: Apache 2.0 * identifier: Apache-2.0 * ``` */ interface LicenseObject$2 { /** * An {@link https://spdx.org/licenses/ SPDX} license expression for the API. The `identifier` field is mutually exclusive of the `url` field. */ identifier?: string; /** * **REQUIRED**. The license name used for the API. */ name: string; /** * A URL to the license used for the API. This MUST be in the form of a URL. The `url` field is mutually exclusive of the `identifier` field. */ url?: string; } /** * The `Link object` represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. * * Unlike _dynamic_ links (i.e. links provided in the response payload), the OAS linking mechanism does not require link information in the runtime response. * * For computing links, and providing instructions to execute them, a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtime-expressions runtime expression} is used for accessing values in an operation and using them as parameters while invoking the linked operation. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * A linked operation MUST be identified using either an `operationRef` or `operationId`. In the case of an `operationId`, it MUST be unique and resolved in the scope of the OAS document. Because of the potential for name clashes, the `operationRef` syntax is preferred for OpenAPI documents with external references. * * **Examples** * * Computing a link from a request operation where the `$request.path.id` is used to pass a request parameter to the linked operation. * * ```yaml * paths: * /users/{id}: * parameters: * - name: id * in: path * required: true * description: the user identifier, as userId * schema: * type: string * get: * responses: * '200': * description: the user being returned * content: * application/json: * schema: * type: object * properties: * uuid: # the unique user id * type: string * format: uuid * links: * address: * # the target link operationId * operationId: getUserAddress * parameters: * # get the `id` field from the request path parameter named `id` * userId: $request.path.id * # the path item of the linked operation * /users/{userid}/address: * parameters: * - name: userid * in: path * required: true * description: the user identifier, as userId * schema: * type: string * # linked operation * get: * operationId: getUserAddress * responses: * '200': * description: the user's address * ``` * * When a runtime expression fails to evaluate, no parameter value is passed to the target operation. * * Values from the response body can be used to drive a linked operation. * * ```yaml * links: * address: * operationId: getUserAddressByUUID * parameters: * # get the `uuid` field from the `uuid` field in the response body * userUuid: $response.body#/uuid * ``` * * Clients follow all links at their discretion. Neither permissions, nor the capability to make a successful call to that link, is guaranteed solely by the existence of a relationship. * * **OperationRef Examples** * * As references to `operationId` MAY NOT be possible (the `operationId` is an optional field in an {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object Operation Object}), references MAY also be made through a relative `operationRef`: * * ```yaml * links: * UserRepositories: * # returns array of '#/components/schemas/repository' * operationRef: '#/paths/~12.0~1repositories~1{username}/get' * parameters: * username: $response.body#/username * ``` * * or an absolute `operationRef`: * * ```yaml * links: * UserRepositories: * # returns array of '#/components/schemas/repository' * operationRef: 'https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1{username}/get' * parameters: * username: $response.body#/username * ``` * * Note that in the use of `operationRef`, the _escaped forward-slash_ is necessary when using JSON references. * * **Runtime Expressions** * * Runtime expressions allow defining values based on information that will only be available within the HTTP message in an actual API call. This mechanism is used by {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#link-object Link Objects} and {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object Callback Objects}. * * The runtime expression is defined by the following {@link https://tools.ietf.org/html/rfc5234 ABNF} syntax * * ```abnf * expression = ( "$url" / "$method" / "$statusCode" / "$request." source / "$response." source ) * source = ( header-reference / query-reference / path-reference / body-reference ) * header-reference = "header." token * query-reference = "query." name * path-reference = "path." name * body-reference = "body" ["#" json-pointer ] * json-pointer = *( "/" reference-token ) * reference-token = *( unescaped / escaped ) * unescaped = %x00-2E / %x30-7D / %x7F-10FFFF * ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped' * escaped = "~" ( "0" / "1" ) * ; representing '~' and '/', respectively * name = *( CHAR ) * token = 1*tchar * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / * "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA * ``` * * Here, `json-pointer` is taken from {@link https://tools.ietf.org/html/rfc6901 RFC6901}, `char` from {@link https://tools.ietf.org/html/rfc7159#section-7 RFC7159} and `token` from {@link https://tools.ietf.org/html/rfc7230#section-3.2.6 RFC7230}. * * The `name` identifier is case-sensitive, whereas `token` is not. * * The table below provides examples of runtime expressions and examples of their use in a value: * * **Examples** * * | Source Location | example expression | notes | * | -------- | ------- | ------- | * | HTTP Method | `$method` | The allowable values for the `$method` will be those for the HTTP operation. | * | Requested media type | `$request.header.accept` | | * | Request parameter | `$request.path.id` | Request parameters MUST be declared in the `parameters` section of the parent operation or they cannot be evaluated. This includes request headers. | * | Request body property | `$request.body#/user/uuid` | In operations which accept payloads, references may be made to portions of the `requestBody` or the entire body. | * | Request URL | `$url` | | * | Response value | `$response.body#/status` | In operations which return payloads, references may be made to portions of the response body or the entire body. | * | Response header | `$response.header.Server` | Single header values only are available | * * Runtime expressions preserve the type of the referenced value. Expressions can be embedded into string values by surrounding the expression with `{}` curly braces. */ interface LinkObject$1 { /** * A description of the link. {@link https://spec.commonmark.org/ CommonMark syntax} MAY be used for rich text representation. */ description?: string; /** * The name of an _existing_, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field. */ operationId?: string; /** * A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object Operation Object}. Relative `operationRef` values MAY be used to locate an existing {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object Operation Object} in the OpenAPI definition. See the rules for resolving {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#relative-references-in-uris Relative References}. */ operationRef?: string; /** * A map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn parameter location} `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id). */ parameters?: Record<string, unknown | string>; /** * A literal value or {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtime-expressions {expression}} to use as a request body when calling the target operation. */ requestBody?: unknown | string; /** * A server object to be used by the target operation. */ server?: ServerObject$1; } /** * Each Media Type Object provides schema and examples for the media type identified by its key. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * **Media Type Examples** * * @example * ```yaml * application/json: * schema: * $ref: "#/components/schemas/Pet" * examples: * cat: * summary: An example of a cat * value: * name: Fluffy * petType: Cat * color: White * gender: male * breed: Persian * dog: * summary: An example of a dog with a cat's name * value: * name: Puma * petType: Dog * color: Black * gender: Female * breed: Mixed * frog: * $ref: "#/components/examples/frog-example" * ``` */ interface MediaTypeObject$2 { /** * A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to `requestBody` objects when the media type is `multipart` or `application/x-www-form-urlencoded`. */ encoding?: Record<string, EncodingObject$1>; /** * Example of the media type. The example object SHOULD be in the correct format as specified by the media type. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` which contains an example, the `example` value SHALL _override_ the example provided by the schema. */ example?: unknown; /** * Examples of the media type. Each example object SHOULD match the media type and specified schema if present. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema. */ examples?: Record<string, ExampleObject$2 | ReferenceObject$2>; /** * The schema defining the content of the request, response, or parameter. */ schema?: SchemaObject$2; } /** * Configuration details for a supported OAuth Flow * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * **OAuth Flow Object Examples** * * ```yaml * type: oauth2 * flows: * implicit: * authorizationUrl: https://example.com/api/oauth/dialog * scopes: * write:pets: modify pets in your account * read:pets: read your pets * authorizationCode: * authorizationUrl: https://example.com/api/oauth/dialog * tokenUrl: https://example.com/api/oauth/token * scopes: * write:pets: modify pets in your account * read:pets: read your pets * ``` */ interface OAuthFlowObject$1 { /** * **REQUIRED (`"implicit"`, `"authorizationCode"`)**. The authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */ authorizationUrl?: string; /** * The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */ refreshUrl?: string; /** * **REQUIRED**. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. The map MAY be empty. */ scopes: Record<string, string>; /** * **REQUIRED (`"password"`, `"clientCredentials"`, `"authorizationCode"`)**. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */ tokenUrl?: string; } /** * Allows configuration of the supported OAuth Flows. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. */ interface OAuthFlowsObject$1 { /** * Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI 2.0. */ authorizationCode?: OAuthFlowObject$1; /** * Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenAPI 2.0. */ clientCredentials?: OAuthFlowObject$1; /** * Configuration for the OAuth Implicit flow */ implicit?: OAuthFlowObject$1; /** * Configuration for the OAuth Resource Owner Password flow */ password?: OAuthFlowObject$1; } /** * Describes a single API operation on a path. * * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. * * @example * ```yaml * tags: * - pet * summary: Updates a pet in the store with form data * operationId: updatePetWithForm * parameters: * - name: petId * in: path * description: ID of pet that needs to be updated * required: true * schema: * type: string * requestBody: * content: * 'application/x-www-form-urlencoded': * schema: * type: object * properties: * name: * description: Updated name of the pet * type: string * status: * description: Updated status of the pet * type: string * required: * - status * responses: * '200': * description: Pet updated. * content: * 'application/json': {} * 'application/xml': {} * '405': * description: Method Not Allowed * content: * 'application/json': {} * 'application/xml': {} * security: * - petstore_auth: * - write:pets * - read:pets * ``` */ interface OperationObject$2 { /** * A map of possible out-of band callbacks related to the parent operation. The key is a unique identifier for the Callback Object. Each value in the map is a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object Callback Object} that describes a request that may be initiated by the API provider and the expected responses. */ callbacks?: Record<string, CallbackObject$1 | ReferenceObject$2>; /** * Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is `false`. */ deprecated?: boolean; /** * A verbose explanation of the operation behavior. {@link https://spec.commonmark.org/ CommonMark syntax} MAY be used for rich text representation. */ description?: string; /** * Additional external documentation for this operation. */ externalDocs?: ExternalDocumentationObject$2; /** * Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is **case-sensitive**. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions. */ operationId?: string; /** * A list of parameters that are applicable for this operation. If a parameter is already defined at the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathItemParameters Path Item}, the new definition will override it but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterName name} and {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn location}. The list can use the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object Reference Object} to link to parameters that are defined at the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#componentsParameters OpenAPI Object's components/parameters}. */ parameters?: ReadonlyArray<ParameterObject$2 | ReferenceObject$2>; /** * The request body applicable for this operation. The `requestBody` is fully supported in HTTP methods where the HTTP 1.1 specification {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.1 RFC7231} has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague (such as {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.1 GET}, {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.2 HEAD} and {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.5 DELETE}), `requestBody` is permitted but does not have well-defined semantics and SHOULD be avoided if possible. */ requestBody?: RequestBodyObject$1 | ReferenceObject$2; /** * The list of possible responses as they are returned from executing this operation. */ responses?: ResponsesObject$2; /** * A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. To make security optional, an empty security requirement (`{}`) can be included in the array. This definition overrides any declared top-level {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oasSecurity `security`}. To remove a top-level security declaration, an empty array can be used. */ security?: ReadonlyArray<SecurityRequirementObject$2>; /** * An alternative `server` array to service this operation. If an alternative `server` object is specified at the Path Item Object or Root level, it will be overridden by this value. */ servers?: ReadonlyArray<ServerObject$1>; /** * A short summary of what the operation does. */ summary?: string; /** * A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. */ tags?: ReadonlyArray<string>; } /** * Describes a single operation parameter. * * A unique parameter is defined by a combination of a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterName name} and {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn location}. * * **Parameter Locations** * * There are four possible parameter locations specified by the `in` field: * * - path - Used together with {@link https:/