Executing the command below to generate an auto-generated API using openapi-generator (v6.0.1 - stable):
openapi-generator-cli generate -i app.json -g typescript -o src/main/api
The json file is valid. Validation was done using
openapi-generator-cli validate -i app.json
.
Even though the command runs successfully, there are missing import statements and initial configuration in the auto-generated docs:
import { } from '';
import * as fs from 'fs';
const configuration = .createConfiguration();
const apiInstance = new .AuthApi(configuration);
Comparing with Datadog's node.js api client, it appears that it should resemble something like this:
import { client, v1 } from '@datadog/datadog-api-client';
const configuration = client.createConfiguration();
const apiInstance = new v1.MonitorsApi(configuration);
The discrepancy raises the question of what might be missing for the generator to provide correct imports for our API.
Edit: Here's an example JSON file:
{
"openapi": "3.0.2",
"info": {
"title": "NinjaAPI",
"version": "1.0.0",
"description": ""
},
"paths": {
"/api/auth/cli/pickup/{pickup_key}/": {
"get": {
"operationId": "users_api_cli_pickup",
"summary": "Cli Pickup",
"parameters": [
{
"in": "path",
"name": "pickup_key",
"schema": {
"title": "Pickup Key",
"type": "string",
"format": "uuid"
},
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PickupResponse"
}
}
}
}
},
"tags": [
"auth"
]
}
}
},
"components": {
"schemas": {
"PickupResponse": {
"title": "PickupResponse",
"type": "object",
"properties": {
"success": {
"title": "Success",
"type": "boolean"
},
"jwt": {
"title": "Jwt",
"type": "string"
}
},
"required": [
"success"
]
}
},
"securitySchemes": {
"UserJWTBearerAuth": {
"type": "http",
"scheme": "bearer"
}
}
}
}