Skip to content

Commit

Permalink
docs(config-api): auto generation of swagger spec (#2347)
Browse files Browse the repository at this point in the history
* feat(config-api): swagger annotation

* feat(config-api): swagger annotation

* feat(jans-config-api): swagger annotations for auto generation of spec

* feat(onfig-api): swagger metadata for auto generation of spec

* feat(onfig-api): swagger metadata for auto generation of spec

* feat(config-api): auto generation of swagger spec

* feat(config-api): auto generation of swagger spec

* feat(config-api): swagger spec generation

* feat(config-api): swagger spec generation

* feat(config-api): swagger spec generation - working

* feat(config-api): swagger spec generation - working

* feat(config-api): auto generation of swagger spec

* feat(config-api): auto generation of swagger spec

* feat(config-api): auto generation of swagger spec

* feat(config-api): auto gen swagger changes

* feat(config-api): swagger specauto generation

* feat(config-api): swagger specauto generation

* feat(config-api): swagger spec auto generation
  • Loading branch information
pujavs authored Sep 9, 2022
1 parent 1429a85 commit 57a1748
Show file tree
Hide file tree
Showing 46 changed files with 8,661 additions and 304 deletions.
5,346 changes: 5,346 additions & 0 deletions jans-config-api/docs/jans-config-api-swagger-auto.yaml

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions jans-config-api/plugins/admin-ui-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>

<!-- Swagger -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core-jakarta</artifactId>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -154,6 +161,34 @@
</execution>
</executions>
</plugin>

<!-- swagger -->
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin-jakarta</artifactId>
<version>${swagger-maven-plugin-jakarta}</version>
<executions>
<execution>
<configuration>
<alwaysResolveAppPath>true</alwaysResolveAppPath>
<outputFileName>jans-admin-ui-plugin-swagger</outputFileName>
<contextId>${project.artifactId}</contextId>
<prettyPrint>true</prettyPrint>
<resourcePackages>
<package>io.jans.ca.plugin.adminui.rest</package>
</resourcePackages>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models-jakarta</artifactId>
<version>${swagger-models-jakarta}</version>
</dependency>
</dependencies>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
import io.jans.ca.plugin.adminui.rest.license.LicenseResource;
import io.jans.ca.plugin.adminui.rest.logging.AuditLoggerResource;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.*;
import io.swagger.v3.oas.annotations.tags.*;
import io.swagger.v3.oas.annotations.security.*;
import io.swagger.v3.oas.annotations.servers.*;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
import java.util.HashSet;
Expand All @@ -21,6 +28,27 @@
*
*/
@ApplicationPath("/")
@OpenAPIDefinition(info = @Info(title = "Jans Config API - Admin-UI", version = "1.0.0", contact = @Contact(name = "Gluu Support", url = "https://support.gluu.org", email = "xxx@gluu.org"),

license = @License(name = "Apache 2.0", url = "https://github.com/JanssenProject/jans/blob/main/LICENSE")),

tags = { @Tag(name = "Admin UI - Role"),
@Tag(name = "Admin UI - Permission"),
@Tag(name = "Admin UI - Role-Permissions Mapping"),
@Tag(name = "Admin UI - License") },

servers = { @Server(url = "https://jans.io/", description = "The Jans server") })

@SecurityScheme(name = "oauth2", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(clientCredentials = @OAuthFlow(tokenUrl = "https://{op-hostname}/.../token", scopes = {
@OAuthScope(name = "https://jans.io/oauth/jans-auth-server/config/adminui/user/role.read", description = "View admin user role related information"),
@OAuthScope(name = "https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write", description = "Manage admin user role related information"),
@OAuthScope(name = "https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.read", description = "View admin permission related information"),
@OAuthScope(name = "https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write", description = "Manage admin permission related information"),
@OAuthScope(name = "https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly", description = "View role-permission mapping related information"),
@OAuthScope(name = "https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write", description = "Manage role-permission mapping related information"),
@OAuthScope(name = "https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly", description = "Delete admin-ui license related information"),
@OAuthScope(name = "https://jans.io/oauth/jans-auth-server/config/adminui/license.write", description = "View admin-ui license related information")}
)))
public class ApiApplication extends Application {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import io.jans.ca.plugin.adminui.service.config.AUIConfigurationService;
import io.jans.ca.plugin.adminui.utils.ErrorResponse;
import io.jans.configapi.core.rest.ProtectedApi;

import io.swagger.v3.oas.annotations.Hidden;

import org.slf4j.Logger;

import jakarta.inject.Inject;
Expand All @@ -19,6 +22,7 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

@Hidden
@Path("/admin-ui/oauth2")
public class OAuth2Resource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

import io.jans.as.model.config.adminui.LicenseSpringCredentials;
import io.jans.ca.plugin.adminui.model.auth.LicenseApiResponse;
import io.jans.ca.plugin.adminui.model.exception.ApplicationException;
import io.jans.ca.plugin.adminui.model.auth.LicenseRequest;
import io.jans.ca.plugin.adminui.model.auth.LicenseResponse;
import io.jans.ca.plugin.adminui.service.license.LicenseDetailsService;
import io.jans.ca.plugin.adminui.utils.ErrorResponse;
import io.jans.configapi.core.rest.ProtectedApi;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.*;

import org.slf4j.Logger;

import jakarta.inject.Inject;
Expand Down Expand Up @@ -35,9 +43,17 @@ public class LicenseResource {
@Inject
LicenseDetailsService licenseDetailsService;

@Operation(summary = "Check if admin-ui license is active", description = "Check if admin-ui license is active", operationId = "is-license-active", tags = {
"Admin UI - License" }, security = @SecurityRequirement(name = "oauth2", scopes = {
SCOPE_LICENSE_READ }))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))) })
@GET
@Path(IS_ACTIVE)
@ProtectedApi(scopes={SCOPE_LICENSE_READ})
@ProtectedApi(scopes = { SCOPE_LICENSE_READ })
@Produces(MediaType.APPLICATION_JSON)
public Response isActive() {
LicenseApiResponse licenseResponse = null;
Expand All @@ -52,9 +68,18 @@ public Response isActive() {
}
}

@Operation(summary = "Activate license using license-key", description = "Activate license using license-key", operationId = "activate-adminui-license", tags = {
"Admin UI - License" }, security = @SecurityRequirement(name = "oauth2", scopes = {
SCOPE_LICENSE_WRITE }))
@RequestBody(description = "LicenseRequest object", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseRequest.class)))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))) })
@POST
@Path(ACTIVATE_LICENSE)
@ProtectedApi(scopes={SCOPE_LICENSE_WRITE})
@ProtectedApi(scopes = { SCOPE_LICENSE_WRITE })
@Produces(MediaType.APPLICATION_JSON)
public Response activateLicense(@Valid @NotNull LicenseRequest licenseRequest) {
LicenseApiResponse licenseResponse = null;
Expand All @@ -69,9 +94,18 @@ public Response activateLicense(@Valid @NotNull LicenseRequest licenseRequest) {
}
}

@Operation(summary = "Save license api credentials", description = "Save license api credentials", operationId = "save-license-api-credentials", tags = {
"Admin UI - License" }, security = @SecurityRequirement(name = "oauth2", scopes = {
SCOPE_LICENSE_WRITE }))
@RequestBody(description = "LicenseSpringCredentials object", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseSpringCredentials.class)))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseApiResponse.class, description = "License response"))) })
@POST
@Path(SAVE_API_CREDENTIALS)
@ProtectedApi(scopes={SCOPE_LICENSE_WRITE})
@ProtectedApi(scopes = { SCOPE_LICENSE_WRITE })
@Produces(MediaType.APPLICATION_JSON)
public Response saveLicenseCredentials(@Valid @NotNull LicenseSpringCredentials licenseSpringCredentials) {
LicenseApiResponse licenseResponse = null;
Expand All @@ -86,9 +120,17 @@ public Response saveLicenseCredentials(@Valid @NotNull LicenseSpringCredentials
}
}

@Operation(summary = "Get admin ui license details", description = "Get admin ui license details", operationId = "get-adminui-license", tags = {
"Admin UI - License" }, security = @SecurityRequirement(name = "oauth2", scopes = {
SCOPE_LICENSE_READ }))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = LicenseResponse.class, description = "License Response"))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@GET
@Path(LICENSE_DETAILS)
@ProtectedApi(scopes={SCOPE_LICENSE_READ})
@ProtectedApi(scopes = { SCOPE_LICENSE_READ })
@Produces(MediaType.APPLICATION_JSON)
public Response getLicenseDetails() {
try {
Expand Down
Loading

0 comments on commit 57a1748

Please sign in to comment.