Open jlsherrill opened 3 months ago
the following patch to the pulp api spec seems to help, but it may not be a full fix:
--- pulp_api.json 2024-07-23 09:25:12.179493116 -0400
+++ patched_pulp.json 2024-07-23 09:59:30.669329005 -0400
@@ -58586,61 +58586,130 @@
"description": "URL with more information about the packaged software"
},
"changelogs": {
- "type": "object",
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
"readOnly": true,
"default": "[]",
"description": "Changelogs that package contains"
},
"files": {
- "type": "object",
- "readOnly": true,
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "readOnly": true,
"default": "[]",
"description": "Files that package contains"
},
"requires": {
- "type": "object",
- "readOnly": true,
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "readOnly": true,
"default": "[]",
"description": "Capabilities the package requires"
},
"provides": {
- "type": "object",
- "readOnly": true,
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "oneOf": [
+ {"type": "string"},
+ {"type": "bool"}
+ ]
+ }
+ },
+ "readOnly": true,
"default": "[]",
"description": "Capabilities the package provides"
},
"conflicts": {
- "type": "object",
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "oneOf": [
+ {"type": "string"},
+ {"type": "bool"}
+ ]
+ }
+ },
"readOnly": true,
"default": "[]",
"description": "Capabilities the package conflicts"
},
"obsoletes": {
- "type": "object",
- "readOnly": true,
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "oneOf": [
+ {"type": "string"},
+ {"type": "bool"}
+ ]
+ }
+ },
+ "readOnly": true,
"default": "[]",
"description": "Capabilities the package obsoletes"
},
"suggests": {
- "type": "object",
- "readOnly": true,
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "readOnly": true,
"default": "[]",
"description": "Capabilities the package suggests"
},
"enhances": {
- "type": "object",
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
"readOnly": true,
"default": "[]",
"description": "Capabilities the package enhances"
},
"recommends": {
- "type": "object",
- "readOnly": true,
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "readOnly": true,
"default": "[]",
"description": "Capabilities the package recommends"
},
"supplements": {
- "type": "object",
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
"readOnly": true,
"default": "[]",
"description": "Capabilities the package supplements"
@@ -60266,4 +60335,4 @@
"url": "http://localhost:8080/"
}
]
-}
\ No newline at end of file
+}
oh and I realized we can use 'fields' to workaround this, so its not high priority for us right now
If I understand correctly this was not a regression, you are just trying this out for the first time, right?
This may be related to https://github.com/pulp/pulp_rpm/issues/3657 ?
Yes, I believe so. The ideal solution would be to fix this in the serializer level, but the problem with that (as pointed here) is that it would affect all the interfaces (API and other client bindings), and that could break some users pipeline if their code rely on this innacurate type representation.
I think that if we can show this doesnt work with other binding clients it would be safer to update.
A second approach is monkey-patching the types in the api-spec, as you've shown.
If we go this path maybe we can add some "Known Issues" doc notes on pulp-openapi-generator
for people who want to generate Go bindings.
oh and I realized we can use 'fields' to workaround this, so its not high priority for us right now
Can you elaborate? What fields
exactly?
@pedro-psb yes, trying for the first time. I'm not sure it ever worked.
Can you elaborate? What fields exactly?
The list packages api: https://pulpproject.org/pulp_rpm/restapi/#tag/Content:-Packages/operation/content_rpm_packages_list
provides a fields and exclude_fields option that excludes some fields from being returned in the api. If I use the 'fields' parameter and only include a few fields i care about (name, version, release, arch), it works perfectly fine, since the problematic fields are excluded.
Discussion in the RPM meeting: it's not necessarily a breaking change for Python and Ruby bindings because of their dynamically typed nature, maybe we can change the schema and fix the Go bindings without breaking usages of Ruby and Python bindings.
We can make the change and compare generated bindings code before and after, maybe it is fine?
Worst case we can release it alongside a breaking release.
Version
Describe the bug When we produce Go bindings for the pulp api spec, and try to fetch rpms from the ContentRpmPackagesList api, we get an error:
Playing around with this with Go, it appears that its related to the fact that changelogs, files etc.. are declared as an 'Object', but in fact are an array of an array of strings
To Reproduce Steps to reproduce the behavior:
Expected behavior I would expect the api spec to reflect the data returned.
Additional context This may be related to https://github.com/pulp/pulp_rpm/issues/3657 ?
these fields in the schema:
example json fetched from the api: