3.6.0 • Published 5 days ago

@api-ts/openapi-generator v3.6.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
5 days ago

@api-ts/openapi-generator

The api-ts openapi-generator is a command-line utility for converting an io-ts-http API specification into an OpenAPI specification.

Install

npm install --save-dev @api-ts/openapi-generator

Use

The openapi-generator assumes the io-ts-http apiSpec is exported in the top level of the Typescript file passed as an input parameter. The OpenAPI specification will be written to stdout.

ARGUMENTS:
  <file> - API route definition file

OPTIONS:
  --name, -n <str>       - API name [optional]
  --version, -v <str>    - API version [optional]
  --codec-file, -c <str> - Custom codec definition file [optional]

FLAGS:
  --internal, -i - include routes marked private
  --help, -h     - show help

For example:

npx openapi-generator src/index.ts

Custom codec file

openapi-generator only reads files in the specified package, and stops at the module boundary. This allows it to work even without node_modules installed. It has built-in support for io-ts, io-ts-types, and @api-ts/io-ts-http imports. If your package imports codecs from another external library, then you will have to define them in a custom configuration file so that openapi-generator will understand them. To do so, create a JS file with the following format:

module.exports = (E) => {
  return {
    'io-ts-bigint': {
      BigIntFromString: () => E.right({ type: 'string' }),
      NonZeroBigInt: () => E.right({ type: 'number' }),
      NonZeroBigIntFromString: () => E.right({ type: 'string' }),
      NegativeBigIntFromString: () => E.right({ type: 'string' }),
      NonNegativeBigIntFromString: () => E.right({ type: 'string' }),
      PositiveBigIntFromString: () => E.right({ type: 'string' }),
    },
    // ... and so on for other packages
  };
};

The input parameter E is the namespace import of fp-ts/Either (so that trying to require it from the config file isn't an issue), and the return type is a Record containing AST definitions for external libraries. Refer to KNOWN_IMPORTS here for info on the structure

3.6.0

5 days ago

3.5.1

15 days ago

3.4.0

1 month ago

3.4.1

1 month ago

3.5.0

1 month ago

3.3.3

1 month ago

3.3.2

2 months ago

3.3.1

2 months ago

3.3.0

2 months ago

3.2.1

2 months ago

3.2.0

2 months ago

3.1.3

2 months ago

3.1.2

2 months ago

3.1.1

3 months ago

3.1.0

3 months ago

3.0.4

4 months ago

3.0.3

4 months ago

3.0.2

5 months ago

3.0.1

5 months ago

3.0.0

5 months ago

2.11.0

7 months ago

2.3.0

8 months ago

2.10.1-beta.1

7 months ago

2.2.0

9 months ago

2.5.0

8 months ago

2.4.1

8 months ago

2.10.0

8 months ago

2.4.0

8 months ago

2.7.0

8 months ago

2.6.0

8 months ago

2.9.0

8 months ago

2.7.2

8 months ago

2.8.0

8 months ago

2.7.1

8 months ago

2.1.0

9 months ago

2.0.0

9 months ago

2.9.1

8 months ago

2.7.3

8 months ago

1.0.9

11 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.0

2 years ago

0.2.0-beta.9

2 years ago

0.2.0

2 years ago

0.2.0-beta.10

2 years ago

0.2.0-beta.11

2 years ago

0.2.0-beta.12

2 years ago

0.2.0-beta.2

2 years ago

0.2.0-beta.6

2 years ago

0.2.0-beta.5

2 years ago

0.2.0-beta.4

2 years ago

0.2.0-beta.3

2 years ago

0.2.0-beta.8

2 years ago

0.2.0-beta.7

2 years ago

0.2.0-beta.1

2 years ago

0.1.1-beta.4

2 years ago

0.1.1-beta.3

2 years ago

0.1.1-beta.2

2 years ago

0.1.1-beta.1

2 years ago