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

GroupedOpenApi not generating groups

Open ArdentZeal opened this issue 1 year ago • 0 comments

Hi,

I am trying to get GroupedOpenApi to work by switching between different versions of our api. I built a minimal working example, just using the settings route for now, but there are never groups in our generated apiDocs.json. I can change descriptions, security configs and the likes just fine. I tried GroupedOpenApi with beans first, but switched to application properties as I could not get it to work. Nevertheless also the application.properties route does everything BUT the grouping.

We are just using the apiDocs.json, we are not using the built-in swaggerUi.

Hoping for any additional advice you could give me.

application.properties Example

springdoc.api-docs.version=OPENAPI_3_1
springdoc.api-docs.groups.enabled=true
springdoc.pathsToMatch=/f/**/settings

springdoc.group-configs[0].group=groupV1
springdoc.group-configs[0].paths-to-match=/f/k/v1/settings

springdoc.group-configs[1].group=groupV2
springdoc.group-configs[1].paths-to-match=/f/k/v2/settings

springdoc.group-configs[2].group=groupV3
springdoc.group-configs[2].paths-to-match=/f/all/v3/settings

springdoc.cache.disabled=true

Generated apiDocs.json

{
	"openapi": "3.1.0",
	"info": {
		"title": "OpenAPI definition",
		"version": "v0"
	},
	"servers": [
		{
			"url": "<redacted>",
			"description": "Generated server url"
		}
	],
	"paths": {
		"/f/k/v2/settings": {
			"get": {
				"tags": [
					"settings-controller"
				],
				"operationId": "readSettingsV2",
				"responses": {
					"200": {
						"description": "OK",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Settings"
								}
							}
						}
					}
				}
			}
		},
		"/f/k/v1/settings": {
			"get": {
				"tags": [
					"settings-controller"
				],
				"operationId": "readSettings",
				"responses": {
					"200": {
						"description": "OK",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Settings"
								}
							}
						}
					}
				}
			}
		},
		"/f/all/v3/settings": {
			"get": {
				"tags": [
					"settings-controller"
				],
				"operationId": "readSettingsV3",
				"responses": {
					"200": {
						"description": "OK",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Settings"
								}
							}
						}
					}
				}
			}
		}
	},
	"components": {
		"schemas": {
			"Settings": {
				"properties": {
					"stringProperty": {
						"type": "string"
					}
				}
			}
		}
	}
}

Additional context <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-api</artifactId> 2.6.0

Spring Boot: 3.3.2

ArdentZeal avatar Aug 22 '24 13:08 ArdentZeal