Duplicate classes / Models are generated if ( $ref) referenced externally.
Created by: its-atique1987
Description
If Schemas are referenced in cyclic manner, the Models are generated twice. In below code,the Model ProblemDetails
is generated twice as
ProblemDetails.java
ProblemDetails2.java
Is the correct way to reference? If Not why? and How to fix the above case?
openapi-generator version
openapi-generator-cli-4.0.0-beta3
OpenAPI declaration file content or url
openapi.yaml
openapi: 3.0.0
info:
title: Common Data Types
version: "1.0"
paths:
/{appId}/subscriptions:
get:
summary: read all of the active subscriptions for the app.
operationId: getSubscriptionsById
parameters:
- name: appId
in: path
description: App ID
required: true
schema:
type: integer
format: int64
responses:
'200':
description: OK (Successful)
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Subscription'
'500':
$ref: './common.yaml#/components/responses/E500'
components:
schemas:
ProblemDetails:
type: object
properties:
title:
type: string
description: A short, human-readable summary of the problem
status:
type: integer
description: The HTTP status code for this occurrence of the problem.
Subscription:
type: string
common.yaml
openapi: 3.0.0
info:
title: Common Data Types
version: "1.0"
paths: {}
components:
responses:
E500:
description: Server Error
content:
application/json:
schema:
$ref: './openapi.yaml#/components/schemas/ProblemDetails'
Command line used for generation
java -jar openapi-generator-cli-4.0.0-beta3.jar generate -i openapi.yaml -g spring -o ./temp