swagger-codegen
swagger-codegen copied to clipboard
[JAVA] jaxrs-jersey: unnecessary java classes
Description
Assuming there is a schema where one type references another which is not from type: object (see yaml file below): swagger-codegen generates a class for MyExampleString which is never referenced in the class MyExampleObjectType. Instead MyExampleObjectType has the type directly in it as field --> private String myExampleString = null;
Swagger-codegen version
3.0.14
Swagger declaration file content or url
openapi: 3.0.0
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
servers:
- url: 'https://api.example.com'
paths:
/users:
get:
summary: Returns a list of users.
description: Optional extended description in Markdown.
responses:
'200':
$ref: '#/components/schemas/MyExampleObjectType'
components:
schemas:
MyExampleStringType:
type: string
maxLength: 11
MyExampleObjectType:
type: object
properties:
myExampleString:
$ref: '#/components/schemas/MyExampleStringType'
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i ref.yaml -l jaxrs-jersey
Steps to reproduce
Download the yaml above to a file ref.yaml and run the build command.
Suggest a fix/enhancement
Only generate schemas with type: object.