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

Incorrect "string | string" type generated from the swagger.json using oneOf statement #216

Open
8Duke8 opened this issue Jan 11, 2024 · 0 comments

Comments

@8Duke8
Copy link

8Duke8 commented Jan 11, 2024

Here is a part of the schema: The oneOf condition for phone property below incorrectly generates the type "string | string" as shown in result below (even in the latest version 8.0.0).

SOURCE:

"/users/{userId}": {
      "put": {
        "operationId": "putUserAsAdmin",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^(\\([0-9]{3}\\) ?|[0-9]{3}-)?[0-9]{3}-[0-9]{4}$|^\\d{10}$"
                      },
                      {
                        "type": "string",
                        "minLength": 0,
                        "maxLength": 0
                      }
                    ]**
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
                  },
                  ...

RESULT:

export type PutUserAsAdminRequestBody = {
  phone?: string | string;
  name: string;
  /**
   * @pattern ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
   */
  email: string;
  ...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant