Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@typespec/openapi3

Package Overview
Dependencies
Maintainers
1
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typespec/openapi3

TypeSpec library for emitting OpenAPI 3.0 from the TypeSpec REST protocol binding

  • 0.41.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
63K
increased by1.38%
Maintainers
1
Weekly downloads
 
Created
Source

TypeSpec OpenAPI 3.0 Emitter

This package provides the TypeSpec emitter to produce OpenAPI 3.0 output from TypeSpec source.

Install

In your typespec project root

npm install @typespec/openapi3

Emit OpenAPI 3.0 spec

  1. Via the command line
tsp compile . --emit @typespec/openapi3
  1. Via the config

Add the following to the tspconfig.yaml file.

emitters:
  @typespec/openapi3: true

For configuration see options

Use OpenAPI 3.0 specific decorators:

import "@typespec/openapi3";

using OpenAPI;

// Using `using`
@useRef("common.json#/components/schemas/Foo")
model Foo {}

// Using fully qualified names
@OpenAPI.oneOf
union MyUnion {
  cat: Cat,
  dog: Dog,
}

Decorators

@useRef

Syntax:

@useRef(urlString)

@useRef

@useRef is used to replace the TypeSpec model type in emitter output with a pre-existing named OpenAPI schema.

@oneOf

Syntax:

@oneOf()

@oneOfemits oneOf keyword for a union type in the resulting OpenAPI 3.0 specification. It indicates that the value of union type can only contain exactly one of the subschemas.

@oneOf can only be applied to a union types.

Emitter options:

Emitter options can be configured via the tspconfig.yaml configuration:

emitters:
  '@typespec/openapi3':
    <optionName>: <value>


# For example
emitters:
  '@typespec/openapi3':
    outputFile: my-custom-openapi.json

or via the command line with

--option "@typespec/openapi3.<optionName>=<value>"

# For example
--option "@typespec/openapi3.output-file=my-custom-openapi.json"

output-file

Configure the name of the swagger output file relative to the compiler output-path.

new-line

Set the newline character for emitting files. Can be either:

  • lf(Default)
  • crlf

omit-unreachable-types

Only include types referenced via an operation.

See also

Keywords

FAQs

Package last updated on 03 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc