Mega
Mega

Reputation: 1334

How to create an Open API 3.0.1 Specification

I am new to swagger documentation etc Please, could you share any good resource or steps for creating an open api spec for the following endpoint, which is an endpoint of a spring boot microservice:

@PostMapping(path = "/pdf", produces = MediaType.APPLICATION_PDF_VALUE)
    public ResponseEntity<ByteArrayResource> createReport(@RequestParam MultipartFile template, @RequestParam MultipartFile templateDataAsJson) throws IOException {

        log.info("Triggering PDF Generation and Download");

        log.info("Step 1 Starts : Sending Json data to the template data binder microservice: Request:{}", templateDataAsJson);

        String completedHtmlJson = restClient.populateTemplate(template, templateDataAsJson);

        log.info("Steps 2 Starts: Sending populated html template to html-to-pdf microservice for rendering:{}", completedHtmlJson);

        ResponseEntity<ByteArrayResource> response = restClient.html2PdfGeneration(completedHtmlJson);

        return ResponseEntity.ok().contentType(APPLICATION_PDF).body(response.getBody());

    }

Any help or references will be appreciated. Thanks all.

Upvotes: 0

Views: 1015

Answers (1)

Varesh
Varesh

Reputation: 1758

You can look at SpringDoc https://github.com/springdoc/springdoc-openapi

It will generate the documentation on the fly for for you.

Upvotes: 2

Related Questions