OAS 3.0 securityScheme type "oauth2" not supported
See original GitHub issueIn the components, if I put a “securityScheme” with type “oauth2”, I get errors :
Schema error at components.securitySchemes['apiOAuth']
should NOT have additional properties
additionalProperty: flows
Schema error at components.securitySchemes['apiOAuth'].type
should be equal to one of the allowed values
allowedValues: apiKey, http, openIdConnect
Schema error at components.securitySchemes['apiOAuth'].flows.implicit
should NOT have additional properties
additionalProperty: tokenUrl
Demonstration API definition
Based on the petstore example.
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: An paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
securitySchemes:
apiOAuth:
type: oauth2
flows:
implicit:
authorizationUrl: 'https://myapi.com/oauth/authorize'
tokenUrl: 'https://myapi.com/oauth/token'
refreshUrl: 'https://myapi.com/oauth/token/refresh'
scopes:
-'write:pets': "modify pets in your account"
Current Behavior
The “oauth2” type for securitySchemes is not implemented ?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Authentication - Swagger
OAS 3 This guide is for OpenAPI 3.0. ... You use securitySchemes to define all security schemes your API supports, then use security...
Read more >OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
Tooling which supports OAS 3.0 SHOULD be compatible with all OAS 3.0.* versions. The patch version SHOULD NOT be considered by tooling, making ......
Read more >OAuth2 client credentials don't working at portal
Looks like you are specifying Authorization Code grant type, not Client Credentials in your Open API Spec. Here's what I use for OAS...
Read more >Using OpenAPI and Swagger UI - Quarkus
The value / is not allowed as it blocks the application from serving anything else. ... quarkus.smallrye-openapi.oauth2-security-scheme-value.
Read more >Documenting the API in OAS 3.0 — Django {json:api} training ...
OAS 3.0 support is still evolving (the standard is just about one year old) so ... version: v1 components: securitySchemes: course_auth: type: oauth2...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok. got it working by replacing
flow
withflows
andtokenUrl
is must. However, the Validation error is still incorrect whentokenUrl
is missing orflows
is written asflow
@rygilles while there’s an issue with the validation error because it’s not giving you the right problem, your definition is invalid because implicit flow doesn’t support the
tokenUrl
field.