Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double import of enum in generated mock file #1798

Closed
AllieJonsson opened this issue Jan 8, 2025 · 0 comments · Fixed by #1799
Closed

Double import of enum in generated mock file #1798

AllieJonsson opened this issue Jan 8, 2025 · 0 comments · Fixed by #1799
Assignees
Labels
bug Something isn't working msw MSW related issues
Milestone

Comments

@AllieJonsson
Copy link
Contributor

What are the steps to reproduce this issue?

Use this schema:

{
    "openapi": "3.0.1",
    "info": {
      "title": "Test",
      "version": "1.0"
    },
    "paths": {
      "/api/useradmin/organization/bankidusage": {
        "get": {
          "tags": [
            "UserAdmin"
          ],
          "responses": {
            "200": {
              "description": "OK",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/BankIdUsage"
                  }
                }
              }
            }
          }
        }
      },
      "/api/useradmin/users/{userId}": {
        "get": {
          "tags": [
            "UserAdmin"
          ],
          "parameters": [
            {
              "name": "userId",
              "in": "path",
              "required": true,
              "schema": {
                "type": "string",
                "format": "uuid"
              }
            }
          ],
          "responses": {
            "200": {
              "description": "OK",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/UserAdminDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "components": {
      "schemas": {
        "BankIdUsage": {
          "enum": [
            "Allow",
            "Deny",
            "Force"
          ],
          "type": "string",
          "x-enumNames": [
            "Allow",
            "Deny",
            "Force"
          ]
        },
        "UserAdminDto": {
          "required": [
            "bankIdUsage"
          ],
          "type": "object",
          "properties": {
            "bankIdUsage": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/BankIdUsage"
                }
              ],
              "x-enumNames": [
                "Allow",
                "Deny",
                "Force"
              ]
            }
          },
          "additionalProperties": false
        }
      }
    }
  }

and generate with mocks enabled.

What happens?

This is the resulting imports:
image

What were you expecting to happen?

Only the value import should happen if both the type and value is needed:
image

Any logs, error output, etc?

Duplicate identifier 'BankIdUsage'.

Any other comments?

PR coming

What versions are you using?

Latest orval

@melloware melloware added the bug Something isn't working label Jan 8, 2025
@melloware melloware added this to the 7.4.1 milestone Jan 8, 2025
@melloware melloware added the msw MSW related issues label Jan 8, 2025
@melloware melloware modified the milestones: 7.4.1, 7.4.2 Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working msw MSW related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants