Skip to content

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

@balzmo

Description

@balzmo
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions