-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRAFT: 15404 schema map for SerializedPKRelatedField #15449
base: develop
Are you sure you want to change the base?
Conversation
I tested this a bit (by putting this extension to my code locally) and it do not resolves #15404 fully as it is not generating references to the Nested objects like before and instead its generating schema with type "object" and fields inserted inside. |
@deathbeam can you please provide a screenshot or text of what you are expecting to see and what you are seeing? |
Sure. So for example VMInterface before the openapi changes: "required": [
"virtual_machine",
"name"
],
"type": "object",
"properties": {
"id": {
"title": "ID",
"type": "integer",
"readOnly": true
},
"url": {
"title": "Url",
"type": "string",
"format": "uri",
"readOnly": true
},
"display": {
"title": "Display",
"type": "string",
"readOnly": true
},
"virtual_machine": {
"$ref": "#/definitions/NestedVirtualMachine"
},
"name": {
"title": "Name",
"type": "string",
"maxLength": 64,
"minLength": 1
},
"enabled": {
"title": "Enabled",
"type": "boolean"
},
"parent": {
"$ref": "#/definitions/NestedVMInterface"
},
"bridge": {
"$ref": "#/definitions/NestedVMInterface"
},
"mtu": {
"title": "MTU",
"type": "integer",
"maximum": 65536,
"minimum": 1,
"x-nullable": true
},
"mac_address": {
"title": "MAC Address",
"type": "string",
"x-nullable": true
},
"description": {
"title": "Description",
"type": "string",
"maxLength": 200
},
"mode": {
"title": "Mode",
"required": [
"label",
"value"
],
"type": "object",
"properties": {
"label": {
"type": "string",
"enum": [
"Access",
"Tagged",
"Tagged (All)"
]
},
"value": {
"type": "string",
"enum": [
"access",
"tagged",
"tagged-all"
]
}
}
},
"untagged_vlan": {
"$ref": "#/definitions/NestedVLAN"
},
"tagged_vlans": {
"type": "array",
"items": {
"$ref": "#/definitions/NestedVLAN"
},
"uniqueItems": true
},
"vrf": {
"$ref": "#/definitions/NestedVRF"
},
"l2vpn_termination": {
"$ref": "#/definitions/NestedL2VPNTermination"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/NestedTag"
}
},
"custom_fields": {
"title": "Custom fields",
"type": "object",
"default": {}
},
"created": {
"title": "Created",
"type": "string",
"format": "date-time",
"readOnly": true,
"x-nullable": true
},
"last_updated": {
"title": "Last updated",
"type": "string",
"format": "date-time",
"readOnly": true,
"x-nullable": true
},
"count_ipaddresses": {
"title": "Count ipaddresses",
"type": "integer",
"readOnly": true
},
"count_fhrp_groups": {
"title": "Count fhrp groups",
"type": "integer",
"readOnly": true
}
} VMInterface now (with your fix applied): "type": "object",
"description": "Adds support for custom fields and tags.",
"properties": {
"id": {
"type": "integer",
"readOnly": true
},
"url": {
"type": "string",
"format": "uri",
"readOnly": true
},
"display": {
"type": "string",
"readOnly": true
},
"virtual_machine": {
"$ref": "#/components/schemas/NestedVirtualMachine"
},
"name": {
"type": "string",
"maxLength": 64
},
"enabled": {
"type": "boolean"
},
"parent": {
"allOf": [
{
"$ref": "#/components/schemas/NestedVMInterface"
}
],
"nullable": true
},
"bridge": {
"allOf": [
{
"$ref": "#/components/schemas/NestedVMInterface"
}
],
"nullable": true
},
"mtu": {
"type": "integer",
"maximum": 65536,
"minimum": 1,
"nullable": true
},
"mac_address": {
"type": "string",
"nullable": true
},
"description": {
"type": "string",
"maxLength": 200
},
"mode": {
"type": "object",
"properties": {
"value": {
"enum": [
"access",
"tagged",
"tagged-all",
""
],
"type": "string",
"description": "* `access` - Access\n* `tagged` - Tagged\n* `tagged-all` - Tagged (All)",
"x-spec-enum-id": "79109bd9dbb73a3c"
},
"label": {
"type": "string",
"enum": [
"Access",
"Tagged",
"Tagged (All)"
]
}
}
},
"untagged_vlan": {
"allOf": [
{
"$ref": "#/components/schemas/NestedVLAN"
}
],
"nullable": true
},
"tagged_vlans": {
"type": "array",
"items": {
"type": "object",
"description": "Represents an object related through a ForeignKey field. On write, it accepts a primary key (PK) value or a\ndictionary of attributes which can be used to uniquely identify the related object. This class should be\nsubclassed to return a full representation of the related object on read.",
"properties": {
"id": {
"type": "integer",
"readOnly": true
},
"url": {
"type": "string",
"format": "uri",
"readOnly": true
},
"display": {
"type": "string",
"readOnly": true
},
"vid": {
"type": "integer",
"maximum": 4094,
"minimum": 1,
"title": "VLAN ID",
"description": "Numeric VLAN ID (1-4094)"
},
"name": {
"type": "string",
"maxLength": 64
}
},
"required": [
"display",
"id",
"name",
"url",
"vid"
]
}
},
"vrf": {
"allOf": [
{
"$ref": "#/components/schemas/NestedVRF"
}
],
"nullable": true
},
"l2vpn_termination": {
"allOf": [
{
"$ref": "#/components/schemas/NestedL2VPNTermination"
}
],
"readOnly": true,
"nullable": true
},
"tags": {
"type": "array",
"items": {
"$ref": "#/components/schemas/NestedTag"
}
},
"custom_fields": {
"type": "object",
"additionalProperties": {}
},
"created": {
"type": "string",
"format": "date-time",
"readOnly": true,
"nullable": true
},
"last_updated": {
"type": "string",
"format": "date-time",
"readOnly": true,
"nullable": true
},
"count_ipaddresses": {
"type": "integer",
"readOnly": true
},
"count_fhrp_groups": {
"type": "integer",
"readOnly": true
}
},
"required": [
"count_fhrp_groups",
"count_ipaddresses",
"created",
"display",
"id",
"l2vpn_termination",
"last_updated",
"name",
"url",
"virtual_machine"
] Notice how before "tagged_vlans": {
"type": "array",
"items": {
"type": "object",
"description": "Represents an object related through a ForeignKey field. On write, it accepts a primary key (PK) value or a\ndictionary of attributes which can be used to uniquely identify the related object. This class should be\nsubclassed to return a full representation of the related object on read.",
"properties": {
"id": {
"type": "integer",
"readOnly": true
},
"url": {
"type": "string",
"format": "uri",
"readOnly": true
},
"display": {
"type": "string",
"readOnly": true
},
"vid": {
"type": "integer",
"maximum": 4094,
"minimum": 1,
"title": "VLAN ID",
"description": "Numeric VLAN ID (1-4094)"
},
"name": {
"type": "string",
"maxLength": 64
}
},
"required": [
"display",
"id",
"name",
"url",
"vid"
]
}
}, |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further action is taken. |
Fixes: #15404
Fixes drf-spectacular mapping for SerializedPKRelatedField