Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI as a schema implementation is resolving to null #3015

Closed
paradoxcat opened this issue Nov 12, 2018 · 1 comment
Closed

URI as a schema implementation is resolving to null #3015

paradoxcat opened this issue Nov 12, 2018 · 1 comment

Comments

@paradoxcat
Copy link

When using annotations on our resource method the following Operation annotation will produce a null schema:

@Operation(responses = {
                    @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = URI.class))),
                    @ApiResponse(responseCode = "400", description = "Bad Request"),
                    @ApiResponse(responseCode = "500", description = "Internal Server Error")
            })
 "post" : {
        "operationId" : "exampleOperation",
        "responses" : {
          "200" : {
            "description" : "OK",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/null"
                }
              }
            }
          },
          "400" : {
            "description" : "Bad Request"
          },
          "500" : {
            "description" : "Internal Server Error"
          }
        }
      }

I believe that "java.net.URI.class" is dealt with explicitly by "io.swagger.v3.core.util.PrimitiveType" and we are having similar issues with other classes mentioned there including "java.net.URL" and "java.util.UUID".

frantuma added a commit that referenced this issue Nov 13, 2018
frantuma added a commit that referenced this issue Nov 13, 2018
refs #3015 - fixed schema impl resolving as primitive, add excluded custom classes
@frantuma
Copy link
Member

Thanks for reporting this; #3017 (available in latest 2.0.6-SNAPSHOT on sonatype) fixes it by correctly resolving to string schema with uri format; it also allows to provide a set of classes not to be considered primitive in case this is needed for some reason (in this case URI would be resolved as a non system POJO); please see related test for its usage.

In 2.0.5 version you can instead workaround that by providing the schema your self:

@Operation(responses = {
                    @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(type = "string", format = "uri"))),
                    @ApiResponse(responseCode = "400", description = "Bad Request"),
                    @ApiResponse(responseCode = "500", description = "Internal Server Error")
            })

Closing ticket, please reopen if still experiencing issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants