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

[Bug]: Error with multiple schemas in urlencoded request body #932

Open
rganczarek opened this issue Oct 23, 2024 · 0 comments
Open

[Bug]: Error with multiple schemas in urlencoded request body #932

rganczarek opened this issue Oct 23, 2024 · 0 comments
Labels
kind/bug Indicates an issue

Comments

@rganczarek
Copy link

rganczarek commented Oct 23, 2024

Actual Behavior

I have this schema:

...
    post:
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              oneOf:
                - $ref: '#/components/schemas/requestA'
                - $ref: '#/components/schemas/requestB'

and when I test a request with data that follows requestB schema I'm getting this error:

{
    "errors": [
        {
            "title": "Value {'errors': [{'title': \"Value {} not valid for schema of type any: (<ValidationError: '{} is not valid under any of the given schemas'>,)\", 'status': 400, 'type': \"<class 'openapi_core.validation.schemas.exceptions.InvalidSchemaValue'>\"}]} not valid for schema of type any: (<ValidationError: '{\\'errors\\': [{\\'title\\': \"Value {} not valid for schema of type any: (<ValidationError: \\'{} is not valid under any of the given schemas\\'>,)\", \\'status\\': 400, \\'type\\': \"<class \\'openapi_core.validation.schemas.exceptions.InvalidSchemaValue\\'>\"}]} is not valid under any of the given schemas'>,)",
            "status": 400,
            "type": "<class 'openapi_core.validation.schemas.exceptions.InvalidSchemaValue'>",
        }
    ]
}

However, when I change the schema to have only one requestBody schema, I get correct results (requestB schema accepts the payload and reuqestA schema returns a list of wrong fields).

Expected Behavior

Validator should validate request trying according to one of the provided request schemas.

Steps to Reproduce

Described in actual behavior

OpenAPI Core Version

0.19.4

OpenAPI Core Integration

django

Affected Area(s)

schema, validation

References

No response

Anything else we need to know?

No response

Would you like to implement a fix?

No

@rganczarek rganczarek added the kind/bug Indicates an issue label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Indicates an issue
Projects
None yet
Development

No branches or pull requests

1 participant