Skip to content

[Question]: Duplicate records if Class and Operation both has @Path param #4984

@bharattomar

Description

@bharattomar

Hi,

I have an API where the class and operation both has @path annotation ( @path("/{id}") ) as shown in following interface example. @path("/v1.0/private/communications") and @path("/{id}")

Interface :

@Tag(name = "CommunicationsAPI")
@Path("/v1.0/private/communications")
public interface CommunicationsAPI extends CommonJsonAPI {

    @GET
    @Path("/{id}")
    CommunicationDetails getCommunicationDetails(
            @Parameter(name = "id", description = "Number which uniquely identifies the Communication.")
            @PathParam("id") String communicationId
    );
}

Implementation class :

@Path("/")
public class CommunicationsAPIImpl implements CommunicationsAPI {

    public CommunicationDetails getCommunicationDetails( String communicationId ) {

    }
}
 

When I generate the openapi.json / openapi.yaml using swagger-maven-plugin-jakarta plugin, the generated JSON / YAML has got two entries.

Open API JSON :

"/v1.0/private/communications/{id}" : {
      "get" : {
        "tags" : [ "CommunicationsAPI" ],
        "summary" : "This API returns details of a communication by id.",
 

"/{id}" : {
      "get" : {
        "tags" : [ "CommunicationsAPI" ],
        "summary" : "This API returns details of a communication by id.",

I think because of this it appears two times in API docs :

Image


I need only "/v1.0/private/communications/{id}" , and "/{id}" should not be created.

Wondering if there is a configuration for plugin to create only one with with full path ?


Following is the plugin configuration in pom.xml

( POM ) :

<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin-jakarta</artifactId>
<version>2.2.30</version>
<dependencies>
	<dependency>
		<groupId>io.swagger.core.v3</groupId>
		<artifactId>swagger-jaxrs2-jakarta</artifactId>
		<version>2.2.28</version>
	</dependency>
</dependencies>
<executions>
	<execution>
		<phase>compile</phase>
		<goals>
			<goal>resolve</goal>
		</goals>
	</execution>
</executions>
<configuration>
	<outputFileName>openapi</outputFileName>
	<outputFormat>JSONANDYAML</outputFormat>
	<encoding>UTF-8</encoding>
	<prettyPrint>true</prettyPrint>
	<readAllResources>false</readAllResources>
	<openapi31>false</openapi31>
	<configurationFilePath>${project.basedir}/src/main/resources/openapi-configuration.json</configurationFilePath>
	<outputPath>${project.build.outputDirectory}/static</outputPath>
	<resourcePackages>
		<package>com.xxx.xxx</package>
	</resourcePackages>
	<defaultResponseCode>true</defaultResponseCode>
	<alwaysResolveAppPath>true</alwaysResolveAppPath>
</configuration>
</plugin>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions