Change np.ndarray types to list type to fix model serialization to fix OpenAPISpec and SwaggerUI (2) #986
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix
What is the current behavior? (You can also link to an open issue here)
In Marqo 2.x, OpenAPI spec generation is not functional. Attempting to access
/openapi.json
or/docs
results in errors, making it impossible to retrieve the API specifications and documentation. This issue is documented in Issue #778.What is the new behavior (if this is a feature change)?
This PR restores OpenAPI spec generation and resolves the issues with the
/openapi.json
and/docs
endpoints. The root cause was identified insrc/marqo/tensor_search/models/add_docs_objects.py
, where the documents field included a union type that couldn't be serialized due to the presence of np.ndarray.By replacing np.ndarray with the standard Python list type in the union, the serialization issue is resolved, allowing OpenAPI specs and Swagger UI to function as expected.
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No, this PR does not introduce any breaking changes. Existing functionalities remain unaffected, and users do not need to make any changes to their applications.
Have unit tests been run against this PR? (Has there also been any additional testing?)
No, unit tests haven't been executed. I locally confirmed that the OpenAPI specification and Swagger UI are now accessible and operational.
Related Python client changes (link commit/PR here)
No related changes in the Python client.
Related documentation changes (link commit/PR here)
No changes needed as the fix restores a functionality already documented.
Other information:
The issue was addressed by considering three potential solutions:
The third option was chosen for its simplicity and effectiveness.