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

RESTWS-958: Upgrade swagger to 2.2.23 #631

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

mherman22
Copy link
Member

@mherman22 mherman22 commented Oct 14, 2024

Description of what I changed

Issue I worked on

see https://issues.openmrs.org/browse/RESTWS-958

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@mherman22 mherman22 force-pushed the RESTWS-958 branch 2 times, most recently from e47142d to 672ccc1 Compare October 15, 2024 19:02
@mherman22 mherman22 marked this pull request as ready for review October 17, 2024 20:50
@mherman22 mherman22 requested a review from ibacher October 17, 2024 20:52
@@ -19,6 +19,28 @@
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-common</artifactId>
<version>${project.parent.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
Copy link
Member Author

@mherman22 mherman22 Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hacky but i needed to add these exclusions because the jackson related dependencies coming from swagger-core 2.2.23 are quite high and causing conflicts with the related jackson stuff from spring

<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -21,6 +21,28 @@
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-common</artifactId>
<version>${project.parent.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -23,6 +23,28 @@
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-common</artifactId>
<version>${project.parent.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@ibacher
Copy link
Member

ibacher commented Oct 18, 2024

@mherman22 Rather than doing the exclusions in every POM, can we add the exclusion to the omod-common declaration of Swagger? That should remove it from everywhere...

@mherman22
Copy link
Member Author

mherman22 commented Oct 18, 2024

@mherman22 Rather than doing the exclusions in every POM, can we add the exclusion to the omod-common declaration of Swagger? That should remove it from everywhere...

@ibacher i tried that before this approach however this bean here ->

causes a org.springframework.beans.factory.BeanDefinitionStoreException with something as

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jsonHttpMessageConverter' defined in class path resource [org/openmrs/module/webservices/rest/web/DynamicBeanConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.http.converter.HttpMessageConverter org.openmrs.module.webservices.rest.web.DynamicBeanConfiguration.getMappingJacksonHttpMessageConverter() throws java.lang.Exception] threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException

for more context -> https://paste.ubuntu.com/p/tJ6mZxnKJJ/

@ibacher
Copy link
Member

ibacher commented Oct 18, 2024

I see what you mean... Have you tried running this version in an SDK instance?

@mherman22
Copy link
Member Author

I see what you mean... Have you tried running this version in an SDK instance?

Version you mean the omod built with the changes of this PR?

If so, then no. I have an instance I setup using docker but then openmrs is failing on startup for example the queue module's 1xlegacyController class is the cause and its because i think I need to now go into each of those modules and update them to take up stuff in this PR.

However I can not do before we have this in.

Or is there a way I can actually test this on modules without having to first get this in?

@ibacher
Copy link
Member

ibacher commented Oct 18, 2024

Technically, if you run mvn clean install and then update the module to depend on the SNAPSHOT version, you can test this all locally.

@ibacher
Copy link
Member

ibacher commented Oct 18, 2024

install adds it to your local Maven repo copy and, at least until the next PR gets merged, that should be newer than the SNAPSHOT we've published (and you can always re-do the install if that happens), so Maven will pick-up your local copy as the "latest" SNAPSHOT.

@mherman22
Copy link
Member Author

install adds it to your local Maven repo copy and, at least until the next PR gets merged, that should be newer than the SNAPSHOT we've published (and you can always re-do the install if that happens), so Maven will pick-up your local copy as the "latest" SNAPSHOT.

Interesting, thanks. If I can test this locally then that's great. I will update the PR as and when I have tested thoroughly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pulled this out of RestConstants because for soe reason, initialization of RestConstants was failing.


openAPI = new OpenAPI();
BuildJSON();
cachedJson = createJSON(); // Cache the JSON string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Spec was being reset when accessing cached data, causing
empty paths in the API documentation on subsequent requests. This occurred
because initOpenAPI() was creating a new empty Paths object while handling
cached responses.

@mherman22
Copy link
Member Author

Screenshot 2024-10-29 at 14-49-24 OpenMRS
these are the current visuals. I am lookng into the failing test

@mherman22 mherman22 requested a review from dkayiwa October 30, 2024 07:33
@@ -31,9 +31,9 @@
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<groupId>io.swagger.core.v3</groupId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick thing: since the versions are already defined in the root POM (in dependency management), they don't need to be specified here. That way we only need to update versions in a single place (dependency management doesn't make something a dependency, but it's configuration applies to a dependency with the same coordinates.

For the same reasons, we shouldn't need to replicate the exclusions here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@mherman22 mherman22 requested a review from ibacher November 18, 2024 07:19
@dkayiwa
Copy link
Member

dkayiwa commented Nov 21, 2024

@mherman22 as we discussed on this week's platform call, did you get some time to check if swagger has an option that saves us from the burden of having to manually maintain resource documentation?

@mherman22
Copy link
Member Author

@mherman22 as we discussed on this week's platform call, did you get some time to check if swagger has an option that saves us from the burden of having to manually maintain resource documentation?

@dkayiwa I am still looking into that. But so far what i have landed on from the various docs that i have read indicate OpenAPI 3.0 itself may not provide a mechanism to automatically generate schema definitions from code. But i am looking into Springdoc trying to see if it works for us but it looks to be more of a springboot project.

Others that i have looked at are poorly maintained and it's been long (4 years) since the last commit.

I will take any suggestions before i read all books on the internet 😃

@mherman22
Copy link
Member Author

add springfox to that list.

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

Successfully merging this pull request may close these issues.

3 participants