Skip to content
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

Use of oneOf for schemas problematic for SDK #1533

Open
emigun opened this issue Nov 27, 2024 · 1 comment
Open

Use of oneOf for schemas problematic for SDK #1533

emigun opened this issue Nov 27, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@emigun
Copy link
Contributor

emigun commented Nov 27, 2024

Summary

Using oneOf in openAPI schema makes it impossible to create an instance of some classes in the SDK.

Steps to Reproduce

Using DatasetsControllerFindByIdAndUpdateRequest in the python SDK as an example:

from scicat_sdk_py.models.datasets_controller_find_by_id_and_update_request import DatasetsControllerFindByIdAndUpdateRequest

instance = DatasetsControllerFindByIdAndUpdateRequest.from_dict({"principalInvestigator": "Emil"})

Current Behaviour

This raises a ValueError.

Expected Behaviour

An instance should be created.

Details

The following error is raised:
ValueError: Multiple matches found when deserializing the JSON string into DatasetsControllerFindByIdAndUpdateRequest with oneOf schemas: PartialUpdateDerivedDatasetObsoleteDto, PartialUpdateRawDatasetObsoleteDto.

It is my understanding that oneOf should be used in cases where it strictly is one of the schemas. For us this doesn't work because there is overlap between the Dtos (actually they are almost identical).

In our case, anyOf is probably better?

oneOf is used for four endpoints in the datasets controller.

@emigun emigun added the bug Something isn't working label Nov 27, 2024
@Junjiequan Junjiequan self-assigned this Nov 27, 2024
@Junjiequan
Copy link
Contributor

We will investigate this issue asap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants