Arvutiteaduse instituut
  1. Kursused
  2. 2024/25 kevad
  3. Ettevõttesüsteemide integreerimine (MTAT.03.229)
EN
Logi sisse

Ettevõttesüsteemide integreerimine 2024/25 kevad

  • 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"));
    }
}
  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused