22

What is swagger-ui and what is the use of it?

I have visited http://swagger.io/, but I need more information.

Please guide me.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Saravanan Rajaraman
  • 1,029
  • 2
  • 12
  • 25

2 Answers2

18

Swagger UI is a tool that takes Swagger specification files, presents them visually and allows you to execute operations.

Swagger itself is a specification to document and describe REST APIs. The specification can be found here - https://github.com/swagger-api/swagger-spec/. The repository contains the specification itself, json schema, samples and so on. The main README of the repository also points you to additional tools including libraries and frameworks to produce your specifications.

When it comes to creating Swagger specification, you can use one of the frameworks and integrate it with existing code to auto-generate such documentation.

If you don't have an existing application or would rather document it manually, you can use the Swagger-Editor tool or the text editor of your choice.

Ron
  • 14,160
  • 3
  • 52
  • 39
  • I have an existing Swagger API running. Now, what is necessary for Swagger UI to being able to show my API documentation? Just opening `./dist/index.html` and navigating to my swagger api doesn't quite cut it. Do I have to serve the `swagger.json` manually via http? Does my API need an extra endpoint where it just serves the .json file? Thanks for clarifying. – atripes Aug 18 '15 at 09:40
  • 4
    The question is unclear and lacking details. I'd suggest either starting a new question with full details here or use our google group which is monitored more closely. – Ron Aug 18 '15 at 09:46
  • I'm also confused. How to use swagger UI together with the api developed by Swagger editor? – Bagusflyer Oct 29 '15 at 08:50
1

maven dependency:

    <dependency>
         <groupId>io.springfox</groupId>
         <artifactId>springfox-swagger2</artifactId>
         <version>2.4.0</version>
    </dependency>  
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.4.0</version>
    </dependency>

============================================================================

@Configuration
@EnableSwagger2   
    public class SwaggerConfig {

        private static final String SEARCH = "spring-rest-swagger";

        @Bean
        public Docket myApp() {
            return new Docket(DocumentationType.SWAGGER_2).groupName(SEARCH)
                    .apiInfo(apiInfo()).tags(new Tag(SEARCH, "spring-rest-swagger API"));
        }

        private ApiInfo apiInfo() {
            return new ApiInfoBuilder().title(SEARCH).build();
        }
    }

==============================================================================

for reference use below link:(step by step explanation)

https://www.youtube.com/watch?v=xeYpiHLpme0&t=1s