Skip to content

Conversation

@mherman22
Copy link
Member

@mherman22 mherman22 commented Nov 29, 2024

Description of what I changed

Issue I worked on

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

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 changed the title RESTWS-963Refactor the mechanism for making Swagger aware of resource handlers and adopt a more automated approach RESTWS-963: Refactor the mechanism for making Swagger aware of resource handlers for documentation Nov 29, 2024
@mherman22 mherman22 changed the title RESTWS-963: Refactor the mechanism for making Swagger aware of resource handlers for documentation RESTWS-963: Remove the manual methods used for generating the swagger documentation Dec 2, 2024
@mherman22 mherman22 requested a review from dkayiwa December 5, 2024 17:54
public Model getGETModel(Representation rep) {
getGETCalled = true;
return super.getGETModel(rep);
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
Copy link
Member

Choose a reason for hiding this comment

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

Did you intentionally change these methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes i did, because we are getting rid of those methods so i had to replace them with methods used for creating the rest api

Comment on lines 112 to 116
description.addProperty("drug");
return description;
}

public Model getGETModel(Representation rep) {
ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
if (rep instanceof DefaultRepresentation) {
modelImpl.property("display", new StringProperty()).property("uuid", new StringProperty())
.property("drug", new RefProperty("#/definitions/DrugGetRef"))
.property("conceptReferenceTerm", new RefProperty("#/definitions/ConceptreferencetermGetRef"))
.property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeGetRef"));
} else if (rep instanceof FullRepresentation) {
modelImpl.property("display", new StringProperty()).property("uuid", new StringProperty())
.property("auditInfo", new StringProperty()).property("drug", new RefProperty("#/definitions/DrugGet"))
.property("conceptReferenceTerm", new RefProperty("#/definitions/ConceptreferencetermGet"))
.property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeGet"));
}
return modelImpl;
}

@Override
public Model getCREATEModel(Representation rep) {
return new ModelImpl().property("conceptReferenceTerm", new StringProperty().example("uuid"))
.property("conceptMapType", new StringProperty().example("uuid"))
.property("drug", new StringProperty().example("uuid"));
}

}

Choose a reason for hiding this comment

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

good improvements:
Well-structured with correct use of Swagger models.
Logical separation for different representations.
Needs Improvement:
Remove redundant code using a helper method.
Improve method naming for clarity.
Add error handling for edge cases.

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