Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

"security" attribute in paths definition causes an error during parsing #15

@BastienCagna

Description

@BastienCagna

Hi,
The security part of the description raise an error whereas it pass the validation.

{
    "openapi": "3.0.2",
    "info": {
        "title": "FastAPI",
        "version": "0.1.0"
    },
    "paths": {
        "/user/": {
            "get": {
                "tags": [
                    "user"
                ],
                "summary": "Read Users",
                "operationId": "read_users_user__get",
                "parameters": [
                    {
                        "required": false,
                        "schema": {
                            "title": "Skip",
                            "type": "integer",
                            "default": 0
                        },
                        "name": "skip",
                        "in": "query"
                    },
                    {
                        "required": false,
                        "schema": {
                            "title": "Limit",
                            "type": "integer",
                            "default": 100
                        },
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful Response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "title": "Response Read Users User  Get",
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/PUser"
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/HTTPValidationError"
                                }
                            }
                        }
                    }
                },
                **"security": [
                    {
                        "JWTBearer": []
                    },
                    {
                        "OAuth2PasswordBearer": []
                    }
                ]**
            }
        }
    },
    "components": {
        "schemas": {
           [...]
        },
        "securitySchemes": {
            "JWTBearer": {
                "type": "http",
                "scheme": "bearer"
            },
            "OAuth2PasswordBearer": {
                "type": "oauth2",
                "flows": {
                    "password": {
                        "scopes": {},
                        "tokenUrl": "token"
                    }
                }
            }
        }
    }
}

It gives me this parse-log:

Expecting Partial<{ type: ("apiKey" | "http" | "oauth2" | "openIdConnect"), description: string, name: string, in: string, scheme: string, bearerFormat: string, flows:... at 0.paths./user/.get.1.security.0.JWTBearer but instead got: []

Expecting Partial<{ type: ("apiKey" | "http" | "oauth2" | "openIdConnect"), description: string, name: string, in: string, scheme: string, bearerFormat: string, flows:... at 0.paths./user/.get.1.security.1.OAuth2PasswordBearer but instead got: []

The error disappear when I remove the security part of the path definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions