OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java] ServerConfiguration is not included in imports when generating from simple OpenAPI file
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- 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
When upgrading OpenAPI, I noticed this PR introduced ServerConfiguration for the restclient library but the generated code does not compile because the ServerConfiguration and ServerVariable POJOs are not imported.
openapi-generator version
7.15.x and 7.16.x
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Metric ACL API
description: Metric ACL API for managing access control lists.
version: 3.3.0
paths:
# paths
components:
securitySchemes:
# security scheme definitions
parameters:
# parameter definitions
headers:
# header definitions
schemas:
# schema definitions
Generation Details
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator.version}</version>
<executions>
<execution>
<id>generate-java-http-client</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<output>${openapi.generation.directory}</output>
<inputSpec>${project.basedir}/src/main/resources/api-characteristic.yaml</inputSpec>
<generatorName>java</generatorName>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>true</generateSupportingFiles>
<supportingFilesToGenerate>ApiClient.java,Authentication.java,HttpBasicAuth.java,HttpBearerAuth.java,ApiKeyAuth.java,JavaTimeFormatter.java,RFC3339DateFormat.java</supportingFilesToGenerate>
<configOptions>
<sourceFolder>.</sourceFolder>
<groupId>${project.groupId}</groupId>
<invokerPackage>${openapi.generation.external.admintool.base.package}</invokerPackage>
<apiPackage>${openapi.generation.external.admintool.base.package}.api</apiPackage>
<modelPackage>${openapi.generation.external.admintool.base.package}.model</modelPackage>
<generateClientAsBean>true</generateClientAsBean>
<dateLibrary>java8</dateLibrary>
<artifactId>${openapi.generation.artifact.id.package}</artifactId>
<artifactVersion>${project.version}</artifactVersion>
<configPackage>${openapi.generation.external.admintool.base.package}.configuration</configPackage>
<basePackage>${openapi.generation.external.admintool.base.package}</basePackage>
<library>restclient</library>
</configOptions>
<typeMappings>
<typeMapping>OffsetDateTime=LocalDateTime</typeMapping>
</typeMappings>
<importMappings>
<importMapping>java.time.OffsetDateTime=java.time.LocalDateTime</importMapping>
</importMappings>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
- Run
mvn installusing provided OpenAPI spec file and Maven plugin config
Related issues/PRs
Suggest a fix
Import the ServerConfiguration and ServerVariable imports in the mustache file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running mvn install with the minimal OpenAPI spec and Maven plugin configuration described in the issue, using the Java restclient library. Locate the Java supporting-file mustache template that generates the imports, add the missing ServerConfiguration and ServerVariable imports, and verify that the generated code compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100