3

I have this REST service:

@RestController
public class ContaCorrenteController {

    @Autowired
    private configCorrenteService service;

    @Produces(MediaType.APPLICATION_JSON)
    @RequestMapping("/v1/number/{number}/config/{config}/final/{data}")
    @GET
    public ResponseEntity<Final> Final(
            @PathVariable("number") Integer number, 
            @PathVariable("config") Integer config, 
            @PathVariable("data") @DateTimeFormat(pattern="yyyyMMdd") LocalDate data) {
        Final final = service.consultFinal(number, config, data);
        return ResponseEntity.ok(final);
    }

    @Produces(MediaType.APPLICATION_JSON)
    @RequestMapping("/v1/number/{number}/config/{config}/final")
    @GET
    public ResponseEntity<Final> final(
            @PathVariable("number") Integer number, 
            @PathVariable("config") Integer config) {
        Final final = service.consultFinalNow(number, config);
        return ResponseEntity.ok(final);
    }
}

I need to automatically genarete a REST documentation using this java file. Can I automatically generate a json or yaml to import on Swagger editor or another way to documentation?

2

1 Answer 1

4

You can integrate with SpringFox:

https://github.com/springfox/springfox

Which can automatically generate swagger definitions from your Spring-MVC server. You'll need to add some annotations to effectively document things but it should be quite straight forward.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, thank you for your answer... Could you explain what is the difference between Swagger-Core and Springfox? May I use only Swagger-Core to automatic generating the Swagger documentation? Thank you a lot.
Springfox is a community-driven project to add swagger support to spring-mvc. Swagger core is focused on pure servlets and JAX-RS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.