Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8583
Closed
Open
Issue created Jan 30, 2021 by Administrator@rootContributor6 of 6 checklist items completed6/6 checklist items

[BUG][JAVA] AbstractOpenApiSchema package output and declaration missmatch

Created by: BenjaminKlatt

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The class AbstractOpenApiSchema is generated into the model package but declares a model package within the invoker package

Not sure if you prefer a pull request over a bug report. so starting with a bug report and a suggested fix below,

openapi-generator version

openapi-generator-maven-plugin 5.0.0

OpenAPI declaration file content or url

Does not depend on a specific openapi spec

Generation Details

Maven Plugin Configuration

<plugin>
	<groupId>org.openapitools</groupId>
	<artifactId>openapi-generator-maven-plugin</artifactId>
	<version>5.0.0</version>
	<executions>
		<execution>
			<goals>
				<goal>generate</goal>
			</goals>
			<configuration>
				<generatorName>java</generatorName>
				<inputSpec>${openapi.spec.path}</inputSpec>
				<apiPackage>com.example.api</apiPackage>
				<invokerPackage>com.example.invoker</invokerPackage>
				<modelPackage>com.example.model</modelPackage>
				<configOptions>
					<library>native</library>
					<dateLibrary>java8</dateLibrary>
				</configOptions>
			</configuration>
		</execution>
	</executions>
</plugin>
Steps to reproduce
  1. add plugin definition above to a maven project's pom
  2. reference any json based openapi spec as ${openapi.spec.path} property
  3. run mvn mvn clean generate-sources
  4. check AbstractOpenApiSchema.java file for valid package declaration (is generated into com.example.model but declares com.example.invoker.model as package
Related issues/PRs
Suggest a fix

Depending the result expected, the mustach template should use the model package declaration instead of {{invokerPackage}}.model https://github.com/OpenAPITools/openapi-generator/blob/edf153eedef58bd04ffa02a56ecbe60a7165bf0f/modules/openapi-generator/src/main/resources/Java/libraries/native/AbstractOpenApiSchema.mustache#L3 as this is also the case in the native petstore example: https://github.com/OpenAPITools/openapi-generator/blob/edf153eedef58bd04ffa02a56ecbe60a7165bf0f/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java

Assignee
Assign to
Time tracking