swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Add a configuration parameter for the generated ContentType enum to avoid name clashing

Open dompagoj opened this issue 2 weeks ago • 2 comments

Adds a configuration parameter for the generated ContentType enum to avoid name clashing when the openapi schema already has a type called ContentType, this results in the generated enum called ContentType and an interface of the same name, which is a compile error in typescript


[!NOTE] Introduce configurable contentTypeEnumName and update templates to use it, preventing enum/name clashes.

  • Config:
    • Add config.contentTypeEnumName (default: "ContentType") in src/configuration.ts.
  • Templates:
    • Replace hardcoded ContentType with config.contentTypeEnumName in templates/base/http-clients/axios-http-client.ejs and fetch-http-client.ejs (enum declaration, request param type, formatters, header handling).
    • Update templates/default/procedure-call.ejs and templates/modular/procedure-call.ejs to reference the configurable enum when setting request type.
  • Types:
    • Extend GenerateApiConfiguration["config"] with contentTypeEnumName in types/index.ts (with JSDoc/default).
  • Changeset:
    • Add patch changeset describing the new configuration option.

Written by Cursor Bugbot for commit 667c8a35d669fdbf5e4bcea8ef5a83175a8a04a3. This will update automatically on new commits. Configure here.

dompagoj avatar Dec 09 '25 14:12 dompagoj

🦋 Changeset detected

Latest commit: 667c8a35d669fdbf5e4bcea8ef5a83175a8a04a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
swagger-typescript-api Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Dec 09 '25 14:12 changeset-bot[bot]

bugbot run

smorimoto avatar Dec 13 '25 15:12 smorimoto