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

Make ModelConverterContext swappable #4718

Open
nikita2206 opened this issue Aug 14, 2024 · 0 comments
Open

Make ModelConverterContext swappable #4718

nikita2206 opened this issue Aug 14, 2024 · 0 comments

Comments

@nikita2206
Copy link

nikita2206 commented Aug 14, 2024

Currently, the ModelConverterContext is instantiated statically from within the ModelConverters class. The context happens to contain some logic that seems to be hard (or impossible) to modify in any other way, other than by extending the ModelConverterContextImpl and overriding the resolve() method.

Problem

Namely, we would like to add clever handling of Optional<...> properties of objects, such that the OAS component that contains such property would specify nullable = true for it. However, because the ModelConverterContextImpl has the following line, we lose the information about Optional wrapper very early on, which makes it impossible for us to use the existing ModelConverter extension points to implement this:

AnnotatedType aType = ReferenceTypeUtils.unwrapReference(type);

Solution

If you don't see any immediate issues with this, I'd like to create a PR adding a ModelConverterContextFactory factory which will be settable on a ModelConverters singleton object, like the following:

ModelConverters.getInstance()
  .setContextFactory(converters -> new CustomContext(converters));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant