0b01001001/spectree

[BUG]

abiezersifontes opened this issue · 2 comments

Describe the bug
I got the an error in the url host/apidoc/redoc because of the security schemas i think

To Reproduce
Steps to reproduce the behavior:

  • use next constructor
    openapi = SpecTree("flask", after=api_after_handler, security_schemes=[ SecurityScheme( name="Authorization", data={ "type": "http", "scheme": "bearer", "bearerFormat": "JWT", "in":"header", }, )], security={"Authorization": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT", "in":"header", }})

Expected behavior
the redoc should charge correctly

Error Message
`
Something went wrong...
e.scopes.map is not a function
Stack trace
TypeError: e.scopes.map is not a function
at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:974038
at Array.map ()
at n.value (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:973909)
at Ba (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:491619)
at Ua (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:491418)
at Bs (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:532017)
at kl (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:518396)
at xl (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:518324)
at bl (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:518187)
at fl (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:2:515262)

ReDoc Version: 2.0.0-rc.57
Commit: e4f34f5
`

Desktop (please complete the following information):

  • fedora 33

Python Information (please complete the following information):

  • Python Version Python=3.9
  • Library Version spectree=0.6.7
  • Other dependencies flask=2.0

I think for the security you should use something like this:

api = SpecTree(
    "flask",
    security_schemes=[
        SecurityScheme(
            name="Authorization",
            data={
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "JWT",
                "in": "header",
            },
        )
    ],
    security={
        "Authorization": []
    },
)

Check the How-To part in the README for more details.

I had not understood so well the security parameter, Now I see, thanks you saved my life