Institute of Computer Science
  1. Courses
  2. 2024/25 spring
  3. Enterprise Systems Integration (MTAT.03.229)
ET
Log in

Enterprise Systems Integration 2024/25 spring

  • Home
  • Lectures
  • Practicals
  • Assignements
  • Project and exam
  • Message Board

OpenAPI-Swagger

The OpenAPI Specification, previously known as the Swagger Specification, defines a standard, language-agnostic interface to HTTP APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.

To add OpenAPI-Swagger to your project, you just need to add the following Maven (springdoc-openapi) Dependency

// pom.xml    
..
         <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
            <version>2.0.2</version>
         </dependency>  
..

After running your project, you can access the created API documentation using the following link

http://localhost:8080/swagger-ui/4.15.5/index.html

If you want to add more specialized information to the API documentation, you can use the following Bean and modify the OpenAPI information to fit the description of your project.

@SpringBootApplication
public class Week4Application {
    public static void main(String[] args) {
        SpringApplication.run(Week4Application.class, args);
    }
@Bean
    public OpenAPI springShopOpenAPI() {
        return new OpenAPI()
                .info(new Info().title("Products - Orders API")
                .description("Products - Orders API")
                .version("v0.0.1")
                .license(new License().name("Apache 2.0").url("http://springdoc.org")))
                .externalDocs(new ExternalDocumentation()
                .description("Products - Orders Documentation")
                .url("http://localhost:8080/swagger-ui/4.15.5/index.html"));
    }
}
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment