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
94 stars 43 forks source link

Classes that are used as body parameters are not resolved and always result in a parameter of type "Object" #61

Closed elenaferr0 closed 1 year ago

elenaferr0 commented 1 year ago

The JSON below produces the following dart method:

  @PUT('/users/credentials')
  Future<void> changeUserCredentials({
    @Body() required Object credentials,
  });

while the expected content is

  @PUT('/users/credentials')
  Future<void> changeUserCredentials({
    @Body() required Credentials credentials,
  });

JSON:

{
  "swagger": "2.0",
  "info": {
    "version": "1.0",
    "title": "User Service"
  },
  "host": "",
  "basePath": "/api",
  "tags": [
    {
      "name": "Users",
      "description": "User Controller"
    }
  ],
  "paths": {
    "/users/credentials": {
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Changes the user's credentials",
        "operationId": "changeUserCredentials",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "*/*"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "credentials",
            "description": "credentials",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Credentials"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Credentials changed correctly"
          }
        },
        "deprecated": false
      }
    }
  },
  "definitions": {
    "Credentials": {
      "type": "object",
      "required": [
        "email",
        "password"
      ],
      "properties": {
        "email": {
          "type": "string",
          "description": "The new email"
        },
        "password": {
          "type": "string"
        }
      },
      "title": "Credentials"
    }
  }
}