Skip to content

[BUG] Generating incorrect OpenAPI specification when using multiple types the same tag. #696

@Tijs-2

Description

@Tijs-2

When adding the same tag on two different controllers it adds the tag twice under tags.
It does add them correctly under the paths but because it is added twice under tags the openapi spec is invalid.
It would be nice to add the same tag on multiple controllers so I can group them.

So the following code:

@Tag(name = "test")
@Controller("/test1")
public class ExampleController {

    @Get
    public String test() {
        return "test";
    }
}

@Tag(name = "test")
@Controller("/test2")
public class ExampleController2 {

    @Get
    public String test() {
        return "test";
    }
}

Generatates the following openapi spec:

{
	"openapi" : "3.0.1",
	"info" : {
		"title" : "",
		"version" : ""
	},
	"servers" : [
		{
			"url" : "localhost:8080",
			"description" : "local testing"
		}
	],
	"tags" : [
		{
			"name" : "test",
			"description" : ""
		},
		{
			"name" : "test",
			"description" : ""
		}
	],
	"paths" : {
		"/test1" : {
			"get" : {
				"tags" : [
					"test"
				],
				"summary" : "",
				"description" : "",
				"responses" : {
					"200" : {
						"description" : "",
						"content" : {
							"application/json" : {
								"schema" : {
									"type" : "string"
								}
							}
						}
					}
				}
			}
		},
		"/test2" : {
			"get" : {
				"tags" : [
					"test"
				],
				"summary" : "",
				"description" : "",
				"responses" : {
					"200" : {
						"description" : "",
						"content" : {
							"application/json" : {
								"schema" : {
									"type" : "string"
								}
							}
						}
					}
				}
			}
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions