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
100 stars 47 forks source link

Support of default values for ref enum types #92

Closed StarProxima closed 1 year ago

StarProxima commented 1 year ago

OpenApi:

    "/api/bells/pagination": {
      "get": {
        "summary": "Read Bells Pagination",
        "operationId": "read_bells_pagination_api_bells_pagination_get",
        "parameters": [
          {
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SortOrder",
              "default": "asc"
            },
            "name": "sort_order",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_BellInDb_"
                }
              }
            }
          }
        }
      }
    }

Before:

  @GET('/api/bells/pagination')
  Future<PageBellInDb> readBellsPaginationApiBellsPaginationGet({
    @Query('sort_order') SortOrder sortOrder = asc, // <-- error
  });

After:

  @GET('/api/bells/pagination')
  Future<PageBellInDb> readBellsPaginationApiBellsPaginationGet({
    @Query('sort_order') SortOrder sortOrder = SortOrder.asc,
  });