Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

With 'oneOf' the response schema contains an extra 'type: "string". #3076

Closed
Labels
bugSomething isn't working
@dkwakkel

Description

Describe the bug

When using the annotation @apiresponse with a content and the a schema with 'oneOf', the schema of my response object contains an extra 'type: "string". Before 2.8.2 this was not the case.

Code:
@GetMapping("/test")
@ResponseStatus(HttpStatus.OK)
@operation(summary = "get", description = "Provides a response.")
@apiresponse(content = @content(mediaType = MediaTypes.HAL_JSON_VALUE,
schema = @io.swagger.v3.oas.annotations.media.Schema(oneOf = {
Integer.class
})),
responseCode = "200")
public Object get() {
return 1;
}

Result:

 "application/hal+json": {
 "schema": {
 "type": "string",
 "oneOf": [
 {
 "type": "integer",
 "format": "int32"
 }

To Reproduce
Steps to reproduce the behavior:

git clone https://github.com/dkwakkel/springdoc-wrong-type
Run the application (spring boot).
Run curl --location --request GET 'http://localhost:8080/api-docs' --header 'Content-Type: application/json'

The issue did not occur before v2.8.2, and it is still present in v2.8.11.

Expected behavior
The type should not be there:

 "application/hal+json": {
 "schema": {
 "oneOf": [
 {
 "type": "integer",
 "format": "int32"
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /