Skip to content
New issue

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

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

Already on GitHub? # to your account

jaxrs-spec: @Path-Generation is wrong for resource-path "/" #758

Closed
attrobit opened this issue Aug 7, 2018 · 1 comment
Closed

jaxrs-spec: @Path-Generation is wrong for resource-path "/" #758

attrobit opened this issue Aug 7, 2018 · 1 comment

Comments

@attrobit
Copy link
Contributor

attrobit commented Aug 7, 2018

Description

When we define our primary resource under path "/" (see declaration file), jaxrs-spec generates the following stub:

@Path("/default")
@Api(description = "the default API")
...
public interface DefaultApi {
...
}

The generated path "/default" is wrong and the name of the interface is confusing. Additionally to that the following interface will be generated for the path "/{uuid}":

@Path("/{uuid}")
@Api(description = "the {uuid} API")
...
public interface UuidApi {
}
openapi-generator version

3.2.1-SNAPSHOT

OpenAPI declaration file content or url
paths:
  /:
    get:
      summary: findArbeitsstoff
      operationId: FindArbeitsstoffe
      tags:
        - Arbeitsstoff
      parameters:
        - name: cas
          in: query
          description: Kennung des Arbeitsstoffes
          required: true
          schema:
            $ref: '#/components/schemas/CasKey'
      responses:
        200:
          description: Gefilterte Arbeitsstoffsliste
          content:
            application/arbeitsstoff-v2+pdf:
              schema:
                $ref: '#/components/schemas/ArbeitsstoffDtoList'
            application/arbeitsstoff-v2+json:
              schema:
                $ref: '#/components/schemas/ArbeitsstoffDtoList'
  /{uuid}:
    get:
      summary: getArbeitsstoff
      description: Gibt einen individuellen Arbeitsstoff zurück
      tags:
        - Arbeitsstoff
      operationId: GetArbeitsstoff
      parameters:
        - name: uuid
          in: path
          description: UUID des Arbeitsstoffes
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        200:
          description: Ausgewählter Arbeitsstoff
          content:
            application/arbeitsstoff-v2+pdf:
              schema:
                $ref: '#/components/schemas/ArbeitsstoffDto'
            application/arbeitsstoff-v2+json:
              schema:
                $ref: '#/components/schemas/ArbeitsstoffDto'
        590:
          $ref: '#/components/responses/ProgrammierFehler'
    put:
Command line used for generation

Maven configuration:

                    <plugin>
                        <groupId>org.openapitools</groupId>
                        <artifactId>openapi-generator-maven-plugin</artifactId>
                        <version>3.2.1-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <inputSpec>
                                        ${project.basedir}/src/main/resources/${project.serviceContract.fileName}
                                    </inputSpec>
                                    <output>${project.basedir}</output>
                                    <language>jaxrs-spec</language>
                                    <generateModels>true</generateModels>
                                    <generateApis>true</generateApis>
                                    <generateApiTests>false</generateApiTests>
                                    <generateApiDocumentation>false</generateApiDocumentation>
                                    <generateModelTests>false</generateModelTests>
                                    <configOptions>
                                        <apiPackage>${project.targetPackage}</apiPackage>
                                        <modelPackage>${project.targetPackage}.dto</modelPackage>
                                        <sourceFolder>src/main/generated</sourceFolder>
                                        <dateLibrary>java8</dateLibrary> <!-- jaxrs-spec -->
                                        <interfaceOnly>true</interfaceOnly> <!-- jaxrs-spec -->
                                        <returnResponse>true</returnResponse> <!-- jaxrs-spec -->
                                    </configOptions>
                                    <generateSupportingFiles>false</generateSupportingFiles>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
Steps to reproduce

Define some primary resources under path "/" (see example contract) and generate the jaxrs stubs.

Related issues/PRs
Suggest a fix/enhancement

My suggestion is using the tags to grouping the methods into interfaces like jaxrs-cxf.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants