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

If there is a Required in oneOf, it will not work. #495

Closed
kahirokunn opened this issue Oct 16, 2023 · 3 comments
Closed

If there is a Required in oneOf, it will not work. #495

kahirokunn opened this issue Oct 16, 2023 · 3 comments

Comments

@kahirokunn
Copy link
Contributor

I have this Swagger file:

          "status": {
            "type": "object",
            "nullable": true,
            "properties": {
              "conditions": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "object",
                  "oneOf": [{ "required": ["message", "status", "type"] }],
                  "properties": {
                    "message": { "type": "string" },
                    "status": {
                      "type": "string",
                      "enum": ["Unknown", "True", "False"]
                    },
                    "type": { "type": "string", "enum": ["Ready"] }
                  }
                }
              }
            }
          }

This outputs code like this, where the object has become any:

  status?:
    | ({
        conditions?: (any[] | null) | undefined
      } | null)
    | undefined

If I remove oneOf, it works correctly:

          "status": {
            "type": "object",
            "nullable": true,
            "properties": {
              "conditions": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "object",
                  "required": ["message", "status", "type"],
                  "properties": {
                    "message": { "type": "string" },
                    "status": {
                      "type": "string",
                      "enum": ["Unknown", "True", "False"]
                    },
                    "type": { "type": "string", "enum": ["Ready"] }
                  }
                }
              }
            }
          }
@Xiphe
Copy link
Collaborator

Xiphe commented Nov 27, 2023

Is this related to #503 ?

@kahirokunn
Copy link
Contributor Author

@Xiphe yes

@Xiphe Xiphe closed this as completed in d97fc2e Nov 28, 2023
@Xiphe
Copy link
Collaborator

Xiphe commented Nov 28, 2023

I assume then this is fixed with #503 right? Please re-open in case I misunderstood :)

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

2 participants