Swagger 2 spring download yml file

I am new to charts, contracts and working on the Spring boot (gradle) project, where we are just starting to work with contracts. I used grails, I love how you can put a defs field in a Domain, and it is inherited through the stack.

A specific question, and maybe a question with pigment support.

How can I create the main stub of a YAML file from a standard controller class?

I understand that I have to create the [Name] -v1-0.yml file in the controller\src\test\resources directory

I implemented swagger-ui.html in a project, and actually a cool interactive web page appears showing the endpoints and things of the request. Using the class SwaggerConfig extends WebMvcConfigurerAdapter , which works to publish interfaces to the ui json doc web page.

I believe that the understanding is that the yml file in the testing resources directory will be a fixed generation of โ€œcontractsโ€ and is used in some gradle testing method to make sure that the API signature and contract points have not changed, like a basic unit style test of the interface . (Well no?)

I am lazy, thinking to myself: why am I handing this stupid file? Can yaml doc skeleton be generated for me quite easily from controller / model details?

For example, the page has a YML file and makes a friendly ui page: http://editor.swagger.io/#/

There is a really good "uber" sample YAML file on this page, I really need to write this, I already wrote the Controller, javadoc, annotated, all kinds of cool things that should be able to generate at least quite (I accuse you of not want to hack it!), which, first of all, added SpringFox annotations, which did cooler things and really went to the city to trust this check of the contract more.

FYI: 'spring-boot-starter-web' 'spring-boot-starter-test' 'springfox-swagger-ui', version: '2.4.0'

+6
source share
2 answers

I understood. Itโ€™s very simple why I havenโ€™t seen this anywhere. :)

Copy / paste the path to the resource in the browser:

http://localhost:8095/v2/api-docs?group=full-api

Select the generated content and copy it to the clipboard.

Open the Swagger editor in a browser:

http://editor.swagger.io

Choose Insert JSON ... from the File menu.

Paste the generated JAON Swagger content and click Import.

+6
source

There is a function request for providing a specification submission: https://github.com/springfox/springfox/issues/651

Apart from progress, it is not yet available.

+2
source

All Articles