[Java] swagger-codegen v3.0.10 generates bad code on API spec processed successfully by v3.0.8
Description
I have a somewhat complex spec (see below) that can be processed successfully by the following configuration using version 3.0.8, but not by 3.0.10. In #9541 I documented a problem in version 3.0.9 when processing that spec that has been fixed. I might have revealed a new problem.
I don't see any warnings during the generation phase, but apparently the class OneOfResponseXnbChoiceNrModeFddDlarFcnFreqInfoSulInformationSulTransmissionBandwidthNcnrb is not generated, so the generated code does not compile. I'll post just the first compile error:
[ERROR] .../swagger-codegen-debug/target/generated-sources/swagger/src/main/java/org/my/client/model/ResponseXnbChoiceNrModeFddDlarFcnFreqInfoSulInformationSulTransmissionBandwidth.java:[21,27] cannot find symbol
[ERROR] symbol: class OneOfResponseXnbChoiceNrModeFddDlarFcnFreqInfoSulInformationSulTransmissionBandwidthNcnrb
[ERROR] location: package org.my.client.model
I use a maven-based build with the following configuration. All the ${foo} things are just strings, anything will do.
<plugin>
<!-- This 2019 version is required for OpenAPI 3 -->
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.10</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/thespec.yaml</inputSpec>
<language>java</language>
<packageName>${client.base.package.name}</packageName>
<modelPackage>${client.base.package.name}.model</modelPackage>
<apiPackage>${client.base.package.name}.api</apiPackage>
<invokerPackage>${client.base.package.name}.invoker</invokerPackage>
<configOptions>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<artifactVersion>${project.version}</artifactVersion>
<library>resttemplate</library>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<licenseName>Apache 2.0</licenseName>
<licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Swagger-codegen version
3.0.10
Command line used for generation
mvn clean install
Steps to reproduce
Generate and compile via mvn clean install
Related issues/PRs
#9541
Swagger declaration file content or url
This is the exact same spec I submitted in #9541. Again I'm sorry for the length, I cut it down as far as I could, a single endpoint and a single schema element.
openapi: 3.0.0
info:
title: Service
version: 1.0.0
servers:
- url: 'http://{apiRoot}/v1'
variables:
apiRoot:
default: 'localhost:3800'
paths:
'/nodeb/{ranName}':
get:
tags:
- nodeb
summary: Get node by name
operationId: getNb
parameters:
- name: ranName
in: path
required: true
description: Name of RAN to return
schema:
type: string
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Response'
components:
schemas:
Response:
properties:
xnb:
properties:
servedNrCells:
items:
properties:
nrNeighbourInfos:
items:
properties:
choiceNrMode:
properties:
fdd:
properties:
dlarFcnFreqInfo:
properties:
frequencyBands:
items:
properties:
nrFrequencyBand:
type: integer
supportedSulBands:
items:
type: integer
type: array
additionalProperties: false
type: object
type: array
nrArFcn:
oneOf:
- type: integer
sulInformation:
properties:
sulArFcn:
oneOf:
- type: integer
sulTransmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
ularFcnFreqInfo:
properties:
frequencyBands:
items:
properties:
nrFrequencyBand:
type: integer
supportedSulBands:
items:
type: integer
type: array
additionalProperties: false
type: object
type: array
nrArFcn:
oneOf:
- type: integer
sulInformation:
properties:
sulArFcn:
oneOf:
- type: integer
sulTransmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
tdd:
properties:
arFcnNrFreqInfo:
properties:
frequencyBands:
items:
properties:
nrFrequencyBand:
type: integer
supportedSulBands:
items:
type: integer
type: array
additionalProperties: false
type: object
type: array
nrArFcn:
oneOf:
- type: integer
sulInformation:
properties:
sulArFcn:
oneOf:
- type: integer
sulTransmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
configuredStac:
type: string
nrCgi:
type: string
nrMode:
oneOf:
- type: string
- type: integer
nrPci:
type: integer
stac5g:
type: string
additionalProperties: false
type: object
type: array
servedNrCellInformation:
properties:
cellId:
type: string
choiceNrMode:
properties:
fdd:
properties:
dlFreqInfo:
properties:
frequencyBands:
items:
properties:
nrFrequencyBand:
type: integer
supportedSulBands:
items:
type: integer
type: array
additionalProperties: false
type: object
type: array
nrArFcn:
oneOf:
- type: integer
sulInformation:
properties:
sulArFcn:
oneOf:
- type: integer
sulTransmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
dlTransmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
ulFreqInfo:
properties:
frequencyBands:
items:
properties:
nrFrequencyBand:
type: integer
supportedSulBands:
items:
type: integer
type: array
additionalProperties: false
type: object
type: array
nrArFcn:
oneOf:
- type: integer
sulInformation:
properties:
sulArFcn:
oneOf:
- type: integer
sulTransmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
ulTransmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
additionalProperties: false
type: object
tdd:
properties:
nrFreqInfo:
properties:
frequencyBands:
items:
properties:
nrFrequencyBand:
type: integer
supportedSulBands:
items:
type: integer
type: array
additionalProperties: false
type: object
type: array
nrArFcn:
oneOf:
- type: integer
sulInformation:
properties:
sulArFcn:
oneOf:
- type: integer
sulTransmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
transmissionBandwidth:
properties:
ncnrb:
oneOf:
- type: string
- type: integer
nrscs:
oneOf:
- type: string
- type: integer
additionalProperties: false
type: object
additionalProperties: false
type: object
additionalProperties: false
type: object
configuredStac:
type: string
nrMode:
oneOf:
- type: string
- type: integer
nrPci:
type: integer
servedPlmns:
items:
type: string
type: array
stac5g:
type: string
additionalProperties: false
type: object
additionalProperties: false
type: object
type: array
additionalProperties: false
type: object
Observing issues with Java codegen as well. Luckily found this post and rolled back to 3.0.8.
FYI, here comes my demo project with reproducable issue: https://github.com/jurikolo/opentracing-kubernetes-demo/tree/bug-9569
Hello guys: This PR has been made to solve this issue.
i'm going to close it, but feel free to reopen it if something wrong is fine.