Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Typescript-axios generator]: How to generate only TypeScript types without API controllers/resources? #20719

Open
manastelavane opened this issue Feb 24, 2025 · 0 comments

Comments

@manastelavane
Copy link

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: ""

Is there a way to generate only types using openapi-generator, or should I switch to a different tool? If so, what alternatives would you recommend?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant