Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Query parameter at beginning of path leads to class name "nullApi" #1347

Closed
balzmo opened this issue Oct 30, 2018 · 3 comments · Fixed by #3821
Closed

Query parameter at beginning of path leads to class name "nullApi" #1347

balzmo opened this issue Oct 30, 2018 · 3 comments · Fixed by #3821

Comments

@balzmo
Copy link

balzmo commented Oct 30, 2018

Description

When using generatorName="jaxrs-spec" and the first path fragement in a declaration is a query parameter, the API class is given the name "nullApi".

It happens also in cases where tags are present.

This does not occur e.g. with generatorName="jaxrs-cxf". In this case the tag name or the query parameter name are taken to build the class name.

openapi-generator version

Version 3.3.1

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Name demo
  version: 1.0
paths:
  /{country}/document:
    get:
      summary: Get a document
      tags:
      - document
      operationId: getDocument
      parameters:
      - name: country
        in: path
        required: true
        schema:
          type: string
      responses:
        "201":
          description: The document
        "500":
          description: Server error
tags:
  - name: document
    description: Document tag
Command line used for generation

Maven build:

<build>
    <plugins>
        <plugin>
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <version>3.3.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <inputSpec>${project.basedir}/src/main/resources/test.yaml</inputSpec>
                        <generatorName>jaxrs-spec</generatorName>
                        <output>${project.basedir}/target</output>
                        <configOptions>
                            <sourceFolder>/generated-sources/java</sourceFolder>
                            <useSwaggerAnnotations>false</useSwaggerAnnotations>
                            <interfaceOnly>true</interfaceOnly>
                        </configOptions>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.openapitools</groupId>
                    <artifactId>openapi-generator-maven-plugin</artifactId>
                    <version>3.3.1</version>
                    <type>maven-plugin</type>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>
Steps to reproduce

The effect is reproducible with the given Maven build and all OpenAPI declarations where the first path fragment is a query parameter.

@wing328
Copy link
Member

wing328 commented Nov 20, 2018

@balzmo "nullApi is definitely less than ideal. What about naming it as "DefaultApi" for the time being?

@bensimpson-ch
Copy link
Contributor

@balzmo @wing328
I created a pull request to catch the null (nullApi) and write "DefaultApi" instead. The pull request uses the above yaml as a test:
Its my first pull request on github - please forgive me if I am doing it wrong.
Cheers
Ben

@wing328
Copy link
Member

wing328 commented Sep 4, 2019

Thanks for the PR by @bensimpson-ch to fix the the issue.

@balzmo please give another try with the latest master.

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

Successfully merging a pull request may close this issue.

3 participants