Decorators
TypeSpec.OpenAPI
Section titled âTypeSpec.OpenAPIâ@defaultResponse
Section titled â@defaultResponseâSpecify that this model is to be treated as the OpenAPI default response.
This differs from the compiler built-in @error decorator as this does not necessarily represent an error.
@TypeSpec.OpenAPI.defaultResponseModel
Parameters
Section titled âParametersâNone
Examples
Section titled âExamplesâ@defaultResponsemodel PetStoreResponse is object;
op listPets(): Pet[] | PetStoreResponse;@extension
Section titled â@extensionâAttach some custom data to the OpenAPI element generated from this type.
@TypeSpec.OpenAPI.extension(key: valueof string, value: valueof unknown)unknown
Parameters
Section titled âParametersâ| Name | Type | Description |
|---|---|---|
| key | valueof string | Extension key. |
| value | valueof unknown | Extension value. |
Examples
Section titled âExamplesâ@extension("x-custom", "My value")@extension("x-pageable", #{ nextLink: "x-next-link" })op read(): string;@externalDocs
Section titled â@externalDocsâSpecify the OpenAPI externalDocs property for this type.
@TypeSpec.OpenAPI.externalDocs(url: valueof string, description?: valueof string)unknown
Parameters
Section titled âParametersâ| Name | Type | Description |
|---|---|---|
| url | valueof string | Url to the docs |
| description | valueof string | Description of the docs |
Examples
Section titled âExamplesâ@externalDocs( "https://example.com/detailed.md", "Detailed information on how to use this operation")op listPets(): Pet[];Specify OpenAPI additional information.
The service title is already specified using @service.
@TypeSpec.OpenAPI.info(additionalInfo: valueof TypeSpec.OpenAPI.AdditionalInfo)Namespace
Parameters
Section titled âParametersâ| Name | Type | Description |
|---|---|---|
| additionalInfo | valueof AdditionalInfo | Additional information |
@operationId
Section titled â@operationIdâSpecify the OpenAPI operationId property for this operation.
@TypeSpec.OpenAPI.operationId(operationId: valueof string)Operation
Parameters
Section titled âParametersâ| Name | Type | Description |
|---|---|---|
| operationId | valueof string | Operation id value. |
Examples
Section titled âExamplesâ@operationId("download")op read(): string;@tagMetadata
Section titled â@tagMetadataâSpecify OpenAPI additional information.
@TypeSpec.OpenAPI.tagMetadata(name: valueof string, tagMetadata: valueof TypeSpec.OpenAPI.TagMetadata)Namespace
Parameters
Section titled âParametersâ| Name | Type | Description |
|---|---|---|
| name | valueof string | tag name |
| tagMetadata | valueof TagMetadata | Additional information |
Examples
Section titled âExamplesâ@service@tagMetadata( "Tag Name", #{ description: "Tag description", externalDocs: #{ url: "https://example.com", description: "More info.", `x-custom`: "string" }, `x-custom`: "string", })namespace PetStore {
}