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

Adding Swagger doc on teams endpoints #2256

Open
wants to merge 3 commits into
base: improvment/add-swagger-doc
Choose a base branch
from

Conversation

Dimfacion
Copy link
Member

@Dimfacion Dimfacion commented Jan 20, 2025

Proposed changes

  • Adding Swagger doc on teams endpoints

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality
  • For bug fix -> I implemented a test that covers the bug

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 31 lines in your changes missing coverage. Please review.

Project coverage is 32.77%. Comparing base (c61ba68) to head (a1a2bb2).

Files with missing lines Patch % Lines
...bas/rest/helper/UserRoleDescriptionCustomizer.java 0.00% 31 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                        @@
##             improvment/add-swagger-doc    #2256      +/-   ##
================================================================
- Coverage                         32.87%   32.77%   -0.10%     
+ Complexity                         1509     1500       -9     
================================================================
  Files                               582      580       -2     
  Lines                             17930    17938       +8     
  Branches                           1158     1169      +11     
================================================================
- Hits                               5894     5880      -14     
- Misses                            11772    11794      +22     
  Partials                            264      264              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

if (preAuthorizeAnnotation != null) {
specialRequirement += "<br>**Special Requirement :** ";
String preAuthorize = preAuthorizeAnnotation.value();
if (preAuthorize.startsWith("isExercisePlanner")
Copy link
Member

Choose a reason for hiding this comment

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

For all the tests, isn't startsWith a bit risky, instead of equals ? (especially for the tests on isPlanner, isObserver, etc.)

Copy link
Member

Choose a reason for hiding this comment

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

Also, code could probably be factorized a bit using regex ? With a Pattern like Pattern.compile("is(.?)Planner") ?
If group 0 is empty, give the isPlanner message, else if group 0 = Scenario give the scenarioPlanner message, else give the simulationPlanner message ?
But not sure if it's worth doing or not

@@ -165,13 +192,19 @@ public Team upsertTeam(@Valid @RequestBody TeamCreateInput input) {

@DeleteMapping("/api/teams/{teamId}")
@PreAuthorize("isPlanner()")
public void deleteTeam(@PathVariable String teamId) {
@ApiResponses(value = {@ApiResponse(responseCode = "200")})
Copy link
Member

Choose a reason for hiding this comment

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

204 instead of 200 ?

teamRepository.deleteById(teamId);
}

@PutMapping("/api/teams/{teamId}")
@PreAuthorize("isPlanner()")
public Team updateTeam(@PathVariable String teamId, @Valid @RequestBody TeamUpdateInput input) {
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The updated team")})
Copy link
Member

Choose a reason for hiding this comment

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

Didn't think about it before this one, but shouldn't we also describe errors ? (like updating a team taht deosn't exist ?)

private String organizationId;

@JsonProperty("team_tags")
@Schema(description = "Id of the tags linked to the team")
private List<String> tagIds = new ArrayList<>();

@JsonProperty("team_exercises")
Copy link
Member

Choose a reason for hiding this comment

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

Should we use this opportunity to rename it to team_simulation ?

public class TeamUpdateInput {

@NotBlank(message = MANDATORY_MESSAGE)
@JsonProperty("team_name")
@Schema(description = "Name of the team")
Copy link
Member

Choose a reason for hiding this comment

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

We should probably create a super class here to mutualize code between the various team input types


@JsonProperty("team_exercises")
private Set<String> exercises = new HashSet<>();
@Schema(description = "List of exercises of the team")
Copy link
Member

Choose a reason for hiding this comment

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

List of simulation IDs


@JsonProperty("team_scenarios")
private Set<String> scenarios = new HashSet<>();
@Schema(description = "List of scenarios of the team")
Copy link
Member

Choose a reason for hiding this comment

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

List of scenario IDs

public long getUsersNumber() {
return this.users.size();
}

// region transient
@JsonProperty("team_exercise_injects")
private Set<String> exercisesInjects = new HashSet<>();
@Schema(description = "List of injects from all simulations of the team")
Copy link
Member

Choose a reason for hiding this comment

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

List of inject IDs

public long getExercisesInjectsNumber() {
return this.exercisesInjects.size();
}

@JsonProperty("team_scenario_injects")
@Schema(description = "List of injects from all scenarios of the team")
Copy link
Member

Choose a reason for hiding this comment

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

List of inject IDs

public long getScenariosInjectsNumber() {
return this.scenariosInjects.size();
}

@JsonIgnore private List<InjectExpectation> injectExpectations = new ArrayList<>();

@JsonProperty("team_inject_expectations")
@Schema(description = "List of expectations id linked to this team")
Copy link
Member

Choose a reason for hiding this comment

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

expectations id -> expectation ids

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