2

I have a simple question: I'm just getting started with Open API 3. For this purpose I have added the following dependency in Maven.

  <dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-ui</artifactId>
        <version>1.2.30</version>
    </dependency>

With the addition of this dependency, can I access the service via localhost:8082/v3/api-docs without having previously set anything and called a function of the dependency? How can this happen? What is the concept behind this ?

Jens
  • 67,715
  • 15
  • 98
  • 113
VolkanCP
  • 63
  • 5

2 Answers2

3

Adding the OpenAPI dependency in your Maven pom.xml just adds the librar(ies) to your project. That's all.

If this were a "traditional" project (like a JSP web app, for example), you'd have to write the code to create the web service (e.g. "localhost:8082/v3/api-docs").

But it sounds like your project might be Spring Boot:

https://developer.ibm.com/technologies/java/tutorials/j-spring-boot-basics-perry/

If you let it, Spring Boot will use its @EnableAutoConfiguration annotation to automatically configure your application. Auto-configuration is based on the JARS in your classpath and how you’ve defined your beans:

  • Spring Boot uses the JARs you have specified to be present in the CLASSPATH to form an opinion about how to configure certain automatic behavior. For example, if you have the H2 database JAR in your classpath and have configured no other DataSource beans, then your application will be automatically configured with an in-memory database.

  • Spring Boot uses the way you define beans to determine how to automatically configure itself. For example, if you annotate your JPA beans with @Entity, then Spring Boot will automatically configure JPA such that you do not need a persistence.xml file.

FoggyDay
  • 11,962
  • 4
  • 34
  • 48
0

It is called convention over configuration. Wiki link https://en.wikipedia.org/wiki/Convention_over_configuration

user12047085
  • 162
  • 1
  • 12