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

Duplicated pattern within allOf when a class is reused #143

Open
coder925 opened this issue Feb 26, 2024 · 0 comments
Open

Duplicated pattern within allOf when a class is reused #143

coder925 opened this issue Feb 26, 2024 · 0 comments

Comments

@coder925
Copy link

In v6.0.0 of MicroElements.Swashbuckle.FluentValidation, I get duplicated pattern rules in swagger.json:

"phone": {
    "type": "string",
    "allOf": [
          {
              "pattern": "^$|\\+(?:[0-9] ?){6,14}[0-9]"
          },
          {
              "pattern": "^$|\\+(?:[0-9] ?){6,14}[0-9]"
          },
          {
              "pattern": "^$|\\+(?:[0-9] ?){6,14}[0-9]"
          }
      ],
    "nullable": true
}

whereas in v5.7.0 I only get one pattern as expected:

"phone": {
    "pattern": "^$|\\+(?:[0-9] ?){6,14}[0-9]",
    "type": "string",
    "nullable": true
}

for a class ContactInfo that has a regex validation on Phone number.

This happens when I have multiple classes that uses the ContactInfo class by composition:

classDiagram
    class ContactInfo {
        +String Phone
    }
    class Teacher {
        +ContactInfo ContactInfo
    }
    class Student {
        +ContactInfo ContactInfo
    }
    Teacher --|> ContactInfo
    Student --|> ContactInfo
Loading

Full sample

https://github.com/coder925/fluentvalidation-withregex

Consequence

The multiple patterns gives issues when generating TypeScript files for this swagger.json in openapi-generator-cli. The property phone will not be a string but an interface.

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