swagger-api / swagger-api/swagger-parser
JSON reference in $ref isn't acknowledged
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
I initially created this issue in swagger-codegen's repo.
Description
It looks like I am having a couple issues.
$ref: '#/definitions/Tenant/properties/name'gets rendered in theTenantmodel with typeTenantpropertiesname- The rendered
Tenantmodel only has anameproperty. TheTenantdefinition below has 6 total properties which do not make it into the rendered model. - Replacing
$ref: '#/definitions/Tenant/properties/name'with a simpletype: stringfixes the type issue but still leaves a relatively emptyTenantmodel. - 3 is caused due to a parameter name colliding with a root level definition name. Changing either one generates the correct models. If the names are the same then the parameter model will take precedence.
@property
def name(self):
"""
Gets the name of this Tenant.
:return: The name of this Tenant.
:rtype: Tenantpropertiesname
"""
return self._name
Swagger-codegen version
2.2.3
Swagger declaration file content or url
patch:
description: Update a tenant record.
operationId: update
tags:
- tenants
parameters:
- $ref: "#/parameters/id"
- in: body
name: tenant
description: The tenant properties to update
schema:
type: object
required:
- name
properties:
name:
$ref: '#/definitions/Tenant/properties/name'
definitions:
Tenant:
type: object
required:
- name
- handle
properties:
id:
type: integer
format: int32
readOnly: true
name:
type: string
handle:
type: string
pattern: '^[a-zA-Z0-9-]{0,62}$'
createdAt:
type: string
format: date-time
readOnly: true
updatedAt:
type: string
format: date-time
readOnly: true
deletedAt:
type: string
format: date-time
readOnly: true
Command line used for generation
swagger-codegen generate --input-spec fetched/tenant-service.yaml --lang python --output sdk
Steps to reproduce
Related issues/PRs
I am not able to find a related issue.
Suggest a fix/enhancement
Unsure.
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 fetched/tenant-service.yaml using swagger-codegen generate --input-spec fetched/tenant-service.yaml --lang python --output sdk, then inspect the generated Tenant model and the handling of the nested $ref. Done means the property reference resolves to the expected string type, all six Tenant properties remain present, and a parameter name cannot replace the root Tenant definition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100