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

Using AnyOf makes the OpenAPI generator server fail #148

Open
dgarijo opened this issue Oct 29, 2020 · 6 comments
Open

Using AnyOf makes the OpenAPI generator server fail #148

dgarijo opened this issue Oct 29, 2020 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@dgarijo
Copy link
Contributor

dgarijo commented Oct 29, 2020

It looks like while AnyOf is supported by OpenAPI spec, it does not work well in the OpenAPI generator server we are using.

Solution:

  • Warn users of the types that are not going to be supported.
  • Create manually the missing union classes for the spec (but for data types it's difficult to know).
  • Use another server implementation where this works (e.g., Java). But this means we have to port all our code from Python to Java, which is not trivial.

Better solution: Open an issue in OpenAPI generator and wait until they fix it.

@dgarijo dgarijo added the bug Something isn't working label Oct 29, 2020
@DougalW
Copy link

DougalW commented Oct 29, 2020

Interesting behaviour here. It works for the Restrictions example, but when I use my more complex ontology, it fails to generate AnyOf in the yaml. If I manually edit the openapi.yaml file to add the AnyOf, it builds and runs the server fine.

@dgarijo
Copy link
Contributor Author

dgarijo commented Oct 29, 2020

Note that the issue here is not because there is no anyOf in the YAML spec, (for the example I tried it worked fine for me). The issue is that the OpenAPI generator will not produce the class for the anyOf union, and the server will fail. This is due to OpenAPI generator, but we should offer a solution.

If you face a problem with anyOf not being generated as part of the spec, please open an issue, as we will need to fix it.

@dgarijo
Copy link
Contributor Author

dgarijo commented Oct 29, 2020

TO DO : Test if this behavior occurs with OneOf

@dgarijo
Copy link
Contributor Author

dgarijo commented Oct 30, 2020

Workaround solution discussed with @hvarg:

until OpenAPI generator is fixed, we will create a placeholder python class for representing unions (and possibly intersections) of classes. This way the API will work successfully (for these items only a type, label an id are returned, so it will be fine).

@DougalW
Copy link

DougalW commented Nov 5, 2020

I'll try and create a reproducer for this bug. It seems to work sometimes and not other times. Works with the Restrictions example, but not my ontology. At present I manually modify the config.yaml file to add back in the anyOf.

@dgarijo
Copy link
Contributor Author

dgarijo commented Nov 5, 2020 via email

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

No branches or pull requests

3 participants