OpenAPI specification generator in NodeJS that can generate openapi-specs for multiple languages
MIT License
penify-oapi-codegen
is a JavaScript library designed to convert OpenAPI schemas into various code examples. This tool simplifies the process of generating client libraries in different programming languages based on your API documentation.
Before installing penify-oapi-codegen
, ensure you have the following installed:
Additionally, you need to install openapi-to-postmanv2
globally. This can be done using the following command:
npm install -g openapi-to-postmanv2
To install penify-oapi-codegen
, run the following command:
npm install penify-oapi-codegen
Once installed, you can use penify-oapi-codegen
from the command line to generate code examples from your OpenAPI schemas.
It will generate OpenAPI schema for all possible language and variant.
penify-oapi-codegen -i path/to/your/openapi/schema.json -o path/to/output/schema_with_code.json
penify-oapi-codegen -i path/to/your/openapi/schema.json -l language -v variant -o path/to/output/schema_with_code.json
penify-oapi-codegen -s
-i, --input <path>
: Path to the OpenAPI schema file (required).-l, --language <language>
: Programming language for the code example (optional).-v, --variant <variant>
: Variant of the code generator for the specified language (optional).-o, --output <path>
: Path to the output code example file (optional).-s,
: To show list of supported languagesThe tool supports generating code examples for the following languages and variants:
Language | Variant |
---|---|
csharp | RestSharp |
curl | cURL |
go | Native |
http | HTTP |
java | OkHttp |
java | Unirest |
javascript | Fetch |
javascript | jQuery |
javascript | XHR |
c | libcurl |
nodejs | Axios |
nodejs | Native |
nodejs | Request |
nodejs | Unirest |
objective-c | NSURLSession |
ocaml | Cohttp |
php | cURL |
php | HTTP_Request2 |
php | pecl_http |
powershell | RestMethod |
python | http.client |
python | Requests |
ruby | Net::HTTP |
shell | Httpie |
shell | wget |
swift | URLSession |
penify-oapi-codegen -s ./schemas/api.json -l python -v Requests -o ./examples/schema_python_requests_example.json
penify-oapi-codegen -s ./schemas/api.json -l javascript -v Fetch -o ./examples/schema_js_fetch_example.json
Contributions are welcome! Please open an issue or submit a pull request with your changes.
This project is licensed under the ISC License.
sumansaurabh
Footnote: This tool uses openapi-to-postmanv2
for converting OpenAPI schemas. Please ensure it is installed globally.