swagger-api / swagger-api/swagger-parser
Duplicate Schema nodes with file $ref, single node with http ref
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
I'm hitting an issue with multiple schema nodes getting created when I have more than one component using a single $ref component.
If a relative file $ref is used, two schema nodes get created.
If a http $ref is used, one schema node gets created. (Expected behavior)
Common object:
SourceAccountSummary.yaml
type: object
required:
- sourceAccountId
- totalCost
- currency
properties:
sourceAccountId:
type: string
format: uuid
totalCost:
type: number
format: int32
currency:
type: string
Object 1:
PayoutSummaryAudit.yaml
type: object
required:
- payoutId
- payorId
- status
- instructedDateTime
properties:
payoutId:
type: string
format: uuid
payorId:
type: string
format: uuid
status:
type: string
enum: [ACCEPTED, REJECTED, SUBMITTED, QUOTED, INSTRUCTED, COMPLETED, INCOMPLETE, CONFIRMED]
description: The current status of the payment.
submittedDateTime:
type: string
format: date-time
totalPayments:
type: number
format: int32
totalIncompletePayments:
type: number
format: int32
totalFailedPayments:
type: number
format: int32
sourceAccountSummary:
$ref: SourceAccountSummary.yaml
fxSummaries:
$ref: ./FxSummaries.yaml
payoutMemo:
type: string
Object 2:
PayoutSummaryAudit.yaml
type: object
properties:
payoutId:
type: string
format: uuid
payorId:
type: string
format: uuid
dateTime:
type: string
format: date-time
status:
type: string
enum: [ACCEPTED, REJECTED, SUBMITTED, QUOTED, INSTRUCTED, COMPLETED, INCOMPLETE, CONFIRMED]
submittedDateTime:
type: string
formate: date-time
instructedDateTime:
type: string
formate: date-time
totalPayments:
type: integer
totalIncompletePayments:
type: integer
totalFailedPayments:
type: integer
sourceAccountSummary:
type: array
items:
$ref: SourceAccountSummary.yaml
fxSummaries:
type: array
items:
$ref: FxSummary.yaml
payoutMemo:
type: string
Above causes SourceAccountSummary and SourceAccountSummary_2 to get generated.
log snippet:
"baseName" : "sourceAccountSummary",
"complexType" : "SourceAccountSummary2",
"getter" : "getSourceAccountSummary",
"setter" : "setSourceAccountSummary",
"dataType" : "List<SourceAccountSummary2>",
"datatypeWithEnum" : "List<SourceAccountSummary2>",
"name" : "sourceAccountSummary",
"defaultValue" : "new ArrayList<>()",
"defaultValueWithParam" : " = data.sourceAccountSummary;",
"baseType" : "List",
"containerType" : "array",
"jsonSchema" : "{\n \"type\" : \"array\",\n \"items\" : {\n \"$ref\" : \"#/components/schemas/SourceAccountSummary_2\"\n }\n}",
If reference to the common object (SourceAccountSummary) is updated to raw file in Github, only one schema node is created.
Example $ref:
$ref: 'https://raw.githubusercontent.com/velopaymentsapi/VeloOpenApi/2.6.0-SNAPSHOT/spec/definitions/model/SourceAccountSummary.yaml'
Complete example here.
Expected behavior is for file reference and http reference to function the same.
This is causing down stream issues generated source examples, causing multiple POJOs to get created for the same object.
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 with the linked VeloOpenApi example and compare the local-file and HTTP $ref cases for SourceAccountSummary.yaml. Trace how both references are resolved and registered, then verify that repeated references produce one schema node and one generated POJO rather than SourceAccountSummary and SourceAccountSummary_2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100