feat: add Swagger UI for interactive API documentation
This commit is contained in:
parent
c2092d72d6
commit
10b5702e11
|
|
@ -82,6 +82,13 @@
|
|||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI — documentation interactive de l'API -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package com.rayhan.erp.config;
|
||||
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class OpenApiConfig {
|
||||
|
||||
@Bean
|
||||
public OpenAPI openAPI() {
|
||||
return new OpenAPI()
|
||||
.info(new Info()
|
||||
.title("ERP Rayhan — API REST")
|
||||
.description("API de gestion ERP pour SUARL Rayhan (plasturgie). PFE Ali Guennari.\n\n" +
|
||||
"**Comment utiliser :**\n" +
|
||||
"1. Cliquez sur `POST /api/auth/signin` → Try it out → Execute\n" +
|
||||
"2. Copiez le `token` de la réponse\n" +
|
||||
"3. Cliquez sur le bouton **Authorize 🔒** en haut à droite\n" +
|
||||
"4. Collez le token et cliquez Authorize\n" +
|
||||
"5. Tous les endpoints sont maintenant accessibles !\n\n" +
|
||||
"**Identifiants par défaut :** admin / Rayhan2024!")
|
||||
.version("1.0.0")
|
||||
.contact(new Contact()
|
||||
.name("Ali Guennari — PFE SUARL Rayhan")
|
||||
.email("ali.guennari@rayhan.tn")))
|
||||
.addSecurityItem(new SecurityRequirement().addList("Bearer Authentication"))
|
||||
.components(new Components()
|
||||
.addSecuritySchemes("Bearer Authentication",
|
||||
new SecurityScheme()
|
||||
.type(SecurityScheme.Type.HTTP)
|
||||
.scheme("bearer")
|
||||
.bearerFormat("JWT")
|
||||
.description("Entrez votre token JWT (sans le préfixe 'Bearer ')")));
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +61,7 @@ public class WebSecurityConfig {
|
|||
.requestMatchers("/api/auth/**").permitAll()
|
||||
.requestMatchers("/api/test/**").permitAll()
|
||||
.requestMatchers("/error").permitAll()
|
||||
.requestMatchers("/swagger-ui/**", "/swagger-ui.html", "/v3/api-docs/**").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue