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

Document one REST endpoint with springdoc #82

Open
2 of 4 tasks
blcham opened this issue Apr 17, 2024 · 5 comments · May be fixed by #150
Open
2 of 4 tasks

Document one REST endpoint with springdoc #82

blcham opened this issue Apr 17, 2024 · 5 comments · May be fixed by #150
Assignees

Comments

@blcham
Copy link
Contributor

blcham commented Apr 17, 2024

The goal of the task is to agree on how to document REST endpoints. Inspiration can be taken from https://github.com/kbss-cvut/termit.

A/C:

  • one endpoint is chosen, and it is annotated
  • the documentation of REST API is accessible from the application and docker-compose services and how to access it is described in README
  • the documentation of the endpoint is discussed and approved here
  • it is possible to run those services from the springdoc documentation [1]
@blcham blcham changed the title Document REST API with springdoc Document one REST endpoint with springdoc Apr 17, 2024
@blcham blcham assigned blcham and plexisklo and unassigned blcham Apr 17, 2024
@blcham blcham assigned palagdan and unassigned plexisklo Aug 21, 2024
@palagdan
Copy link
Collaborator

palagdan commented Aug 21, 2024

@blcham
For documentation, we can use Springdoc annotations such as @operation and @ApiResponses. For example, let's take a look at ComponentController:

 @Operation(summary = "Create a new component")
    @ApiResponses(value = {
        @ApiResponse(responseCode = "201", description = "Component created successfully"),
        @ApiResponse(responseCode = "400", description = "Invalid input")
    })
    @ResponseStatus(HttpStatus.CREATED)
    @PostMapping(consumes = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
    public Component create(@RequestBody Component component) {
        log.info("> create - {}", component);
        repositoryService.persist(component);
        return component;
    }

  @Operation(summary = "Retrieve all components")
    @ApiResponses(value = {
        @ApiResponse(responseCode = "200", description = "Successfully retrieved all components")
    })
    @GetMapping(produces = {JsonLd.MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE})
    public List<Component> findAll() {
        return repositoryService.findAll();
    }

palagdan added a commit that referenced this issue Aug 22, 2024
@palagdan palagdan linked a pull request Aug 22, 2024 that will close this issue
@blcham
Copy link
Contributor Author

blcham commented Aug 31, 2024

@palagdan i updated A/C

for [1] u might need something like
@Operation(security = {@SecurityRequirement(name = "bearer-key")

@palagdan
Copy link
Collaborator

palagdan commented Sep 6, 2024

Could you explain the last A/C to me?
It is possible to run those services from the Springdoc documentation [1]
Which services are being referred to?

@blcham
Copy link
Contributor Author

blcham commented Sep 8, 2024

I would like to have the web form generated by springdoc ready as much as possible to to execute any of any concrete REST API endpoint.

I assume it is possible to execute annotated REST API endpoints from there -- am i right?

@palagdan
Copy link
Collaborator

Yes, you are right!

blcham pushed a commit that referenced this issue Sep 12, 2024
kostobog added a commit that referenced this issue Sep 12, 2024
- Generate entity type specific bad request response messages - response message is a concatenation of entity type name and validation erro default message.
blcham pushed a commit that referenced this issue Sep 13, 2024
blcham pushed a commit that referenced this issue Sep 13, 2024
- Generate entity type specific bad request response messages - response message is a concatenation of entity type name and validation erro default message.
palagdan added a commit that referenced this issue Oct 14, 2024
palagdan added a commit that referenced this issue Oct 14, 2024
palagdan added a commit that referenced this issue Oct 14, 2024
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 a pull request may close this issue.

3 participants