Skip to content

[BUG] Enum in query not resolving name correctly. #441

@frederikstonge

Description

@frederikstonge

Steps to reproduce

/api/enum-name-mapping-value0

Since this enum is used as query parameter, the default value is not resolving correctly, generating value0 instead of asc.

Expected results

SortDirection.asc as default parameter

Actual results

SortDirection.value0 as default parameter

Your OpenApi snippet

{
  "openapi": "3.0.1",
  "info": {
    "title": "Test",
    "description": "Test.",
    "version": "v1"
  },
  "paths": {
    "/api/enum-name-mapping-value0": {
      "get": {
        "tags": [
          "Bugs"
        ],
        "parameters": [
          {
            "name": "sort",
            "in": "query",
            "description": "\n\n0 = ASC\n\n1 = DESC",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/SortDirection"
                }
              ],
              "default": 0,
              "x-enumNames": [
                "ASC",
                "DESC"
              ]
            },
            "x-enumNames": [
              "ASC",
              "DESC"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/DummyResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DummyResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/DummyResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DummyRequest": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string",
            "description": "",
            "nullable": true
          },
          "testType": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TestType"
              }
            ],
            "description": "",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TestType": {
        "enum": [
          0,
          1
        ],
        "type": "integer",
        "description": "",
        "format": "int32",
        "x-enumNames": [
          "DEFAULT",
          "ADDRESS"
        ]
      },
      "DummyResponse": {
        "type": "object",
        "properties": {
          "dummy": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SortDirection": {
        "enum": [
          0,
          1
        ],
        "type": "integer",
        "description": "\n\n0 = ASC\n\n1 = DESC",
        "format": "int32",
        "x-enumNames": [
          "ASC",
          "DESC"
        ]
      }
    },
    "securitySchemes": {
      "Bearer Access Token": {
        "type": "http",
        "description": "Put your access token from the login endpoint.",
        "scheme": "Bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}

Code sample

Code sample
[Paste your code here]

Logs

Logs
[Paste your logs here]

Dart version and used packages versions

Dart version
[Paste your output here]
Packages version
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions