cadl/packages/openapi
Timothee Guerin 5ba95d0371
Allow reload of js files in vitest (#3086)
Setup a workaround for the fact that vitest(vite underneath) doesn't
ever want to reload files in the outDir
https://github.com/vitest-dev/vitest/issues/5429

as the outDir isn't actually used in vitest(as far as I understand) this
is just an ok workaround.
2024-04-01 17:54:38 +00:00
..
generated-defs Generate TypeScript decorator signatures from `extern dec` (#2122) 2024-03-19 23:08:59 +00:00
lib Deprecate `@service` version and allow `@OpenAPI.info` to take all properties allowed by openapi (#2902) 2024-02-28 22:56:09 +00:00
src Generate TypeScript decorator signatures from `extern dec` (#2122) 2024-03-19 23:08:59 +00:00
test Deprecate `@service` version and allow `@OpenAPI.info` to take all properties allowed by openapi (#2902) 2024-02-28 22:56:09 +00:00
.eslintrc.cjs Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791) 2024-01-22 09:56:55 -08:00
CHANGELOG.json Prepare Publish for January Release (#2816) 2024-01-24 11:14:23 -08:00
CHANGELOG.md Remove old message burried in changelog (#2989) 2024-03-05 16:05:57 -08:00
README.md Improved ref docs for model (#2951) 2024-02-29 07:21:13 -08:00
package.json Allow reload of js files in vitest (#3086) 2024-04-01 17:54:38 +00:00
tsconfig.config.json Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791) 2024-01-22 09:56:55 -08:00
tsconfig.json Generate TypeScript decorator signatures from `extern dec` (#2122) 2024-03-19 23:08:59 +00:00
vitest.config.ts Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791) 2024-01-22 09:56:55 -08:00

README.md

@typespec/openapi

TypeSpec library providing OpenAPI concepts

Install

npm install @typespec/openapi

Decorators

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

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

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

unknown

Parameters
Name Type Description
key valueof string Extension key. Must start with x-
value 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.

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

unknown

Parameters
Name Type Description
url valueof string Url to the docs
description valueof 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.

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

Namespace

Parameters
Name Type Description
additionalInfo AdditionalInfo Additional information

@operationId

Specify the OpenAPI operationId property for this operation.

@TypeSpec.OpenAPI.operationId(operationId: valueof string)
Target

Operation

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