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

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

Open
BastienCagna opened this issue Jul 7, 2022 · 0 comments

Comments

@BastienCagna
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant