From 843e9f323d6558ca95a04e7e0ff1c84530f5b9f9 Mon Sep 17 00:00:00 2001 From: Arnab Dutta Date: Mon, 4 Jul 2022 18:50:33 +0530 Subject: [PATCH] fix: fix typos and other issues in jans-config-api swagger specs #1665 --- .../java/io/jans/configapi/util/AttributeNames.java | 1 + jans-config-api/docs/jans-config-api-swagger.yaml | 13 +++++++------ .../rest/resource/auth/ClientsResource.java | 4 ++-- .../configapi/rest/resource/auth/StatResource.java | 4 ++-- .../io/jans/configapi/core/rest/BaseResource.java | 6 ++++++ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/jans-config-api/common/src/main/java/io/jans/configapi/util/AttributeNames.java b/jans-config-api/common/src/main/java/io/jans/configapi/util/AttributeNames.java index 4b3aefc3634..2dcb60edb13 100644 --- a/jans-config-api/common/src/main/java/io/jans/configapi/util/AttributeNames.java +++ b/jans-config-api/common/src/main/java/io/jans/configapi/util/AttributeNames.java @@ -20,6 +20,7 @@ public class AttributeNames { public static final String SCOPES = "scopes"; public static final String GRANT_TYPES = "grant types"; public static final String DATA_TYPE = "dataType"; + public static final String REDIRECT_URIS = "redirectUris"; private AttributeNames() { } diff --git a/jans-config-api/docs/jans-config-api-swagger.yaml b/jans-config-api/docs/jans-config-api-swagger.yaml index 288456fba42..a609ec85aa5 100644 --- a/jans-config-api/docs/jans-config-api-swagger.yaml +++ b/jans-config-api/docs/jans-config-api-swagger.yaml @@ -1892,8 +1892,8 @@ paths: post: tags: - OAuth - OpenID Connect - Clients - summary: Create new OpenId connect client - description: Create new OpenId connect client + summary: Create new OpenId Connect client + description: Create new OpenId Connect client operationId: post-oauth-openid-clients requestBody: content: @@ -5048,10 +5048,7 @@ components: description: Client. type: object required: - - applicationType - - logout - - includeClaimsInIdToken - - displayName + - redirectUris properties: dn: type: string @@ -6061,6 +6058,10 @@ components: properties: month: type: integer + start_month: + type: integer + end_month: + type: integer monthly_active_users: type: integer format: int64 diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/ClientsResource.java b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/ClientsResource.java index 5f5dc9a7abd..796c57d7e90 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/ClientsResource.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/ClientsResource.java @@ -116,7 +116,7 @@ public Response createOpenIdConnect(@Valid Client client) throws EncryptionExcep inum = inumService.generateClientInum(); client.setClientId(inum); } - checkNotNull(client.getDisplayName(), AttributeNames.DISPLAY_NAME); + checkNotNull(client.getRedirectUris(), AttributeNames.REDIRECT_URIS); //scope validation checkScopeFormat(client); @@ -148,7 +148,7 @@ public Response updateClient(@Valid Client client) throws EncryptionException { } String inum = client.getClientId(); checkNotNull(inum, AttributeNames.INUM); - checkNotNull(client.getDisplayName(), AttributeNames.DISPLAY_NAME); + checkNotNull(client.getRedirectUris(), AttributeNames.REDIRECT_URIS); Client existingClient = clientService.getClientByInum(inum); checkResourceNotNull(existingClient, OPENID_CONNECT_CLIENT); diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/StatResource.java b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/StatResource.java index e754cebc603..3e86e25f8ab 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/StatResource.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/StatResource.java @@ -35,8 +35,8 @@ public class StatResource extends ConfigBaseResource { @Produces(MediaType.APPLICATION_JSON) public Response getStatistics(@HeaderParam("Authorization") String authorization, @QueryParam(value = "month") String month, - @QueryParam(value = "start-month") String startMonth, - @QueryParam(value = "end-month") String endMonth, + @QueryParam(value = "start_month") String startMonth, + @QueryParam(value = "end_month") String endMonth, @QueryParam(value = "format") String format) { if (StringUtils.isBlank(format)) { format = ""; diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java index 18a82e45c25..dd7cf017fcb 100644 --- a/jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java @@ -42,6 +42,12 @@ public static void checkNotNull(String attribute, String attributeName) { } } + public static void checkNotNull(String[] attributes, String attributeName) { + if (attributes == null || attributes.length <= 0) { + throw new BadRequestException(getMissingAttributeError(attributeName)); + } + } + public static void throwMissingAttributeError(String attributeName) { if (StringUtils.isNotEmpty(attributeName)) { throw new BadRequestException(getMissingAttributeError(attributeName));