Closed astagi closed 3 years ago
@ahopkins @artcg
I'll add more tests later.
Nice to see a usage example like that, we should get that code snippet in /examples maybe! Looks good, will leave a comment
@artcg I've just added an example for OAS3. Everything works fine, except header parameters. I added AUTHORIZATION header parameter in car_put
@openapi.parameter("AUTHORIZATION", str, location="header")
@openapi.response(200, {"application/json" : Car})
def car_put(request, car_id):
return json(test_car)
Swagger interface detects the header parameter correctly but when I try out the API call it's not included in the curl command. Any ideas?
Looks great, taking a look at that header issue now
Ah in openapi3:
header parameters for "authorization" are ignored as it recommends to use securityschema instead, so can replace that header with something else for the example maybe...
If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.
ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject
hey @artcg thanks for having looked at this! I'll replace it with SecurityScheme
then and see if it works as expected!
@artcg I updated SecurityScheme to make it working in cars example. I don't know if it's my fault, but itooks like Swagger interface is not working as expected, in put car
method when @openapi.secured
decorator is applied I see a little padlock
every time I try to call the API, no value is included in the header by curl again.
Specs also suggest to define securitySchemes
object into components
, but ComponentsBuilder is commented inside builders.py
. Thoughts? (an example here)
Ah looks like we will need the Components field supported for this which will be a bit of a chore, will push something later in the week, until then, lets merge what looks good so far, can you open a new PR from a new branch based upon this one for the security changes?
eheh totally agree @artcg! I'm going to start working on oas3 naming changes and folders structure.. Thank you for your support!
I removed
tests/test_api_oas3.py
because it uses api module, which depends bydoc
moduleThis PR allows to:
openapi
openapi
You can document your OAS3 API in this way