It looks like I am having a couple issues.
$ref: '#/definitions/Tenant/properties/name' gets rendered in the Tenant model with type TenantpropertiesnameTenant model only has a name property. The Tenant definition below has 6 total properties which do not make it into the rendered model.$ref: '#/definitions/Tenant/properties/name' with a simple type: string fixes the type issue but still leaves a relatively empty Template model.@property
def name(self):
"""
Gets the name of this Tenant.
:return: The name of this Tenant.
:rtype: Tenantpropertiesname
"""
return self._name
2.2.3
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'
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
swagger-codegen generate --input-spec fetched/tenant-service.yaml --lang python --output sdk
I am not able to find a related issue.
Unsure.
$ref: '#/definitions/Tenant/properties/name'
I don't think you can do that. You can only reference a model not a specified property of a model.
@wing328 Then shouldn't swagger-codegen fail on validation if this is not valid?
@wing328 That's not a requirement in the spec. In fact, the spec says:
The Reference Object is a JSON Reference that uses a JSON Pointer as its value. For this specification, only canonical dereferencing is supported.
The { $ref: "#/some/deeply/nested/object" } syntax is perfectly valid syntax according to the JSON reference RFC.
In addition to the _de rigueur_ definition in the spec, the _de facto_ standards enforced by swagger-codegen validate and other official and non-official tooling all point to deep JSON pointers as valid references.
This issue should be re-opened. The point of a formal specification is to remove the ambiguity caused by assuming "I don't think you can do that."
Just reopened it. Please open an issue in the Swagger Parser project to report this.
Please workaround the problem for the time being by specifying the property type directly instead of using $ref.
Most helpful comment
Please workaround the problem for the time being by specifying the property type directly instead of using $ref.