micronaut-openapi
micronaut-openapi copied to clipboard
securitySchemes does not render when using $ref
Expected Behavior
@OpenAPIDefinition(
info = @Info(title = "My API", version = "0.1"),
security = @SecurityRequirements(name = "foo", scopes = "bar")
)
@SecurityScheme(name = "foo", type = DEFAULT, ref = "foo.yml#/components/securitySchemes/foo")
Should result in:
openapi: 3.0.1
info:
title: My API
version: "0.1"
security:
- foo:
- bar
components:
securitySchemes:
foo:
$ref: 'foo.yml#/components/securitySchemes/foo'
Actual Behaviour
It results in:
openapi: 3.0.1
info:
title: My API
version: "0.1"
...where security and components/securitySchemes are missing.
Steps To Reproduce
No response
Environment Information
- JDK 11
- Gradle 7.0.2
Example Application
No response
Version
micronaut-openapi:3.2.0
FYI there is also a question whether DEFAULT should be there. swagger-api/swagger-core#4100
@dansiviter This is not a bug. You specified an invalid value for type. If you read the documentation, you will see this:
The type of the security scheme. Valid values are "apiKey", "http", "oauth2", "openIdConnect".
Returns:
String type
By the way, when you run the build, you will see such an entry in the logs
warning: Error converting [{"name":"foo","type":"DEFAULT","ref":"foo.yml#/components/securitySchemes/foo"}]: to class io.swagger.v3.oas.models.security.SecurityScheme: SecurityScheme type DEFAULT not allowed
at [Source: UNKNOWN; byte offset: #UNKNOWN]
Change the value of type to any other (apiKey, http, oauth2, openIdConnect) and everything will work correctly
@graemerocher This issue can be closed - this is not a bug.