|
| 1 | +# OpenAPI JSON Schema Generator |
| 2 | + |
| 3 | +This application generates OpenAPI JSON schemas based on configuration data from a single input file. |
| 4 | + |
| 5 | +## 🚀 To Run the Generator |
| 6 | + |
| 7 | +``` |
| 8 | +npm run generate --prefix packages/generators-v2 |
| 9 | +``` |
| 10 | + |
| 11 | +The script will process data from the json_for-docs_generation.json file and produce schema files accordingly. |
| 12 | + |
| 13 | +## Input File Structure |
| 14 | + |
| 15 | +The generator reads configuration from a JSON file named json_for-docs_generation.json, which should follow this structure: |
| 16 | + |
| 17 | +```json |
| 18 | +[ |
| 19 | + { |
| 20 | + "name": "modelName", |
| 21 | + "url": "https://ai.aimlapi.com/docs-json?endpoint=openai/chat-completions&model=o1-pro&source=openai", |
| 22 | + "alias": "alias", |
| 23 | + "category": "text-models-llm", |
| 24 | + "vendor": "OpenAI", |
| 25 | + "codeSamples": "chat-completion", |
| 26 | + "customUrlApi": "https://api.aimlapi.com/v1/images/generations", |
| 27 | + "customParams": { |
| 28 | + "text_param": "text", |
| 29 | + "object_param": { |
| 30 | + "name": "object", |
| 31 | + "type": "string" |
| 32 | + }, |
| 33 | + "array_param": ["param1", 212], |
| 34 | + "object_array_param": [ |
| 35 | + { |
| 36 | + "name": "object1", |
| 37 | + "type": "string" |
| 38 | + }, |
| 39 | + { |
| 40 | + "name": 21212, |
| 41 | + "type": "string" |
| 42 | + } |
| 43 | + ] |
| 44 | + }, |
| 45 | + "hideTryItPanel": true |
| 46 | + } |
| 47 | +] |
| 48 | +``` |
| 49 | + |
| 50 | +### Field Descriptions |
| 51 | + |
| 52 | +| Field | Type | Required | Description | |
| 53 | +| ------------------ | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 54 | +| **name** | `string` | ✅ | Model name (required if using a ready-made code sample). | |
| 55 | +| **url** | `string` | ✅ | URL to the JSON documentation endpoint. | |
| 56 | +| **alias** | `string` | ✅ | The output filename (used when saving the generated schema). | |
| 57 | +| **category** | `string` | ✅ | The category under which the schema is grouped (e.g. `text-models-llm`). | |
| 58 | +| **vendor** | `string` | ✅ | Model vendor name (e.g. `OpenAI`). | |
| 59 | +| **codeSamples** | `string` | ❌ | Optional. Determines which predefined code samples to include. Options: <br>• `chat-completion` <br>• `chat-completion-audio` <br>• `text-to-image` <br>• `image-to-image` <br>• `gpt-image-edit` <br>• `hide` (if your want hide codeSample) <br>• `custom` (requires `customUrlApi` and `customParams`) | |
| 60 | +| **customUrlApi** | `string` | ❌ | Used when `codeSamples` is set to `"custom"`. Specifies a custom API endpoint. | |
| 61 | +| **customParams** | `object` | ❌ | Custom parameters for the API request. Supports simple, object, array, and object-array formats. | |
| 62 | +| **hideTryItPanel** | `boolean` | ❌ | If set to true, hides the “Try It” panel in the generated documentation. Useful for endpoints that are not meant to be interactive. | |
| 63 | +## Example Usage |
| 64 | +### Example 1 — Ready-made code sample |
| 65 | +```json |
| 66 | +{ |
| 67 | + "name": "gpt-4o", |
| 68 | + "url": "https://ai.aimlapi.com/docs-json?endpoint=openai/chat-completions&model=gpt-4o&source=openai", |
| 69 | + "alias": "gpt-4o", |
| 70 | + "category": "text-models-llm", |
| 71 | + "vendor": "OpenAI", |
| 72 | + "codeSamples": "chat-completion", |
| 73 | + "hideTryItPanel": true |
| 74 | +} |
| 75 | +``` |
| 76 | +### Example 2 — Custom API configuration |
| 77 | +```json |
| 78 | +{ |
| 79 | + "name": "flux/dev", |
| 80 | + "url": "https://ai.aimlapi.com/docs-json?endpoint=internal/image-generations&model=flux/dev&source=falai", |
| 81 | + "alias": "flux-dev", |
| 82 | + "category": "image-models", |
| 83 | + "vendor": "Black-Forest-Labs", |
| 84 | + "codeSamples": "custom", |
| 85 | + "customUrlApi": "https://api.aimlapi.com/v1/images/generations", |
| 86 | + "customParams": { |
| 87 | + "prompt": "text", |
| 88 | + "style": "string", |
| 89 | + "size": ["512x512", "1024x1024"] |
| 90 | + }, |
| 91 | + "hideTryItPanel": false |
| 92 | +} |
| 93 | +``` |
| 94 | +## Output |
| 95 | + |
| 96 | +Each schema is generated and saved under a filename based on its category, vendor and alias (e.g., category/vendor/alias.json) inside /docs/api-references. |
0 commit comments