Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(config-api): auto generation of swagger spec #2347

Merged
merged 26 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b71a71f
feat(config-api): swagger annotation
pujavs Aug 30, 2022
1d20a20
feat(config-api): swagger annotation
pujavs Aug 30, 2022
e66b5d8
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Aug 31, 2022
1a016a2
feat(jans-config-api): swagger annotations for auto generation of spec
pujavs Aug 31, 2022
5f680d1
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Sep 1, 2022
0865093
feat(onfig-api): swagger metadata for auto generation of spec
pujavs Sep 1, 2022
db0ad85
feat(onfig-api): swagger metadata for auto generation of spec
pujavs Sep 1, 2022
ba89962
feat(config-api): sync with main
pujavs Sep 2, 2022
f1ff3e7
feat(config-api): auto generation of swagger spec
pujavs Sep 2, 2022
7db1873
feat(config-api): auto generation of swagger spec
pujavs Sep 2, 2022
3766cf9
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Sep 6, 2022
1a67c0d
feat(config-api): swagger spec generation
pujavs Sep 6, 2022
356231d
feat(config-api): swagger spec generation
pujavs Sep 6, 2022
bf7e78b
feat(config-api): swagger spec generation - working
pujavs Sep 6, 2022
cff10ab
feat(config-api): swagger spec generation - working
pujavs Sep 6, 2022
597fa88
feat(config-api): swagger spec generation - working
pujavs Sep 6, 2022
9fa1fef
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Sep 7, 2022
bf273dd
feat(config-api): auto generation of swagger spec
pujavs Sep 7, 2022
6d34629
feat(config-api): auto generation of swagger spec
pujavs Sep 7, 2022
7aa7c54
feat(config-api): auto generation of swagger spec
pujavs Sep 7, 2022
f6acf12
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Sep 8, 2022
b519b04
feat(config-api): auto gen swagger changes
pujavs Sep 8, 2022
25a5e02
feat(config-api): swagger specauto generation
pujavs Sep 9, 2022
b191e90
feat(config-api): swagger specauto generation
pujavs Sep 9, 2022
73f23cb
feat(config-api): swagger specauto generation
pujavs Sep 9, 2022
e1e27a4
feat(config-api): swagger spec auto generation
pujavs Sep 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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