Skip to content

Files

This branch is 1732 commits behind microsoft/typespec:main.

openapi

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 12, 2023
Jul 12, 2023
Jul 12, 2023
Feb 3, 2022
Feb 16, 2023
Jul 18, 2022
Aug 8, 2023
Aug 8, 2023
Aug 7, 2023
Jul 18, 2022
Aug 10, 2023
Feb 24, 2022

@typespec/openapi

TypeSpec library providing OpenAPI concepts

Install

npm install @typespec/openapi

Decorators

OpenAPI

@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.

@OpenAPI.defaultResponse
Target

Model

Parameters

None

Examples
@defaultResponse
model PetStoreResponse is object;

op listPets(): Pet[] | PetStoreResponse;

@extension

Attach some custom data to the OpenAPI element generated from this type.

@OpenAPI.extension(key: valueof string, value: unknown)
Target

(intrinsic) unknown

Parameters
Name Type Description
key valueof scalar string Extension key. Must start with x-
value (intrinsic) unknown Extension value.
Examples
@extension("x-custom", "My value")
@extension(
  "x-pageable",
  {
    nextLink: "x-next-link",
  }
)
op read(): string;

@externalDocs

Specify the OpenAPI externalDocs property for this type.

@OpenAPI.externalDocs(url: valueof string, description?: valueof string)
Target

(intrinsic) unknown

Parameters
Name Type Description
url valueof scalar string Url to the docs
description valueof scalar string Description of the docs
Examples
@externalDocs(
  "https://example.com/detailed.md",
  "Detailed information on how to use this operation"
)
op listPets(): Pet[];

@info

Specify OpenAPI additional information. The service title and version are already specified using @service.

@OpenAPI.info(additionalInfo: OpenAPI.AdditionalInfo)
Target

Namespace

Parameters
Name Type Description
additionalInfo model OpenAPI.AdditionalInfo Additional information

@operationId

Specify the OpenAPI operationId property for this operation.

@OpenAPI.operationId(operationId: valueof string)
Target

Operation

Parameters
Name Type Description
operationId valueof scalar string Operation id value.
Examples
@operationId("download")
op read(): string;