mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
added example to AuthenticationResource
This commit is contained in:
@@ -3,10 +3,11 @@ package sonia.scm.api.v2.resources;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
|
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
|
||||||
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityScheme;
|
import io.swagger.v3.oas.annotations.security.SecurityScheme;
|
||||||
import io.swagger.v3.oas.annotations.security.SecuritySchemes;
|
import io.swagger.v3.oas.annotations.security.SecuritySchemes;
|
||||||
@@ -79,9 +80,16 @@ public class AuthenticationResource {
|
|||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("access_token")
|
@Path("access_token")
|
||||||
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
@Operation(summary = "Login via Form", description = "Form-based authentication.", tags = "Authentication")
|
@Operation(
|
||||||
|
summary = "Login via Form",
|
||||||
|
description = "Form-based authentication.",
|
||||||
|
tags = "Authentication",
|
||||||
|
hidden = true
|
||||||
|
)
|
||||||
@ApiResponse(responseCode = "200", description = "success")
|
@ApiResponse(responseCode = "200", description = "success")
|
||||||
|
@ApiResponse(responseCode = "204", description = "success without content")
|
||||||
@ApiResponse(responseCode = "400", description = "bad request, required parameter is missing")
|
@ApiResponse(responseCode = "400", description = "bad request, required parameter is missing")
|
||||||
@ApiResponse(responseCode = "401", description = "unauthorized, the specified username or password is wrong")
|
@ApiResponse(responseCode = "401", description = "unauthorized, the specified username or password is wrong")
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
@@ -102,9 +110,26 @@ public class AuthenticationResource {
|
|||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("access_token")
|
@Path("access_token")
|
||||||
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Operation(summary = "Login via JSON", description = "JSON-based authentication.", tags = "Authentication")
|
@Operation(
|
||||||
|
summary = "Login via JSON",
|
||||||
|
description = "JSON-based authentication.",
|
||||||
|
tags = "Authentication",
|
||||||
|
requestBody = @RequestBody(
|
||||||
|
content = @Content(
|
||||||
|
mediaType = MediaType.APPLICATION_JSON,
|
||||||
|
schema = @Schema(implementation = AuthenticationRequestDto.class),
|
||||||
|
examples = @ExampleObject(
|
||||||
|
name = "Simple login",
|
||||||
|
value = "{\n \"username\":\"scmadmin\",\n \"password\":\"scmadmin\",\n \"cookie\":false,\n \"grant_type\":\"password\"\n}",
|
||||||
|
summary = "Authenticate with username and password"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ApiResponse(responseCode = "200", description = "success")
|
@ApiResponse(responseCode = "200", description = "success")
|
||||||
|
@ApiResponse(responseCode = "204", description = "success without content")
|
||||||
@ApiResponse(responseCode = "400", description = "bad request, required parameter is missing")
|
@ApiResponse(responseCode = "400", description = "bad request, required parameter is missing")
|
||||||
@ApiResponse(responseCode = "401", description = "unauthorized, the specified username or password is wrong")
|
@ApiResponse(responseCode = "401", description = "unauthorized, the specified username or password is wrong")
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
|
|||||||
Reference in New Issue
Block a user