swagger-api / swagger-api/swagger-codegen
[JAVA] Swagger model definitions are not being converted into code by codegen.
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Hi,
I can't figure out why my Java code from codegen is missing some of the models.
Such as HasMore, Limit, offset and count are not created, but Links is.
Does anyone know what the problem here could be?
Swagger-codegen version
Swagger declaration file content
If you post the code inline, please wrap it with
swagger: '2.0'
info:
description: Api for looking up codebases.
version: 1.0.0
title: Codesbases
contact:
name: contact name
email: contact@email.coms
host: xxx.dk
basePath: /api/codebases/
schemes:
- https
paths:
/:
get:
tags:
- Codebase
summary: Request codebases
description: Request all available codebases.
produces:
- json
parameters: []
responses:
'200':
description: Returns a JSON structure listing all available code bases.
schema:
$ref: '#/definitions/jsonObjCodebase'
examples:
application/json:
items:
- id: 4024
name: Carina Codebase
type: ICU
etag: '"zdZ+0AHc28tbGh/N4qq6vTm8gF8="'
links:
- rel: contents
- id: 4008
name: Sensor Modules
type: MONITOR
etag: '"c+O9BmQMcQuyvAHgiLwDAZ5ewmA="'
links:
- rel: contents
'401':
description: 'Unauthorized: The request has not been applied because it lacks valid authentication credentials for the target resource.'
'403':
description: 'Forbidden: The server understood the request but refuses to authorize it.'
'404':
description: 'Not Found: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'
'500':
description: 'Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request'
default:
description: Unexpected error
security:
- basicAuth: []
'/details/{codebase_id}':
get:
tags:
- Codebase
summary: Request codebase via id
description: Request details for a specific codebases.
produces:
- json
parameters:
- name: codebase_id
in: path
description: The codebase ID.
required: true
type: string
responses:
'200':
description: Returns a JSON structure with details about a specific codebase.
schema:
$ref: '#/definitions/jsonObjCodebaseDetails'
examples:
application/json:
items:
- id: 330344
code: 00.A010
codeclass: 2
criticality: 1
assembly: Elektronik
description: No plausibility of sensor values during power-on self-test (POST)
failure: 'The blower is set to a defined speed on starting. The electronics assembly monitors whether sensors PS1, PS2 and DPS1 detect a pressure rise. The sensors are additionally zeroed. The sensor values are checked for plausibility in the process.'
cause: 'During the power-on self-test (POST) the output values of sensors PS1, PS2 or DPS1 were detected as not plausible.'
remedy: '1.) If 00.A009 occurs in the log, refer to remedy 00.A009. 2.) In the HIT software on the "Pneumatic assembly diagram" tab check the plausibility of the pressure sensors. 3.) Check the internal tubing of the Sensor PCB. 4.) Replace Autozero valves V2, V3 of the valve assembly. 5.) Replace the Sensor PCB.'
etag: '"MxeXlOVG/U1GQmxMXzKGn4wmqs8="'
'401':
description: 'Unauthorized: The request has not been applied because it lacks valid authentication credentials for the target resource.'
'403':
description: 'Forbidden: The server understood the request but refuses to authorize it.'
'404':
description: 'Not Found: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.'
'500':
description: 'Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request'
default:
description: Unexpected error
security:
- basicAuth: []
securityDefinitions:
basicAuth:
description: HTTP Basic Authentication
type: basic
definitions:
itemsCodebase:
type: array
items:
$ref: '#/definitions/itemsCodebase_inner'
itemsCodebaseDetails:
type: array
items:
$ref: '#/definitions/itemsCodebaseDetails_inner'
jsonObjCodebaseDetails:
type: object
properties:
items:
$ref: '#/definitions/itemsCodebaseDetails'
hasMore:
$ref: '#/definitions/hasMore'
limit:
$ref: '#/definitions/limit'
offset:
$ref: '#/definitions/offset'
count:
$ref: '#/definitions/count'
links:
$ref: '#/definitions/links'
jsonObjCodebase:
type: object
properties:
items:
$ref: '#/definitions/itemsCodebase'
hasMore:
$ref: '#/definitions/hasMore'
limit:
$ref: '#/definitions/limit'
offset:
$ref: '#/definitions/offset'
count:
$ref: '#/definitions/count'
links:
$ref: '#/definitions/links'
links:
type: array
description: Links to the....
items:
$ref: '#/definitions/links_inner'
hasMore:
type: boolean
description: 'Has more, boolean.'
limit:
type: integer
description: The object limit.
offset:
type: integer
description: The offset.
count:
type: integer
description: The number of objects found.
itemsCodebase_inner:
properties:
id:
type: integer
description: The codebase ID
name:
type: string
description: The name of the codebase
type:
type: string
description: The type of the codebase
etag:
type: string
description: The etag of the codebase
links:
$ref: '#/definitions/links'
description: An array containing code bases.
itemsCodebaseDetails_inner:
properties:
id:
type: integer
description: The codebase ID
code:
type: string
codeclass:
type: integer
criticality:
type: integer
assembly:
type: string
description:
type: string
failure:
type: string
cause:
type: string
remedy:
type: string
etag:
type: string
description: An array containing code bases.
links_inner:
properties:
rel:
type: string
description: The relationship between the current document and the linked document.
href:
type: string
description: The linked address.
Command line used for generation
Here is the output from swagger-codegen-cli-2.2.3, and as you can see HasMore and the others are not created.
$ java -DapiTests=false -jar swagger-codegen-cli-2.2.3.jar generate -i swagger.json -l java
[main] INFO io.swagger.parser.Swagger20Parser - reading from swagger.json
[main] INFO io.swagger.codegen.ignore.CodegenIgnoreProcessor - No .swagger-codegen-ignore file found.
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\model\ItemsCodebase.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\ItemsCodebase.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\model\ItemsCodebaseDetails.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\ItemsCodebaseDetails.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\model\ItemsCodebaseDetailsInner.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\ItemsCodebaseDetailsInner.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\model\ItemsCodebaseInner.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\ItemsCodebaseInner.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\model\JsonObjCodebase.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\JsonObjCodebase.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\model\JsonObjCodebaseDetails.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\JsonObjCodebaseDetails.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\model\Links.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\Links.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\model\LinksInner.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\LinksInner.md
[main] WARN io.swagger.codegen.DefaultCodegen - Empty operationId found for path: get /. Renamed to auto-generated operationId: rootGet
[main] WARN io.swagger.codegen.DefaultCodegen - Empty operationId found for path: get /details/{codebase_id}. Renamed to auto-generated operationId: detailsCodebase_idGet
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java\io\swagger\client\api\CodebaseApi.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\docs\\CodebaseApi.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\pom.xml
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\README.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\build.gradle
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\build.sbt
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\settings.gradle
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\gradle.properties
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\AndroidManifest.xml
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\.travis.yml
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\ApiClient.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\StringUtil.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client/auth\HttpBasicAuth.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client/auth\ApiKeyAuth.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client/auth\OAuth.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client/auth\OAuthFlow.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\gradlew
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\gradlew.bat
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\gradle\wrapper\gradle-wrapper.properties
[main] INFO io.swagger.codegen.DefaultGenerator - writing file D:\git\dele\.\gradle\wrapper\gradle-wrapper.jar
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\git_push.sh
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\.gitignore
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\ApiException.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\Configuration.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\Pair.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client/auth\Authentication.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\ApiCallback.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\ApiResponse.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\JSON.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\ProgressRequestBody.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\ProgressResponseBody.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\src\main\java/io/swagger/client\GzipRequestInterceptor.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\.swagger-codegen-ignore
[main] INFO io.swagger.codegen.AbstractGenerator - writing file D:\git\dele\.\.swagger-codegen\VERSION
Related
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
Reproduce the issue with swagger-codegen-cli-2.2.3, the supplied swagger.json, and the shown Java generation command. Compare the generated JsonObjCodebase and JsonObjCodebaseDetails models with their hasMore, limit, offset, count, and links definitions; done means the referenced models are consistently generated or the omission is explained and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100