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

oneOf validation failed for optional property #97

Open
almaslov opened this issue May 31, 2021 · 0 comments
Open

oneOf validation failed for optional property #97

almaslov opened this issue May 31, 2021 · 0 comments

Comments

@almaslov
Copy link

Hello! I have an issue with describing an optional property with oneOf keyword.
Given a code:

from aiohttp import web
from aiohttp_swagger3 import SwaggerDocs, SwaggerUiSettings


async def handler(request: web.Request) -> web.Response:
    """
    Optional route description
    ---
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              key:
                oneOf:
                  - type: string
                  - type: integer
    responses:
      '200':
        description: Expected response to a valid request
    """
    return web.json_response({})


def main():
    app = web.Application()
    swagger = SwaggerDocs(
        app,
        swagger_ui_settings=SwaggerUiSettings(path="/docs/"),
        version="1.0.0",
    )
    swagger.add_routes([
        web.post("/api/", handler),
    ])
    web.run_app(app, port=8081)

main()

When running
curl -d '{}' -H "Content-Type: application/json" http://0.0.0.0:8081/api/
I expected 200 code, since key is not marked as required.But, instead, I get:
400: {"body": {"key": "fail to validate oneOf"}}

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