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

GH-232 Allow reference to a model from OpenApiContentProperty #232

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

f1qwase
Copy link
Contributor

@f1qwase f1qwase commented Sep 30, 2024

Hi @dzikoysk,
I faced a need to send complex data along with files in a single request.
OpenAPI specification allows it: https://swagger.io/docs/specification/v3_0/describing-request-body/multipart-requests/

Currently javalin-openapi only allows description of primitive types properties in multipart/form content using fields type and format.
This PR introduces a from property to OpenApiPropertyContent annotation. The new from property is treated the same way as in OpenApiContent (it has higher priority than type and format and registers referenced type globally).

What do you think?

@dzikoysk dzikoysk changed the title Allow reference to a model from OpenApiContentProperty GH-232 Allow reference to a model from OpenApiContentProperty Sep 30, 2024
@dzikoysk
Copy link
Member

dzikoysk commented Sep 30, 2024

Yeah, makes sense - thanks for the PR! :) Could you quickly check if it doesn't infinitely loop when a class with self-reference is used? Like:

data class Loop(val self: Loop)

It might be a good idea to add it to the existing example (or tests), just in case 😅

@f1qwase
Copy link
Contributor Author

f1qwase commented Oct 1, 2024

Hi, I added a test for the Loop class.

This PR changes the @OpenApiContentProperty annotation but I used the @OpenApiContent annotation for the loop test since it's more common used and both are processed in the same way.
Please, let me know if you want to test the @OpenApiContentProperty as well.

@f1qwase
Copy link
Contributor Author

f1qwase commented Oct 7, 2024

Hi @dzikoysk,
I wanted to follow up on the status of this PR. Are there any updates or additional changes you'd like to make?

We're currently using javalin-openapi in production and would like to start using this feature.

Thank you.

@dzikoysk dzikoysk merged commit 350ff9b into javalin:main Oct 7, 2024
2 checks passed
@dzikoysk
Copy link
Member

dzikoysk commented Oct 7, 2024

Thanks for reminder, I just missed the notification. Looks good, thank you! It should be available as snapshot within a few minutes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants