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

Change interface name #244

Open BsBrabi opened 1 week ago

BsBrabi commented 1 week ago

Use case

As we cannot modify the schema file we use, we want to override the retrofit interface name, which is currently by default Client.

Proposal

With our OpenApi example, the retrofit interface is named ClientClient. We propose a new parameter client_name which overrides the client name.

OpenApi example:

openapi: 3.0.0
info:
  title: Test-API
  version: 1.0.0
tags:
  - name: Test-API
    description: Test-API
paths:
  "/ping":
    post:
      summary: Processes a ping
      operationId: processPing
      responses:
        '200':
          description: successful operation

Swagger parser config:

swagger_parser:
  schema_path: test.yaml
  output_directory: TestApi
  language: kotlin
  client_name: Test

The new parameter would name the retrofit interface TestClient instead of ClientClient:

interface TestClient {
    /// Processes a ping
    @POST("/ping")
    suspend fun processPing()
}