Skip to content

Commit 7b4924f

Browse files
committed
chore: Update API Code Generator documentation and generate sample code for all languages and variants
1 parent bbe0a48 commit 7b4924f

1 file changed

Lines changed: 118 additions & 1 deletion

File tree

README.md

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,118 @@
1-
# api-code-generator
1+
2+
# API Code Generator
3+
4+
API Code Generator 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.
5+
6+
## Features
7+
8+
- Convert OpenAPI schema to code examples in multiple languages.
9+
- Easy to use command-line interface.
10+
11+
## Prerequisites
12+
13+
Before installing `api-code-generator`, ensure you have the following installed:
14+
15+
- [Node.js](https://nodejs.org/) (version 12 or higher)
16+
- npm (Node package manager)
17+
18+
Additionally, you need to install `openapi-to-postmanv2` globally. This can be done using the following command:
19+
20+
```bash
21+
npm install -g openapi-to-postmanv2
22+
```
23+
24+
## Installation
25+
26+
To install `api-code-generator`, run the following command:
27+
28+
```bash
29+
npm install api-code-generator
30+
```
31+
32+
## Usage
33+
34+
Once installed, you can use `api-code-generator` from the command line to generate code examples from your OpenAPI schemas.
35+
36+
### Generate Code Examples
37+
38+
```bash
39+
api-code-generator generate -i path/to/your/openapi/schema.yaml -l language -v variant -o path/to/output/code_example
40+
```
41+
42+
### Options
43+
44+
- `generate`: Generates code examples from an OpenAPI schema.
45+
- `-i, --input <path>`: Path to the OpenAPI schema file (required).
46+
- `-l, --language <language>`: Programming language for the code example (required).
47+
- `-v, --variant <variant>`: Variant of the code generator for the specified language (required).
48+
- `-o, --output <path>`: Path to the output code example file (required).
49+
50+
## Supported Code Generators
51+
52+
The tool supports generating code examples for the following languages and variants:
53+
54+
| Language | Variant |
55+
|---------------|---------------|
56+
| C | libcurl |
57+
| C# | HttpClient |
58+
| C# | RestSharp |
59+
| cURL | cURL |
60+
| Dart | http |
61+
| Go | Native |
62+
| HTTP | HTTP |
63+
| Java | OkHttp |
64+
| Java | Unirest |
65+
| JavaScript | Fetch |
66+
| JavaScript | jQuery |
67+
| JavaScript | XHR |
68+
| Kotlin | OkHttp |
69+
| NodeJs | Axios |
70+
| NodeJs | Native |
71+
| NodeJs | Request |
72+
| NodeJs | Unirest |
73+
| Objective-C | NSURLSession |
74+
| OCaml | Cohttp |
75+
| PHP | cURL |
76+
| PHP | Guzzle |
77+
| PHP | pecl_http |
78+
| PHP | HTTP_Request2 |
79+
| PowerShell | RestMethod |
80+
| Python | http.client |
81+
| Python | Requests |
82+
| R | httr |
83+
| R | RCurl |
84+
| Rust | Reqwest |
85+
| Ruby | Net:HTTP |
86+
| Shell | Httpie |
87+
| Shell | wget |
88+
| Swift | URLSession |
89+
90+
## Examples
91+
92+
### Example 1: Generate Python Requests Code Example
93+
94+
```bash
95+
api-code-generator generate -i ./schemas/api.yaml -l Python -v Requests -o ./examples/python_requests_example.py
96+
```
97+
98+
### Example 2: Generate JavaScript Fetch Code Example
99+
100+
```bash
101+
api-code-generator generate -i ./schemas/api.yaml -l JavaScript -v Fetch -o ./examples/js_fetch_example.js
102+
```
103+
104+
## Contributing
105+
106+
Contributions are welcome! Please open an issue or submit a pull request with your changes.
107+
108+
## License
109+
110+
This project is licensed under the ISC License.
111+
112+
## Author
113+
114+
[Your Name]
115+
116+
---
117+
118+
*Footnote: This tool uses `openapi-to-postmanv2` for converting OpenAPI schemas. Please ensure it is installed globally.*

0 commit comments

Comments
 (0)