admin管理员组

文章数量:1279208

I'm trying to generate only TypeScript types from my Swagger JSON specification using @openapitools/openapi-generator-cli, but it keeps generating API controllers and resources even though I've disabled API generation in the configuration.

Here's my current openapitools.json configuration:

{
    "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
    "spaces": 2,
    "generator-cli": {
      "version": "6.2.1",
      "generators": {
        "typescript-types": {
          "generatorName": "typescript-axios",
          "output": "src/generated",
          "glob": "swagger.json",
          "skipValidateSpec": true,
          "additionalProperties": {
            "modelPropertyNaming": "original",
            "typescriptThreePlus": true,
            "enumNameSuffix": "",
            "enumPropertyNaming": "UPPERCASE",
            "withInterfaces": true,
            "generateModels": true,
            "supportsES6": true,
            "modelPackage": "models",
            "stringEnums": true,
            "withoutRuntimeChecks": true,
            "generateApis": false,
            "generateApiDocumentation": false,
            "generateApiTests": false,
            "generateModelDocumentation": false,
            "generateModelTests": false
          }
        }
      }
    }
  }

Despite setting generateApis: false and other API-related flags to false, I'm still getting generated code like:

/**
 * ProductResourcesAPIsApi - axios parameter creator
 * @export
 */
export const ProductResourcesAPIsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * @summary Get Product Details by ID
         * @param {string} xRequestID Request Tracking ID
         * @param {string} id 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         * @memberof ProductResourcesAPIsApi
         */
        public productControllerGetDetails(xRequestID

I only want the TypeScript types/interfaces to be generated, without any API-related code. How can I achieve this?

Things I've already tried:

  1. Setting all API-related generation flags to false
  2. Using withSeparateModelsAndApi: true
  3. Setting apiPackage: ""

本文标签: How to generate only TypeScript types without API controllersresources from Swagger JSONStack Overflow