Carapacik / swagger_parser

Dart package that takes an OpenApi definition file and generates REST clients based on retrofit and data classes for your project.
https://pub.dev/packages/swagger_parser
MIT License
87 stars 33 forks source link

Model name suffix #243

Closed BsBrabi closed 1 week ago

BsBrabi commented 1 week ago

Use case

Currently the model classes get the name which are specified in the schema. It would be great if we can add a suffix to model name, so the names of the model classes do not clash with other classes in our app.

Proposal

New configuration parameter model_suffix with default value set to an empty string.

Example:

swagger_parser:
  schema_url: https://petstore.swagger.io/v2/swagger.json
  output_directory: lib/api
  language: kotlin
  model_suffix: Dto

Model Pet will be named PetDto: data class PetDto(...)

StarProxima commented 1 week ago

@BsBrabi You can use the replacement_rules config parameter to do this:

  replacement_rules:
    - pattern: "$"
      replacement: "Dto"