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

refactor(model-server): prevent duplicate problem types #877

Conversation

languitar
Copy link
Contributor

@languitar languitar commented Jul 4, 2024

This PR makes the model-server-openapi folder a module again, which
is now responsible for merging the individual OpenAPI specification
files into a single one that's then used inside the build and for the
SwaggerUI of the model-server. This has several benefits:

  • The SwaggerUI configuration and usage is easier as we present a
    single, combined API with a good overview under a single URL.
  • The duplicated generated of shared models such as the Problem type is
    prevented as the merging deduplicates the data type.

Implementing merging is implemented with redocly, which was the only
tool I could find for this tasks that worked. The model-server-openapi
contains a decorator plugin for redocly that, as part of the merge
process, prepends the server URL paths to routes so that URLs are
correct in the merged result specification.

The different specifications we maintain had a few duplicated response
names that caused issues when merging. These duplications were resolved
by renaming some instances of them.

To properly categorize the different APIs in the SwaggerUI for the user,
tags were added everywhere in the specifications.

I could also get rid of several required imports by generating the
source code into the same package that's also used for the API
implementation.

To be verified by reviewers

  • Relevant public API members have been documented
  • Documentation related to this PR is complete
    • Boundary conditions are documented
    • Exceptions are documented
    • Nullability is documented if used
  • Touched existing code has been extended with documentation if missing
  • Code is readable
  • New features and fixed bugs are covered by tests

Copy link
Contributor

github-actions bot commented Jul 4, 2024

Test Results

160 files  ±0  160 suites  ±0   10m 58s ⏱️ +16s
915 tests ±0  906 ✅ ±0  9 💤 ±0  0 ❌ ±0 
925 runs  ±0  916 ✅ ±0  9 💤 ±0  0 ❌ ±0 

Results for commit 1381ae2. ± Comparison against base commit 2c381d7.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Jul 4, 2024

JVM coverage report

Overall Project 53.28% -0.01%
Files changed 52.94%

File Coverage
AboutApiImpl.kt 100% 🍏
HttpException.kt 94.19% 🍏
ModelReplicationServer.kt 90.69% 🍏
KeyValueLikeModelServer.kt 86.26% 🍏
HealthApiImpl.kt 73.42% 🍏
IdsApiImpl.kt 71.54% 🍏
Main.kt 21.32% -1.88%
MetricsApiImpl.kt 0% 🍏

@languitar languitar force-pushed the feature/MODELIX-948-Prevent-duplication-of-the-Problem-type-in-spec-and-code branch 2 times, most recently from e8c952a to 136c046 Compare July 4, 2024 18:47
Use a file $ref instead of duplicating the type to prevent potentially
diverging definitions.

This does not yet prevent the duplication of generated code.
@languitar languitar force-pushed the feature/MODELIX-948-Prevent-duplication-of-the-Problem-type-in-spec-and-code branch 2 times, most recently from 3afedc5 to be00722 Compare July 30, 2024 11:58
@languitar languitar marked this pull request as ready for review July 30, 2024 12:01
@languitar languitar requested review from slisson and a team as code owners July 30, 2024 12:01
build.gradle.kts Show resolved Hide resolved
model-server/build.gradle.kts Outdated Show resolved Hide resolved
model-server/build.gradle.kts Outdated Show resolved Hide resolved
This commit makes the model-server-openapi folder a module again, which
is now responsible for merging the individual OpenAPI specification
files into a single one that's then used inside the build and for the
SwaggerUI of the model-server. This has several benefits:

* The SwaggerUI configuration and usage is easier as we present a
  single, combined API with a good overview under a single URL.
* The duplicated generated of shared models such as the Problem type is
  prevented as the merging deduplicates the data type.

Implementing merging is implemented with redocly, which was the only
tool I could find for this tasks that worked. The model-server-openapi
contains a decorator plugin for redocly that, as part of the merge
process, prepends the server URL paths to routes so that URLs are
correct in the merged result specification.

The different specifications we maintain had a few duplicated response
names that caused issues when merging. These duplications were resolved
by renaming some instances of them.

To properly categorize the different APIs in the SwaggerUI for the user,
tags were added everywhere in the specifications.

I could also get rid of several required imports by generating the
source code into the same package that's also used for the API
implementation.
@languitar languitar force-pushed the feature/MODELIX-948-Prevent-duplication-of-the-Problem-type-in-spec-and-code branch from 2b10c51 to 6a32f39 Compare July 30, 2024 13:28
@languitar languitar requested a review from odzhychko July 30, 2024 13:29
odzhychko
odzhychko previously approved these changes Jul 30, 2024
@languitar languitar enabled auto-merge July 30, 2024 13:31
Removes dependencies that are not explicitly required. The original
reason for the additional dependencies was making ktlint tasks happy.
But they have been dropped from the build.
@languitar languitar force-pushed the feature/MODELIX-948-Prevent-duplication-of-the-Problem-type-in-spec-and-code branch from 6a32f39 to 1381ae2 Compare July 30, 2024 14:04
@languitar languitar requested a review from odzhychko July 30, 2024 14:05
@languitar languitar merged commit 8c80ee5 into main Jul 30, 2024
19 checks passed
@languitar languitar deleted the feature/MODELIX-948-Prevent-duplication-of-the-Problem-type-in-spec-and-code branch July 30, 2024 14:39
@slisson
Copy link
Member

slisson commented Aug 6, 2024

🎉 This PR is included in version 8.16.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants