14 Eylül 2022 Çarşamba

SpringDoc OpenAPI @OpenAPIDefinition Anotasyonu

Giriş
Bu anotasyon yerine OpenAPI Sınıfı da kullanılabilir

Örnek
Şöyle yaparız
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.info.Info;

@SpringBootApplication
@OpenAPIDefinition(
  info = @Info(
    title = "SpringShop API | Annotation style", //Title
    version = "0.0", //Version near OAS3 label
    description = "My API description",
    license = @License(name = "Apache 2.0", url = "http://foo.bar"),//License address
    contact = @Contact(url = "http://stefans-example.com", //Website address
                       name = "My Name", //Send email to My Name
                       email = "myemail@gmail.com")
  )
)
public class ExchangeApplication implements CommandLineRunner {
}
Şeklen şöyle

Örnek
Şöyle yaparız
@OpenAPIDefinition(info = @Info(
    title = "Title",
    version = "1.0",
    description = "REST API description...",
    contact = @Contact(name = "Contact")),
    security = {@SecurityRequirement(name = "bearerToken")}
)
@SecuritySchemes({
    @SecurityScheme(name = "bearerToken", type = SecuritySchemeType.HTTP,
            scheme = "bearer", bearerFormat = "JWT")
})




Hiç yorum yok:

Yorum Gönder