-
Notifications
You must be signed in to change notification settings - Fork 264
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
Openapi schema inconsistencies #1422
Comments
Currently I am applying these patches with jsonpatch to the schema before generating the bindings to get a working binding. |
Similar issue with local_context_data being a string instead of a map[string]interface{}
|
We’re run aground on a few other items that has us considering |
I will try and take a look over the next week or so, quite busy lately however. |
Hi @glennmatthews, Attempted to generate from both 1.3.2 and 1.3.3's schema,
Ignoring the validation error allows it to generate (Although its not happy) From a quick look it appears that at least some of the issues still apply, will go through it in more depth soon. |
Hi @UnityDG , I was trying this successfully:
|
Generating a full client with the following (With 1.3.3 running locally)
|
As discussed on slack, Changing JobInput.properties.data.default = {} |
Corresponding code change here would be: diff --git a/nautobot/extras/api/serializers.py b/nautobot/extras/api/serializers.py
index 9ccb18124..2c5393c4f 100644
--- a/nautobot/extras/api/serializers.py
+++ b/nautobot/extras/api/serializers.py
@@ -786,7 +786,7 @@ class JobClassDetailSerializer(JobClassSerializer): # pylint: disable=abstract-
class JobInputSerializer(serializers.Serializer): # pylint: disable=abstract-method
- data = serializers.JSONField(required=False, default="")
+ data = serializers.JSONField(required=False, default={})
commit = serializers.BooleanField(required=False, default=None)
schedule = NestedScheduledJobSerializer(required=False) |
It might also be interesting to test setting |
#2398 adds |
#2092 corrected the issue with |
@nautobot/core Do we know how many of these issues remain? |
Tested with https://demo.nautobot.com/api/docs/?api_version=1.5 (current version: 1.5.7)
For the For the
cable_peer:
type: object
additionalProperties: {}
nullable: true
readOnly: true
connected_endpoint:
type: object
additionalProperties: {}
nullable: true
readOnly: true This probably needs work (TODO), though this may be tricky to represent in the schema since these are GenericForeignKeys in the data model and so could be one of several different data types and serializers.
This is fixed in 2.0 by #3225
Another case (similar to 2. above) where assigned_object:
type: object
additionalProperties: {}
nullable: true
readOnly: true
This seems incorrect to me - it should be just an arbitrary object (dict) of JSON data. The schema is currently generic: config_context:
type: object
additionalProperties: {}
readOnly: true Can anyone provide sample "Actually returned" data showing the issue here?
Another GenericForeignKey currently represented as a generic Summary
|
* Fix #1422: add polymorphic types for serializer GenericForeignKeys * Fix linting and unit-test * Update nautobot/extras/api/nested_serializers.py * Cable.termination_a and .termination_b are never null * Remove some code that turned out to be unneeded for the schema * More schema corrections, disambiguate component names * Add framework for schema testing and some sample tests for dcim schemas * Rework get_all_concrete_foo implementation for reliability * Change lookup functions to return a list rather than yielding individual items * Extract common helper methods from schema tests, add tests for remaining poly endpoints, fix schema for cablepath.path * Add validate_polymorphic_property test method * Remove callable serializer support as it was moved upstream. --------- Co-authored-by: Bryan Culver <bryan.culver@networktocode.com>
Resolved for 2.0 by #3368. Please feel free to open new issues for any other specific gaps in the OpenAPI schema. |
Environment
Found a few mismatches between the defined schema and the returned data when generating bindings for go with openapi-generator-cli
Sample URL: /api/dcim/interfaces/XXX/
Required data: Untaagged vlans applied to interface
Sample Definition: VmInterface + Interface:
Field: tagged_vlans
Schema type: string[] of uuids
Actually returned: NestedVLAN[]
Sample URL: /api/dcim/interfaces/XXX/
Required data: Connection between two interfaces
Sample Definition: Anywhere cable_peer / connected_endpoint is used
Field: cable_peer + connected_endpoint
Schema type: nullable string
Actually returned: NestedInterface?
Sample URL: /api/dcim/devices/X/
Required data: Device with a status defined.
Sample Definition: Anywhere status enum is used in a read state, DeviceWithConfigContext/status for example
Field: $X/status
Schema type: enum string
Actually returned:
Sample URL: /api/ipam/ip-addresses/X/
Required Data: IP Address assigned to an interface
Sample Definition: (Writable)IPAddress
Field: assigned_object
Schema type: nullable string
Actually returned: NestedInterface?
Sample URL: /api/dcim/devices/X/
Required data: Device/VM with config context data.
Sample Definition: (Writable)DeviceWithConfigContext, (Writable)VirtualMachineWithConfigContext
Field: config_context
Schema type: map[string]string
Actually returned: map[string]interface{}
Sample URL: /api/dcim/cables/X/
Required data: Connection between two interfaces
Sample Definition: Cable
Field: termination_a+b
Schema type: nullable string
Actually returned: NestedInterface?
The text was updated successfully, but these errors were encountered: