Skip to content

About

Express + Spectral + OpenAPI-Generator

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

express-openapi-client

## Project tree

.
├── docker-compose.yml
├── eslint.config.cjs
├── package.json
├── README.md
├── tsconfig.json
├── scripts/
│   └── generate-openapi.sh
└── src/
    ├── index.ts
    └── openapi/
        ├── client/
        │   └── pet/
        │       ├── api.ts
        │       ├── base.ts
        │       ├── common.ts
        │       ├── configuration.ts
        │       └── index.ts
        └── specification/
            └── pet.yaml

## Execution steps

1. Ensure Docker and Docker Compose are installed and running.

2. Generate the client (development):

PS D:\express-openapi-client> docker-compose run --rm openapi-generator

3. Developer-style workflow (format → lint → build → start)

npm run build:check

npm run start

---------------
## Example output

PS D:\express-openapi-client> docker-compose run --rm openapi-generator
Running OpenAPI Generator...
Generating client for: pet
Spec file : src/openapi/specification/pet.yaml
Output dir: src/openapi/client/pet
[main] INFO  o.o.c.l.PythonFastAPIServerCodegen - Skipping sorting of path operations, order matters, let the developer decide via their specification file.[main] INFO  o.o.c.l.PythonFastAPIServerCodegen - Skipping sorting of path operations, order matters, let the developer decide via their specification file.[main] WARN  o.o.codegen.DefaultCodegen - OpenAPI 3.1 support is still in beta. To report an issue related to 3.1 spec, please kindly open an issue in the Github repo: https://github.com/openAPITools/openapi-generator.
[main] INFO  o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO  o.o.c.ignore.CodegenIgnoreProcessor - Output directory (/local/src/openapi/client/pet) does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: typescript-axios (client)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'typescript-axios' is considered stable.
[main] INFO  o.o.c.l.AbstractTypeScriptClientCodegen - Hint: Environment variable 'TS_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write"' (Linux/Mac)
[main] INFO  o.o.c.l.AbstractTypeScriptClientCodegen - Note: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] WARN  o.o.codegen.DefaultCodegen - OpenAPI 3.1 support is still in beta. To report an issue related to 3.1 spec, please kindly open an issue in the Github repo: https://github.com/openAPITools/openapi-generator.
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/docs/Category.md
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/docs/ModelError.md
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/docs/Pet.md
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/docs/Tag.md
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/docs/PetApi.md
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/index.ts
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/base.ts
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/common.ts
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/api.ts
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/configuration.ts
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/git_push.sh
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/.gitignore
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/.npmignore
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/.openapi-generator-ignore
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/.openapi-generator/VERSION
[main] INFO  o.o.codegen.TemplateManager - writing file /local/src/openapi/client/pet/.openapi-generator/FILES
############################################################################################
# Thanks for using OpenAPI Generator.                                                      #
# We appreciate your support! Please consider donation to help us maintain this project.   #
# https://opencollective.com/openapi_generator/donate                                      #
############################################################################################
Cleaning up unnecessary files...
OpenAPI client generation completed ✅
PS D:\express-openapi-client>

---------------

Note:
OpenAPI 3.1 support is still in beta. To report an issue related to 3.1 spec,
please kindly open an issue in the Github repo: https://github.com/openAPITools/openapi-generator.

---------------

Reference

OpenAPI Generator
https://openapi-generator.tech/

OpenAPITools/openapi-generator
https://github.com/OpenAPITools/openapi-generator

@openapitools/openapi-generator-cli
https://www.npmjs.com/package/@openapitools/openapi-generator-cli

OpenAPI Specification
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md

Documentation for the typescript-axios Generator
https://openapi-generator.tech/docs/generators/typescript-axios/

Generating Client-Side API code
https://medium.com/@devriesrjj/generating-front-end-api-code-2517b8d89b26

Using OpenAPI Generator With Docker
https://www.youtube.com/watch?v=9MuEP01h1XU

About

Express + Spectral + OpenAPI-Generator

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Contributors

Languages