openapi3-parser
openapi3-parser copied to clipboard
[Feature] Support for schemas/strings with JWT format
What is a problem? JWT, or JSON Web Tokens, are a proposed standard for communication via APIs, as per RFC 7519. Currently, if the Parser tries to parse a string with the format JWT, it throws a ParserError: "Invalid vaue for 'format' property, got 'JWT'".
Describe the solution you'd like Support JWT as a String format, and parse OpenAPI specs accordingly.
Describe alternatives you've considered Ignore the JWT format, and format JWT strings as "normal" strings.
Hey @nick75g, could you provide an example of the spec here to reproduce this behaviour? I am not sure that format should be used for that rather than bearerFormat as mentioned here
Good point. I'm not 100% sure either, since I haven't done too much with OpenAPI specs myself, but I'll check in with whoever created the specs I was using. The particular example was formatted like this:
paths:
/foo:
post:
parameters:
in: header
name: X-SampleToken
schema:
type: string
format: JWT
I noticed that the bearer_auth in that example was empty.
Good point. I'm not 100% sure either, since I haven't done too much with OpenAPI specs myself, but I'll check in with whoever created the specs I was using.
For this particular case, it should be defined as auth and used in a specific endpoint instead of working with a header parameter manually. However, the string format by default contains only some common values mentioned here - like this.
There is a way to disable this strict enum and use any value by passing strict_enum=False in the parse() method.