micronaut-openapi icon indicating copy to clipboard operation
micronaut-openapi copied to clipboard

securitySchemes does not render when using $ref

Open dansiviter opened this issue 3 years ago • 2 comments

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

dansiviter avatar Jan 25 '22 16:01 dansiviter

FYI there is also a question whether DEFAULT should be there. swagger-api/swagger-core#4100

dansiviter avatar Jan 25 '22 16:01 dansiviter

@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.

altro3 avatar May 23 '22 13:05 altro3