npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

penify-oapi-codegen

v1.0.3

Published

A JavaScript library to convert OpenAPI schema to Postman collection and generate sample code.

Downloads

4

Readme

Penify Open API Code Gen

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.

Features

  • Convert OpenAPI schema to code examples in multiple languages.
  • Easy to use command-line interface.

Prerequisites

Before installing penify-oapi-codegen, ensure you have the following installed:

  • Node.js (version 12 or higher)
  • npm (Node package manager)

Additionally, you need to install openapi-to-postmanv2 globally. This can be done using the following command:

npm install -g openapi-to-postmanv2

Installation

To install penify-oapi-codegen, run the following command:

npm install penify-oapi-codegen

Usage

Once installed, you can use penify-oapi-codegen from the command line to generate code examples from your OpenAPI schemas.

Generate Code Examples

For all supported languages

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

For Specific Language and Variant

penify-oapi-codegen -i path/to/your/openapi/schema.json -l language -v variant -o path/to/output/schema_with_code.json

Get all supported languages

penify-oapi-codegen -s

Options

  • -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 languages

Supported Code Generators

The 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 |

Examples

Example 1: Generate Python Requests Code Example

penify-oapi-codegen -s ./schemas/api.json -l python -v Requests -o ./examples/schema_python_requests_example.json

Example 2: Generate JavaScript Fetch Code Example

penify-oapi-codegen -s ./schemas/api.json -l javascript -v Fetch -o ./examples/schema_js_fetch_example.json

Contributing

Contributions are welcome! Please open an issue or submit a pull request with your changes.

License

This project is licensed under the ISC License.

Author

sumansaurabh


Footnote: This tool uses openapi-to-postmanv2 for converting OpenAPI schemas. Please ensure it is installed globally.