swagger-api / swagger-api/swagger-codegen

[JAVA] Model not correctly generated

Open
#11,842 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Some generated model code seems to be missing properties, ProcessInstanceDto for example. Generating it with maven plugin. openapi-codegen generates these models correctly.

Swagger-codegen version

3.0.34

Swagger declaration file content or url

openapi.json is packed in camunda-engine-rest-openapi jar.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<artifactId>camunda-test-client</artifactId>
	<groupId>io.test</groupId>
	<version>0.0.1</version>
	<packaging>jar</packaging>

	<properties>
		<maven.compiler.source>17</maven.compiler.source>
		<maven.compiler.target>17</maven.compiler.target>
		<source.generated.swagger.main>src/java/main</source.generated.swagger.main>
		<source.generated.swagger>${project.build.directory}/generated-sources/swagger</source.generated.swagger>
		<source.generated>${project.build.directory}/generated-sources/</source.generated>
		<camunda.version>7.16.0</camunda.version>
		<spring.version>5.3.20</spring.version>
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.fasterxml.jackson</groupId>
				<artifactId>jackson-bom</artifactId>
				<version>2.10.1</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<!-- DEPENDENCIES REQUIRED FOR CODE GENERATION -->
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>1.18.24</version>
		</dependency>

		<!-- swagger -->
		<dependency>
			<groupId>io.swagger.core.v3</groupId>
			<artifactId>swagger-annotations</artifactId>
			<version>2.2.1</version>
		</dependency>

		<!-- HTTP client: Spring RestTemplate -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<!-- JSON processing: jackson -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-annotations</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.jaxrs</groupId>
			<artifactId>jackson-jaxrs-json-provider</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.datatype</groupId>
			<artifactId>jackson-datatype-jsr310</artifactId>
		</dependency>
		<dependency>
			<groupId>javax.annotation</groupId>
			<artifactId>javax.annotation-api</artifactId>
			<version>1.3.2</version>
		</dependency>
	</dependencies>

	<build>
		<finalName>${project.artifactId}</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>unpack-dependencies</id>
						<phase>initialize</phase>
						<goals>
							<goal>unpack</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>org.camunda.bpm</groupId>
									<artifactId>camunda-engine-rest-openapi</artifactId>
									<version>${camunda.version}</version>
									<type>jar</type>
									<includes>openapi.json</includes>
								</artifactItem>
							</artifactItems>
							<outputDirectory>${project.build.directory}/resources</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>io.swagger.codegen.v3</groupId>
				<artifactId>swagger-codegen-maven-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>generate</goal>
						</goals>
						<phase>generate-sources</phase>
						<configuration>
							<inputSpec>${project.build.directory}/resources/openapi.json</inputSpec>
							<language>java</language>
							<library>resttemplate</library>
							<invokerPackage>io.camunda.client.invoker</invokerPackage>
							<apiPackage>io.camunda.client.api</apiPackage>
							<modelPackage>io.camunda.client.dto</modelPackage>
							<generateApiTests>false</generateApiTests>
							<generateApiDocumentation>false</generateApiDocumentation>
							<generateModelTests>false</generateModelTests>
							<generateModelDocumentation>false</generateModelDocumentation>
							<generateSupportingFiles>true</generateSupportingFiles>
							<configOptions>
								<interfaceOnly>true</interfaceOnly>
								<sourceFolder>${source.generated.swagger.main}</sourceFolder>
								<java8>true</java8>
								<dateLibrary>java8</dateLibrary>
							</configOptions>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
Command line used for generation

mvn compile

Steps to reproduce

Tried cleaning and recompiling, seems to happen every time.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the Maven plugin and mvn compile, using openapi.json from the camunda-engine-rest-openapi jar. Compare the generated ProcessInstanceDto properties with the declarations in openapi.json and with the output from openapi-codegen; done means the missing model properties are accounted for and generated correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.