Skip to content

Support customising names of generated types #822

@rhysforyou

Description

@rhysforyou

Motivation

Currently the code generated by swift-openapi-generator uses very generic type names that cannot be customised, e.g. Client, Operation, APIProtocol, and so on. These names aren't particularly descriptive (what kind of client? what kind of operation?) and prevent multiple generated API clients from being used within a project without splitting them into their own modules and using fully qualified type names (e.g. MyAPI.Client).

Proposed solution

It would be ideal to have some way to customise the names of generated types. I propose adding a set of configuration options to control this, e.g.:

typeNames:
  Client: MyServiceClient
  Operations: MyServiceOperations
  APIProtocol: MyServiceAPIProtocol

Alternatives considered

In most cases, what you really want is some sort of prefix to disambiguate type names, in which case we could simplify the config by simply providing this prefix:

typeNamePrefix: MyService

This may also be preferable as it maps more cleanly to a command line argument, e.g. swift-openapi-generator generate --type-name-prefix MyService.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions