From e456623f54dccf64dee27396613dc3edfa401091 Mon Sep 17 00:00:00 2001 From: sergiishamrai-okta <71881713+sergiishamrai-okta@users.noreply.github.com> Date: Mon, 22 Mar 2021 18:14:41 +0200 Subject: [PATCH] Addressing spec inconsistencies with Open API repo spec (v2.3.0) (#558) OpenApi spec v2.3.0 --- MIGRATING.md | 303 ++++++++++++ api/pom.xml | 2 +- .../okta/sdk/resource/user/UserBuilder.java | 1 + coverage/pom.xml | 2 +- examples/pom.xml | 2 +- examples/quickstart/pom.xml | 2 +- httpclients/httpclient/pom.xml | 2 +- httpclients/okhttp/pom.xml | 2 +- impl/pom.xml | 2 +- .../resource/AbstractPropertyRetriever.java | 4 + .../sdk/impl/resource/DefaultUserBuilder.java | 37 +- .../resource/DefaultUserBuilderTest.groovy | 62 ++- .../resource/GeneratedResourceTest.groovy | 3 +- integration-tests/pom.xml | 2 +- .../okta/sdk/tests/it/ApplicationsIT.groovy | 93 +++- .../sdk/tests/it/AuthorizationServerIT.groovy | 2 +- .../okta/sdk/tests/it/LinkedObjectsIT.groovy | 5 - .../com/okta/sdk/tests/it/UserTypesIT.groovy | 92 +++- .../com/okta/sdk/tests/it/UsersIT.groovy | 2 +- .../sdk/tests/it/util/ClientProvider.groovy | 4 - pom.xml | 24 +- src/swagger/api.yaml | 431 +++++++++++++++--- swagger-templates/pom.xml | 2 +- .../AbstractOktaJavaClientCodegen.java | 40 +- .../codegen/OktaJavaClientImplCodegen.java | 19 +- .../OktaJava/modelInnerEnum.mustache | 58 +-- .../OktaJava/modelInterface.mustache | 6 +- .../modelListResourceInterface.mustache | 2 +- .../resources/OktaJavaImpl/modelImpl.mustache | 2 +- 29 files changed, 1003 insertions(+), 205 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index 01b7d4e4186..b0c06f06da7 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -2,6 +2,309 @@ This SDK uses semantic versioning and follows Okta's [library version policy](https://developer.okta.com/code/library-versions/). In short, we do not make breaking changes unless the major version changes! +## Migrating from 3.x.x to 4.0.0 + +Version 4.0.0 of this SDK introduces a number of breaking changes from previous versions. +In addition to many new classes/interfaces, some existing classes/interfaces are no longer backward compatible due to method renaming and signature changes. + +### Package `com.okta.sdk.client.Client` + +Below methods have undergone a signature change. +- `User createUser(User user, Boolean active, Boolean provider, UserNextLogin nextLogin)` signature changed to `User createUser(CreateUserRequest createUserRequest, Boolean active, Boolean provider, UserNextLogin nextLogin)` +- `User createUser(User user)` signature changed to `User createUser(CreateUserRequest createUserRequest)` + - First argument type changed from `User` to `CreateUserRequest` + +Below methods have been added. +- `UserSchema updateApplicationUserProfile(String appInstanceId, UserSchema userSchema)` +- `UserSchema updateApplicationUserProfile(String appInstanceId)` +- `UserSchema updateUserProfile(String schemaId, UserSchema userSchema)` + +### Package `com.okta.sdk.resource.user.type.UserType` + +Class `com.okta.sdk.resource.user.UserType` moved to `com.okta.sdk.resource.user.type.UserType` + +### Package `com.okta.sdk.resource.user.type.UserTypeList` + +Class `com.okta.sdk.resource.user.UserTypeList` moved to `com.okta.sdk.resource.user.type.UserTypeList` + +### Package `com.okta.sdk.resource.application.JsonWebKey` + +Below methods have been added. +- `JsonWebKey setAlg(String alg)` +- `JsonWebKey setCreated(Date created)` +- `JsonWebKey setE(String e)` +- `JsonWebKey setExpiresAt(Date expiresAt)` +- `JsonWebKey setKeyOps(List keyOps)` +- `JsonWebKey setKid(String kid)` +- `JsonWebKey setKty(String kty)` +- `JsonWebKey setLastUpdated(Date lastUpdated)` +- `JsonWebKey setN(String n)` +- `JsonWebKey setStatus(String status)` +- `JsonWebKey setUse(String use)` +- `JsonWebKey setX5t(String x5t)` +- `JsonWebKey setX5tS256(String x5tS256)` +- `JsonWebKey setX5u(String x5u)` + +### Package `com.okta.sdk.resource.application.OpenIdConnectApplicationIdpInitiatedLogin` + +This is a newly created interface with methods listed below. + +- `List getDefaultScope()` +- `OpenIdConnectApplicationIdpInitiatedLogin setDefaultScope(List defaultScope)` +- `String getMode()` +- `OpenIdConnectApplicationIdpInitiatedLogin setMode(String mode)` + +### Package `com.okta.sdk.resource.application.OpenIdConnectApplicationSettingsClient` + +Below methods have been added. + +- `OpenIdConnectApplicationIdpInitiatedLogin getIdpInitiatedLogin()` +- `OpenIdConnectApplicationSettingsClient setIdpInitiatedLogin(OpenIdConnectApplicationIdpInitiatedLogin idpInitiatedLogin)` + +### Package `com.okta.sdk.resource.application.SamlApplicationSettingsSignOn` + +Below methods have been added. + +- `SingleLogout getSlo()` +- `SpCertificate getSpCertificate()` +- `SamlApplicationSettingsSignOn setSlo(SingleLogout slo)` +- `SamlApplicationSettingsSignOn setSpCertificate(SpCertificate spCertificate)` + +### Package `com.okta.sdk.resource.application.SamlApplicationV1` + +The Interface `com.okta.sdk.resource.application.SamlApplicationV1` has been removed. +The Interface `com.okta.sdk.resource.application.SamlApplication` should be used instead. + + +### Package `com.okta.sdk.resource.application.SingleLogout` + +This is a newly created interface with methods listed below. + +- `Boolean getEnabled()` +- `String getIssuer()` +- `String getLogoutUrl()` +- `SingleLogout setEnabled(Boolean enabled)` +- `SingleLogout setIssuer(String issuer)` +- `SingleLogout setLogoutUrl(String logoutUrl)` + +### Package `com.okta.sdk.resource.application.SpCertificate` + +This is a newly created interface with methods listed below. + +- `List getX5c()` +- `SpCertificate setX5c(List x5c)` + +### Package `com.okta.sdk.resource.authorization.server.AuthorizationServerPolicy` + +Below method has been renamed in the interest of naming consistency. +- Renamed `deletePolicy` to `delete` + +Below method has undergone a signature change. +- `void deletePolicyRule(String ruleId)` signature changed to `void deletePolicyRule(String authServerId, String ruleId)` + +Below method has undergone a signature change and renamed in the interest of naming consistency. +- `AuthorizationServerPolicy updatePolicy(String authServerId, AuthorizationServerPolicy authServerPolicy)` changed to `AuthorizationServerPolicy update(String authServerId)` + +### Package `com.okta.sdk.resource.authorization.server.policy.AuthorizationServerPolicyRule` + +Below method has been renamed in the interest of naming consistency. +- Renamed `deletePolicyRule` to `delete` + +### Package `com.okta.sdk.resource.inline.hook.InlineHookChannelConfig` + +Below methods have been added. + +- `String getMethod()` +- `InlineHookChannelConfig setMethod(String method)` + +### Package `com.okta.sdk.resource.linked.object.LinkedObject` + +Below methods have been removed. +- `String getName()` + - `LinkedObject.getPrimary().getName()` should be used instead +- `LinkedObject setName(String name)` + - `LinkedObject.getPrimary().setName()` should be used instead + +### Package `com.okta.sdk.resource.log.LogCredentialProvider` + +Enum `LogCredentialProvider` has the below new field definition: +- `OKTA_CREDENTIAL_PROVIDER("OKTA_CREDENTIAL_PROVIDER")` + +### Package `com.okta.sdk.resource.policy.DevicePolicyRuleConditionPlatform$SupportedMDMFrameworksEnum` + +Interface `com.okta.sdk.resource.policy.MDMFrameworks` moved to `com.okta.sdk.resource.policy.DevicePolicyRuleConditionPlatform$SupportedMDMFrameworksEnum` + +### Package `com.okta.sdk.resource.policy.DevicePolicyRuleConditionPlatform$TypesEnum` + +Interface `com.okta.sdk.resource.policy.Platforms` moved to `com.okta.sdk.resource.policy.DevicePolicyRuleConditionPlatform$TypesEnum` + +### Package `com.okta.sdk.resource.user.factor.PushUserFactor` + +Below method has been added +- `PushUserFactor setExpiresAt(Date expiresAt)` + +### Package `com.okta.sdk.resource.user.factor.UserFactor` + +Below method has been renamed in the interest of naming consistency. +- Renamed `deleteFactor` to `delete` + +### Package `com.okta.sdk.resource.user.schema.UserSchema` + +This is a newly created interface with methods listed below. +- `String getCreated()` +- `UserSchemaDefinitions getDefinitions()` +- `String getId()` +- `String getLastUpdated()` +- `Map getLinks()` +- `String getName()` +- `Map getProperties()` +- `String getSchema()` +- `String getTitle()` +- `String getType()` +- `UserSchema setDefinitions(UserSchemaDefinitions definitions)` +- `UserSchema setTitle(String title)` + +### Package `com.okta.sdk.resource.user.schema.UserSchemaAttribute` + +This is a newly created interface with methods listed below. +- `String getDescription()` +- `UserSchemaAttributeMaster getMaster()` +- `Integer getMaxLength()` +- `Integer getMinLength()` +- `String getMutability()` +- `List getPermissions()` +- `Boolean getRequired()` +- `String getScope()` +- `String getTitle()` +- `String getType()` +- `UserSchemaAttribute setDescription(String description)` +- `UserSchemaAttribute setMaster(UserSchemaAttributeMaster master)` +- `UserSchemaAttribute setMaxLength(Integer maxLength)` +- `UserSchemaAttribute setMinLength(Integer minLength)` +- `UserSchemaAttribute setMutability(String mutability)` +- `UserSchemaAttribute setPermissions(List permissions)` +- `UserSchemaAttribute setRequired(Boolean required)` +- `UserSchemaAttribute setScope(String scope)` +- `UserSchemaAttribute setTitle(String title)` +- `UserSchemaAttribute setType(String type)` + +### Package `com.okta.sdk.resource.user.schema.UserSchemaAttributeMaster` + +This is a newly created interface with methods listed below. +- `String getType()` +- `UserSchemaAttributeMaster setType(String type)` + +### Package `com.okta.sdk.resource.user.schema.UserSchemaAttributePermission` + +This is a newly created interface with methods listed below. +- `String getAction()` +- `String getPrincipal()` +- `UserSchemaAttributePermission setAction(String action)` +- `UserSchemaAttributePermission setPrincipal(String principal)` + +### Package `com.okta.sdk.resource.user.schema.UserSchemaBase` + +This is a newly created interface with methods listed below. +- `String getId()` +- `UserSchemaBaseProperties getProperties()` +- `List getRequired()` +- `String getType()` +- `UserSchemaBase setProperties(UserSchemaBaseProperties properties)` +- `UserSchemaBase setRequired(List required)` +- `UserSchemaBase setType(String type)` + +### Package `com.okta.sdk.resource.user.schema.UserSchemaBaseProperties` + +This is a newly created interface with methods listed below. +- `UserSchemaAttribute getCity()` +- `UserSchemaAttribute getCostCenter()` +- `UserSchemaAttribute getCountryCode()` +- `UserSchemaAttribute getDepartment()` +- `UserSchemaAttribute getDisplayName()` +- `UserSchemaAttribute getDivision()` +- `UserSchemaAttribute getEmail()` +- `UserSchemaAttribute getEmployeeNumber()` +- `UserSchemaAttribute getFirstName()` +- `UserSchemaAttribute getHonorificPrefix()` +- `UserSchemaAttribute getHonorificSuffix()` +- `UserSchemaAttribute getLastName()` +- `UserSchemaAttribute getLocale()` +- `UserSchemaAttribute getLogin()` +- `UserSchemaAttribute getManager()` +- `UserSchemaAttribute getManagerId()` +- `UserSchemaAttribute getMiddleName()` +- `UserSchemaAttribute getMobilePhone()` +- `UserSchemaAttribute getNickName()` +- `UserSchemaAttribute getOrganization()` +- `UserSchemaAttribute getPostalAddress()` +- `UserSchemaAttribute getPreferredLanguage()` +- `UserSchemaAttribute getPrimaryPhone()` +- `UserSchemaAttribute getProfileUrl()` +- `UserSchemaAttribute getSecondEmail()` +- `UserSchemaAttribute getState()` +- `UserSchemaAttribute getStreetAddress()` +- `UserSchemaAttribute getTimezone()` +- `UserSchemaAttribute getTitle()` +- `UserSchemaAttribute getUserType()` +- `UserSchemaAttribute getZipCode()` +- `UserSchemaBaseProperties setCity(UserSchemaAttribute city)` +- `UserSchemaBaseProperties setCostCenter(UserSchemaAttribute costCenter)` +- `UserSchemaBaseProperties setCountryCode(UserSchemaAttribute countryCode)` +- `UserSchemaBaseProperties setDepartment(UserSchemaAttribute department)` +- `UserSchemaBaseProperties setDisplayName(UserSchemaAttribute displayName)` +- `UserSchemaBaseProperties setDivision(UserSchemaAttribute division)` +- `UserSchemaBaseProperties setEmail(UserSchemaAttribute email)` +- `UserSchemaBaseProperties setEmployeeNumber(UserSchemaAttribute employeeNumber)` +- `UserSchemaBaseProperties setFirstName(UserSchemaAttribute firstName)` +- `UserSchemaBaseProperties setHonorificPrefix(UserSchemaAttribute honorificPrefix)` +- `UserSchemaBaseProperties setHonorificSuffix(UserSchemaAttribute honorificSuffix)` +- `UserSchemaBaseProperties setLastName(UserSchemaAttribute lastName)` +- `UserSchemaBaseProperties setLocale(UserSchemaAttribute locale)` +- `UserSchemaBaseProperties setLogin(UserSchemaAttribute login)` +- `UserSchemaBaseProperties setManager(UserSchemaAttribute manager)` +- `UserSchemaBaseProperties setManagerId(UserSchemaAttribute managerId)` +- `UserSchemaBaseProperties setMiddleName(UserSchemaAttribute middleName)` +- `UserSchemaBaseProperties setMobilePhone(UserSchemaAttribute mobilePhone)` +- `UserSchemaBaseProperties setNickName(UserSchemaAttribute nickName)` +- `UserSchemaBaseProperties setOrganization(UserSchemaAttribute organization)` +- `UserSchemaBaseProperties setPostalAddress(UserSchemaAttribute postalAddress)` +- `UserSchemaBaseProperties setPreferredLanguage(UserSchemaAttribute preferredLanguage)` +- `UserSchemaBaseProperties setPrimaryPhone(UserSchemaAttribute primaryPhone)` +- `UserSchemaBaseProperties setProfileUrl(UserSchemaAttribute profileUrl)` +- `UserSchemaBaseProperties setSecondEmail(UserSchemaAttribute secondEmail)` +- `UserSchemaBaseProperties setState(UserSchemaAttribute state)` +- `UserSchemaBaseProperties setStreetAddress(UserSchemaAttribute streetAddress)` +- `UserSchemaBaseProperties setTimezone(UserSchemaAttribute timezone)` +- `UserSchemaBaseProperties setTitle(UserSchemaAttribute title)` +- `UserSchemaBaseProperties setUserType(UserSchemaAttribute userType)` +- `UserSchemaBaseProperties setZipCode(UserSchemaAttribute zipCode)` + +### Package `com.okta.sdk.resource.user.schema.UserSchemaDefinitions` + +This is a newly created interface with methods listed below. +- `UserSchemaBase getBase()` +- `UserSchemaPublic getCustom()` +- `UserSchemaDefinitions setBase(UserSchemaBase base)` +- `UserSchemaDefinitions setCustom(UserSchemaPublic custom)` + +### Package `com.okta.sdk.resource.user.schema.UserSchemaPublic` + +This is a newly created interface with methods listed below. +- `String getId()` +- `Map getProperties()` +- `List getRequired()` +- `String getType()` +- `UserSchemaPublic setProperties(Map properties)` +- `UserSchemaPublic setRequired(List required)` +- `UserSchemaPublic setType(String type)` + +### Package `com.okta.sdk.resource.user.User` + +Below method has undergone a signature change in the interest of naming consistency. +- `void addAllAppsAsTargetToRole()` to `void addAllAppsAsTarget(String roleId)` +- `void deleteFactor()` to `void deleteFactor(String factorId)` + + ## Migrating from 2.x.x to 3.0.0 Version 3.0.0 of this SDK introduces a number of breaking changes from previous versions. diff --git a/api/pom.xml b/api/pom.xml index 2fc2e640744..d6d7c15701f 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT okta-sdk-api diff --git a/api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java b/api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java index 850fa97b721..d4e0f82b163 100644 --- a/api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java +++ b/api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java @@ -17,6 +17,7 @@ import com.okta.commons.lang.Classes; import com.okta.sdk.client.Client; +import com.okta.sdk.resource.user.type.UserType; import java.util.Arrays; import java.util.Map; diff --git a/coverage/pom.xml b/coverage/pom.xml index 8fc1383d45d..4047cefe915 100644 --- a/coverage/pom.xml +++ b/coverage/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT okta-sdk-coverage diff --git a/examples/pom.xml b/examples/pom.xml index a68c50f2ac2..19bd870ecde 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT okta-sdk-examples diff --git a/examples/quickstart/pom.xml b/examples/quickstart/pom.xml index ab786ecd6bd..5215720592e 100644 --- a/examples/quickstart/pom.xml +++ b/examples/quickstart/pom.xml @@ -20,7 +20,7 @@ com.okta.sdk okta-sdk-examples - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/httpclients/httpclient/pom.xml b/httpclients/httpclient/pom.xml index ac96239f63b..d6313c5f60f 100644 --- a/httpclients/httpclient/pom.xml +++ b/httpclients/httpclient/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT ../.. diff --git a/httpclients/okhttp/pom.xml b/httpclients/okhttp/pom.xml index c00d6f1e0fc..dac14b36685 100644 --- a/httpclients/okhttp/pom.xml +++ b/httpclients/okhttp/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT ../.. diff --git a/impl/pom.xml b/impl/pom.xml index a3e75f732fe..0d0c26de1f1 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT okta-sdk-impl diff --git a/impl/src/main/java/com/okta/sdk/impl/resource/AbstractPropertyRetriever.java b/impl/src/main/java/com/okta/sdk/impl/resource/AbstractPropertyRetriever.java index 25016c8da1f..d2a58848800 100644 --- a/impl/src/main/java/com/okta/sdk/impl/resource/AbstractPropertyRetriever.java +++ b/impl/src/main/java/com/okta/sdk/impl/resource/AbstractPropertyRetriever.java @@ -202,6 +202,10 @@ protected Date getDateProperty(DateProperty key) { return null; } + if(value instanceof Date) { + return (Date)value; + } + try { return dateFormatter.parse(String.valueOf(value)); } catch (ParseException e) { diff --git a/impl/src/main/java/com/okta/sdk/impl/resource/DefaultUserBuilder.java b/impl/src/main/java/com/okta/sdk/impl/resource/DefaultUserBuilder.java index 3ca1adc17f0..1432c4fe95b 100644 --- a/impl/src/main/java/com/okta/sdk/impl/resource/DefaultUserBuilder.java +++ b/impl/src/main/java/com/okta/sdk/impl/resource/DefaultUserBuilder.java @@ -26,7 +26,8 @@ import com.okta.sdk.resource.user.UserCredentials; import com.okta.sdk.resource.user.UserNextLogin; import com.okta.sdk.resource.user.UserProfile; -import com.okta.sdk.resource.user.UserType; +import com.okta.sdk.resource.user.type.UserType; +import com.okta.sdk.resource.user.CreateUserRequest; import java.util.Arrays; import java.util.HashMap; @@ -166,11 +167,11 @@ public UserBuilder setNextLogin(UserNextLogin nextLogin) { return this; } - private User build(Client client) { + private CreateUserRequest build(Client client) { - User user = client.instantiate(User.class); - user.setProfile(client.instantiate(UserProfile.class)); - UserProfile userProfile = user.getProfile(); + CreateUserRequest createUserRequest = client.instantiate(CreateUserRequest.class); + createUserRequest.setProfile(client.instantiate(UserProfile.class)); + UserProfile userProfile = createUserRequest.getProfile(); if (Strings.hasText(firstName)) userProfile.setFirstName(firstName); if (Strings.hasText(lastName)) userProfile.setLastName(lastName); if (Strings.hasText(email)) userProfile.setEmail(email); @@ -185,15 +186,15 @@ private User build(Client client) { } if (Strings.hasText(userTypeId)) { - user.setType(client.instantiate(UserType.class).setId(userTypeId)); + createUserRequest.setType(client.instantiate(UserType.class).setId(userTypeId)); } else if (userType != null) { - user.setType(userType); + createUserRequest.setType(userType); } if (!Collections.isEmpty(groupIds)) { - if (user instanceof AbstractResource) { - ((AbstractResource) user).setProperty("groupIds", groupIds, true); + if (createUserRequest instanceof AbstractResource) { + ((AbstractResource) createUserRequest).setProperty("groupIds", groupIds, true); } else { throw new IllegalArgumentException("'User' is not an instance of 'AbstractResource', so 'groupIds' cannot be set. This would only happen if the implementation of 'User' has been customized."); } @@ -206,7 +207,7 @@ else if (userType != null) { RecoveryQuestionCredential question = client.instantiate(RecoveryQuestionCredential.class); question.setQuestion(securityQuestion); question.setAnswer(securityQuestionAnswer); - createCredentialsIfNeeded(user, client).setRecoveryQuestion(question); + createCredentialsIfNeeded(createUserRequest, client).setRecoveryQuestion(question); } // user password @@ -217,14 +218,14 @@ else if (userType != null) { } PasswordCredential passwordCredential = client.instantiate(PasswordCredential.class); - createCredentialsIfNeeded(user, client).setPassword(passwordCredential.setValue(password)); + createCredentialsIfNeeded(createUserRequest, client).setPassword(passwordCredential.setValue(password)); } // direct password import if (passwordHashProperties != null) { PasswordCredential passwordCredential = client.instantiate(PasswordCredential.class); passwordCredential.put("hash", passwordHashProperties); - createCredentialsIfNeeded(user, client).setPassword(passwordCredential); + createCredentialsIfNeeded(createUserRequest, client).setPassword(passwordCredential); } // password hook import @@ -233,18 +234,18 @@ else if (userType != null) { PasswordCredentialHook passwordCredentialHook = client.instantiate(PasswordCredentialHook.class); passwordCredentialHook.setType(passwordHookImportType); passwordCredential.setHook(passwordCredentialHook); - createCredentialsIfNeeded(user, client).setPassword(passwordCredential); + createCredentialsIfNeeded(createUserRequest, client).setPassword(passwordCredential); } - return user; + return createUserRequest; } - private UserCredentials createCredentialsIfNeeded(User user, Client client) { - if (user.getCredentials() == null) { + private UserCredentials createCredentialsIfNeeded(CreateUserRequest createUserRequest, Client client) { + if (createUserRequest.getCredentials() == null) { UserCredentials credentials = client.instantiate(UserCredentials.class); - user.setCredentials(credentials); + createUserRequest.setCredentials(credentials); } - return user.getCredentials(); + return createUserRequest.getCredentials(); } public UserBuilder setBcryptPasswordHash(String value, String salt, int workFactor) { diff --git a/impl/src/test/groovy/com/okta/sdk/impl/resource/DefaultUserBuilderTest.groovy b/impl/src/test/groovy/com/okta/sdk/impl/resource/DefaultUserBuilderTest.groovy index 668068fc49e..86b81a05604 100644 --- a/impl/src/test/groovy/com/okta/sdk/impl/resource/DefaultUserBuilderTest.groovy +++ b/impl/src/test/groovy/com/okta/sdk/impl/resource/DefaultUserBuilderTest.groovy @@ -16,19 +16,15 @@ package com.okta.sdk.impl.resource import com.okta.sdk.client.Client -import com.okta.sdk.impl.Util +import com.okta.sdk.resource.user.CreateUserRequest import com.okta.sdk.resource.user.PasswordCredential import com.okta.sdk.resource.user.PasswordCredentialHook -import com.okta.sdk.resource.user.User import com.okta.sdk.resource.user.UserCredentials import com.okta.sdk.resource.user.UserNextLogin import com.okta.sdk.resource.user.UserProfile import org.mockito.ArgumentCaptor import org.testng.annotations.Test -import java.nio.charset.StandardCharsets -import java.security.MessageDigest - import static com.okta.sdk.impl.Util.expect import static org.hamcrest.Matchers.aMapWithSize import static org.hamcrest.Matchers.allOf @@ -45,11 +41,11 @@ class DefaultUserBuilderTest { void basicUsage() { def client = mock(Client) - def user = mock(User) + def createUserRequest = mock(CreateUserRequest) def profile = mock(UserProfile) - when(client.instantiate(User)).thenReturn(user) + when(client.instantiate(CreateUserRequest)).thenReturn(createUserRequest) when(client.instantiate(UserProfile)).thenReturn(profile) - when(user.getProfile()).thenReturn(profile) + when(createUserRequest.getProfile()).thenReturn(profile) new DefaultUserBuilder() .setFirstName("Joe") @@ -58,7 +54,7 @@ class DefaultUserBuilderTest { .setNextLogin(UserNextLogin.CHANGEPASSWORD) .buildAndCreate(client) - verify(client).createUser(eq(user), eq(null), eq(null), eq(UserNextLogin.CHANGEPASSWORD)) + verify(client).createUser(eq(createUserRequest), eq(null), eq(null), eq(UserNextLogin.CHANGEPASSWORD)) verify(profile).setFirstName("Joe") verify(profile).setLastName("Coder") verify(profile).setEmail("joe.coder@example.com") @@ -67,16 +63,16 @@ class DefaultUserBuilderTest { @Test void importPasswordSha256() { def client = mock(Client) - def user = mock(User) + def createUserRequest = mock(CreateUserRequest) def profile = mock(UserProfile) def passwordCredential = mock(PasswordCredential) def userCredentials = mock(UserCredentials) - when(client.instantiate(User)).thenReturn(user) + when(client.instantiate(CreateUserRequest)).thenReturn(createUserRequest) when(client.instantiate(UserProfile)).thenReturn(profile) when(client.instantiate(UserCredentials)).thenReturn(userCredentials) when(client.instantiate(PasswordCredential)).thenReturn(passwordCredential) - when(user.getProfile()).thenReturn(profile) - when(user.getCredentials()).thenReturn(userCredentials) + when(createUserRequest.getProfile()).thenReturn(profile) + when(createUserRequest.getCredentials()).thenReturn(userCredentials) String salt = "some-salt" String hashedPassword = "a-hashed-password" @@ -104,16 +100,16 @@ class DefaultUserBuilderTest { @Test void importPasswordSha512() { def client = mock(Client) - def user = mock(User) + def createUserRequest = mock(CreateUserRequest) def profile = mock(UserProfile) def passwordCredential = mock(PasswordCredential) def userCredentials = mock(UserCredentials) - when(client.instantiate(User)).thenReturn(user) + when(client.instantiate(CreateUserRequest)).thenReturn(createUserRequest) when(client.instantiate(UserProfile)).thenReturn(profile) when(client.instantiate(UserCredentials)).thenReturn(userCredentials) when(client.instantiate(PasswordCredential)).thenReturn(passwordCredential) - when(user.getProfile()).thenReturn(profile) - when(user.getCredentials()).thenReturn(userCredentials) + when(createUserRequest.getProfile()).thenReturn(profile) + when(createUserRequest.getCredentials()).thenReturn(userCredentials) String salt = "some-salt" String hashedPassword = "a-hashed-password" @@ -141,16 +137,16 @@ class DefaultUserBuilderTest { @Test void importPasswordSha1() { def client = mock(Client) - def user = mock(User) + def createUserRequest = mock(CreateUserRequest) def profile = mock(UserProfile) def passwordCredential = mock(PasswordCredential) def userCredentials = mock(UserCredentials) - when(client.instantiate(User)).thenReturn(user) + when(client.instantiate(CreateUserRequest)).thenReturn(createUserRequest) when(client.instantiate(UserProfile)).thenReturn(profile) when(client.instantiate(UserCredentials)).thenReturn(userCredentials) when(client.instantiate(PasswordCredential)).thenReturn(passwordCredential) - when(user.getProfile()).thenReturn(profile) - when(user.getCredentials()).thenReturn(userCredentials) + when(createUserRequest.getProfile()).thenReturn(profile) + when(createUserRequest.getCredentials()).thenReturn(userCredentials) String salt = "some-salt" String hashedPassword = "a-hashed-password" @@ -178,16 +174,16 @@ class DefaultUserBuilderTest { @Test void importPasswordBcrypt() { def client = mock(Client) - def user = mock(User) + def createUserRequest = mock(CreateUserRequest) def profile = mock(UserProfile) def passwordCredential = mock(PasswordCredential) def userCredentials = mock(UserCredentials) - when(client.instantiate(User)).thenReturn(user) + when(client.instantiate(CreateUserRequest)).thenReturn(createUserRequest) when(client.instantiate(UserProfile)).thenReturn(profile) when(client.instantiate(UserCredentials)).thenReturn(userCredentials) when(client.instantiate(PasswordCredential)).thenReturn(passwordCredential) - when(user.getProfile()).thenReturn(profile) - when(user.getCredentials()).thenReturn(userCredentials) + when(createUserRequest.getProfile()).thenReturn(profile) + when(createUserRequest.getCredentials()).thenReturn(userCredentials) String salt = "some-salt" String hashedPassword = "a-hashed-password" @@ -216,16 +212,16 @@ class DefaultUserBuilderTest { void createUserWithClearAndImportPassword() { def client = mock(Client) - def user = mock(User) + def createUserRequest = mock(CreateUserRequest) def profile = mock(UserProfile) def passwordCredential = mock(PasswordCredential) def userCredentials = mock(UserCredentials) - when(client.instantiate(User)).thenReturn(user) + when(client.instantiate(CreateUserRequest)).thenReturn(createUserRequest) when(client.instantiate(UserProfile)).thenReturn(profile) when(client.instantiate(UserCredentials)).thenReturn(userCredentials) when(client.instantiate(PasswordCredential)).thenReturn(passwordCredential) - when(user.getProfile()).thenReturn(profile) - when(user.getCredentials()).thenReturn(userCredentials) + when(createUserRequest.getProfile()).thenReturn(profile) + when(createUserRequest.getCredentials()).thenReturn(userCredentials) String salt = "some-salt" String hashedPassword = "a-hashed-password" @@ -255,18 +251,18 @@ class DefaultUserBuilderTest { void createUserWithUsePasswordHookForImport(String type) { def client = mock(Client) - def user = mock(User) + def createUserRequest = mock(CreateUserRequest) def profile = mock(UserProfile) def passwordCredential = mock(PasswordCredential) def passwordCredentialHook = mock(PasswordCredentialHook) def userCredentials = mock(UserCredentials) - when(client.instantiate(User)).thenReturn(user) + when(client.instantiate(CreateUserRequest)).thenReturn(createUserRequest) when(client.instantiate(UserProfile)).thenReturn(profile) when(client.instantiate(UserCredentials)).thenReturn(userCredentials) when(client.instantiate(PasswordCredential)).thenReturn(passwordCredential) when(client.instantiate(PasswordCredentialHook)).thenReturn(passwordCredentialHook) - when(user.getProfile()).thenReturn(profile) - when(user.getCredentials()).thenReturn(userCredentials) + when(createUserRequest.getProfile()).thenReturn(profile) + when(createUserRequest.getCredentials()).thenReturn(userCredentials) DefaultUserBuilder defaultUserBuilder = new DefaultUserBuilder() .setFirstName("Joe") diff --git a/impl/src/test/groovy/com/okta/sdk/impl/resource/GeneratedResourceTest.groovy b/impl/src/test/groovy/com/okta/sdk/impl/resource/GeneratedResourceTest.groovy index 4ad9266d7af..ed6413f1342 100644 --- a/impl/src/test/groovy/com/okta/sdk/impl/resource/GeneratedResourceTest.groovy +++ b/impl/src/test/groovy/com/okta/sdk/impl/resource/GeneratedResourceTest.groovy @@ -204,7 +204,8 @@ class GeneratedResourceTest { } else if (property instanceof IntegerProperty) { value = 42 } else if (property instanceof DateProperty) { - value = "2001-07-04T12:08:56.235-0700" + value = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") + .parse("2001-07-04T12:08:56.235-0700") } else if (property instanceof MapProperty) { value = [one: "two"] } else if (property instanceof ResourceReference) { diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 8b21d6e6ef5..05887aefb46 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -20,7 +20,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/ApplicationsIT.groovy b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/ApplicationsIT.groovy index 290ae194b01..1cf97ee1020 100644 --- a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/ApplicationsIT.groovy +++ b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/ApplicationsIT.groovy @@ -15,10 +15,7 @@ */ package com.okta.sdk.tests.it -import com.okta.commons.http.DefaultRequest -import com.okta.commons.http.HttpMethod import com.okta.commons.http.MediaType -import com.okta.commons.http.Response import com.okta.sdk.client.Client import com.okta.sdk.impl.ds.DefaultDataStore import com.okta.sdk.resource.Resource @@ -27,12 +24,13 @@ import com.okta.sdk.resource.application.* import com.okta.sdk.resource.group.Group import com.okta.sdk.resource.group.GroupBuilder import com.okta.sdk.resource.user.User +import com.okta.sdk.resource.user.schema.UserSchema +import com.okta.sdk.resource.user.schema.UserSchemaDefinitions +import com.okta.sdk.resource.user.schema.UserSchemaPublic import com.okta.sdk.tests.it.util.ITSupport import org.testng.Assert import org.testng.annotations.Test -import wiremock.net.minidev.json.JSONObject -import java.nio.charset.Charset import javax.xml.parsers.DocumentBuilderFactory import static com.okta.sdk.tests.it.util.Util.assertNotPresent @@ -803,4 +801,89 @@ class ApplicationsIT extends ITSupport { .getNodeValue() assertThat(x509Certificate.isBlank(), is(false)) } + + @Test + void getApplicationUserSchemaTest() { + + Application createdApp = client.instantiate(AutoLoginApplication) + .setLabel("app-${uniqueTestName}") + .setVisibility(client.instantiate(ApplicationVisibility) + .setAutoSubmitToolbar(false) + .setHide(client.instantiate(ApplicationVisibilityHide) + .setIOS(false) + .setWeb(false))) + .setSettings(client.instantiate(AutoLoginApplicationSettings) + .setSignOn(client.instantiate(AutoLoginApplicationSettingsSignOn) + .setRedirectUrl("http://swasecondaryredirecturl.okta.com") + .setLoginUrl("http://swaprimaryloginurl.okta.com"))) + client.createApplication(createdApp) + registerForCleanup(createdApp) + + def userSchema = client.getApplicationUserSchema(createdApp.getId()) + assertThat(userSchema, notNullValue()) + assertThat(userSchema.getName(), notNullValue()) + assertThat(userSchema.getTitle(), notNullValue()) + assertThat(userSchema.getType(), notNullValue()) + assertThat(userSchema.getDefinitions(), notNullValue()) + + def userSchemaBase = userSchema.getDefinitions().getBase() + assertThat(userSchemaBase, notNullValue()) + userSchemaBase.getRequired().forEach({ requiredItem -> + assertThat(userSchemaBase.getProperties().containsKey(requiredItem), equalTo(true)) + }) + } + + @Test + void updateApplicationUserProfileTest() { + + Application createdApp = client.instantiate(AutoLoginApplication) + .setLabel("app-${uniqueTestName}") + .setVisibility(client.instantiate(ApplicationVisibility) + .setAutoSubmitToolbar(false) + .setHide(client.instantiate(ApplicationVisibilityHide) + .setIOS(false) + .setWeb(false))) + .setSettings(client.instantiate(AutoLoginApplicationSettings) + .setSignOn(client.instantiate(AutoLoginApplicationSettingsSignOn) + .setRedirectUrl("http://swasecondaryredirecturl.okta.com") + .setLoginUrl("http://swaprimaryloginurl.okta.com"))) + client.createApplication(createdApp) + registerForCleanup(createdApp) + + def userSchema = client.getApplicationUserSchema(createdApp.getId()) + assertThat(userSchema, notNullValue()) + assertThat(userSchema.getDefinitions(), notNullValue()) + + def app = client.instantiate(UserSchema) + app.setDefinitions(client.instantiate(UserSchemaDefinitions)) + app.getDefinitions().setCustom(client.instantiate(UserSchemaPublic)) + app.getDefinitions().getCustom().setProperties(new LinkedHashMap() { + { + put("twitterUserName", + new LinkedHashMap() { + { + put("title", "Twitter username") + put("description", "Username for twitter.com") + put("type", "string") + put("minLength", 1) + put("maxLength", 20) + } + }) + } + }) + + def updatedUserSchema = client.updateApplicationUserProfile(createdApp.getId(), app) + assertThat(updatedUserSchema, notNullValue()) + assertThat(updatedUserSchema.getDefinitions().getCustom(), notNullValue()) + + def userSchemaPublic = updatedUserSchema.getDefinitions().getCustom() + assertThat(userSchemaPublic.getProperties().containsKey("twitterUserName"), equalTo(true)) + + def customPropertyMap = userSchemaPublic.getProperties().get("twitterUserName") + assertThat(customPropertyMap["title"], equalTo("Twitter username")) + assertThat(customPropertyMap["description"], equalTo("Username for twitter.com")) + assertThat(customPropertyMap["type"], equalTo("string")) + assertThat(customPropertyMap["minLength"], equalTo(1)) + assertThat(customPropertyMap["maxLength"], equalTo(20)) + } } diff --git a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/AuthorizationServerIT.groovy b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/AuthorizationServerIT.groovy index 6b61b63e32a..87a9cca0cfa 100644 --- a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/AuthorizationServerIT.groovy +++ b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/AuthorizationServerIT.groovy @@ -572,7 +572,7 @@ class AuthorizationServerIT extends ITSupport { assertThat(createdPolicyRule, notNullValue()) assertThat(createdPolicyRule.getType(), equalTo(AuthorizationServerPolicyRule.TypeEnum.ACCESS)) - createdPolicyRule.deletePolicyRule(createdAuthorizationServer.getId()) + createdPolicyRule.delete(createdAuthorizationServer.getId()) // delete may not effect immediately in the backend sleep(getTestOperationDelay()) diff --git a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/LinkedObjectsIT.groovy b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/LinkedObjectsIT.groovy index 1faeddcc8a2..38aacccb3e3 100644 --- a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/LinkedObjectsIT.groovy +++ b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/LinkedObjectsIT.groovy @@ -51,7 +51,6 @@ class LinkedObjectsIT extends ITSupport { .setType(LinkedObjectDetailsType.USER) LinkedObject linkedObject = client.instantiate(LinkedObject) - .setName(primary.getName()) .setPrimary(primary) .setAssociated(associated) registerForCleanup(linkedObject) @@ -88,7 +87,6 @@ class LinkedObjectsIT extends ITSupport { .setType(LinkedObjectDetailsType.USER) LinkedObject linkedObject = client.instantiate(LinkedObject) - .setName(primary.getName()) .setPrimary(primary) .setAssociated(associated) registerForCleanup(linkedObject) @@ -127,7 +125,6 @@ class LinkedObjectsIT extends ITSupport { .setType(LinkedObjectDetailsType.USER) LinkedObject linkedObject = client.instantiate(LinkedObject) - .setName(primary.getName()) .setPrimary(primary) .setAssociated(associated) registerForCleanup(linkedObject) @@ -168,7 +165,6 @@ class LinkedObjectsIT extends ITSupport { .setType(LinkedObjectDetailsType.USER) LinkedObject linkedObject1 = client.instantiate(LinkedObject) - .setName(primary1.getName()) .setPrimary(primary1) .setAssociated(associated1) registerForCleanup(linkedObject1) @@ -193,7 +189,6 @@ class LinkedObjectsIT extends ITSupport { .setType(LinkedObjectDetailsType.USER) LinkedObject linkedObject2 = client.instantiate(LinkedObject) - .setName(primary2.getName()) .setPrimary(primary2) .setAssociated(associated2) registerForCleanup(linkedObject2) diff --git a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UserTypesIT.groovy b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UserTypesIT.groovy index 0532578eed9..abd318921cf 100644 --- a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UserTypesIT.groovy +++ b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UserTypesIT.groovy @@ -15,7 +15,8 @@ */ package com.okta.sdk.tests.it -import com.okta.sdk.resource.user.UserType +import com.okta.sdk.resource.user.schema.UserSchema +import com.okta.sdk.resource.user.type.UserType import com.okta.sdk.tests.it.util.ITSupport import org.testng.annotations.Test import wiremock.org.apache.commons.lang3.RandomStringUtils @@ -44,6 +45,23 @@ class UserTypesIT extends ITSupport { assertThat(createdUserType.getId(), notNullValue()) assertThat(createdUserType.getName(), equalTo(name)) + + def schemaId = getSchemaIdForUserType(createdUserType) + assertThat(schemaId, notNullValue()) + + def userSchema = client.getUserSchema(schemaId) + assertThat(userSchema, notNullValue()) + assertThat(userSchema.getLinks(), notNullValue()) + + def userTypeId = getTypeIdFromUserSchema(userSchema) + assertThat(userTypeId, equalTo(createdUserType.getId())) + assertThat(userSchema.getDefinitions(), notNullValue()) + + def userSchemaBase = userSchema.getDefinitions().getBase() + assertThat(userSchemaBase, notNullValue()) + userSchemaBase.getRequired().forEach({ requiredItem -> + assertThat(userSchemaBase.getProperties().containsKey(requiredItem), equalTo(true)) + }) } @Test @@ -81,6 +99,47 @@ class UserTypesIT extends ITSupport { assertThat(createdUserType.getId(), notNullValue()) assertThat(createdUserType.getDisplayName(), equalTo(name + "_updated")) assertThat(createdUserType.getDescription(), equalTo(name + "_test_description_updated")) + + def schemaId = getSchemaIdForUserType(createdUserType) + assertThat(schemaId, notNullValue()) + + def userSchema = client.getUserSchema(schemaId) + assertThat(userSchema, notNullValue()) + + userSchema.getDefinitions().getCustom().getProperties().put("customPropertyName", + new LinkedHashMap() { + { + put("title", "Title of custom property") + put("description", "Description of custom property") + put("type", "string") + put("permissions", new ArrayList() { + { + add( + new LinkedHashMap() { + { + put("principal", "SELF") + put("action", "READ_ONLY") + } + } + ) + } + }) + } + }) + + def updatedUserSchema = client.updateUserProfile(schemaId, userSchema) + assertThat(updatedUserSchema, notNullValue()) + assertThat(updatedUserSchema.getDefinitions().getCustom(), notNullValue()) + + def userSchemaPublic = updatedUserSchema.getDefinitions().getCustom() + assertThat(userSchemaPublic.getProperties().containsKey("customPropertyName"), equalTo(true)) + + def customPropertyMap = userSchemaPublic.getProperties().get("customPropertyName") + assertThat(customPropertyMap["title"], equalTo("Title of custom property")) + assertThat(customPropertyMap["description"], equalTo("Description of custom property")) + assertThat(customPropertyMap["type"], equalTo("string")) + assertThat(customPropertyMap["permissions"][0]["principal"], equalTo("SELF")) + assertThat(customPropertyMap["permissions"][0]["action"], equalTo("READ_ONLY")) } @Test @@ -124,4 +183,35 @@ class UserTypesIT extends ITSupport { assertPresent(client.listUserTypes(), createdUserType1) assertPresent(client.listUserTypes(), createdUserType2) } + + String getSchemaIdForUserType(UserType userType) { + def schema = userType.getLinks().get("schema") + assertThat(schema, notNullValue()) + assertThat(schema instanceof LinkedHashMap, equalTo(true)) + + def schemaHref = (schema as LinkedHashMap).get("href") + assertThat(schemaHref, notNullValue()) + + def schemaId = schemaHref.toString().split("/").last() + assertThat(schemaId, notNullValue()) + + return schemaId + } + + String getTypeIdFromUserSchema(UserSchema userSchema) { + + def type = userSchema.getLinks().get("type") + assertThat(type, notNullValue()) + assertThat(type instanceof LinkedHashMap, equalTo(true)) + + def typeHref = (type as LinkedHashMap).get("href") + assertThat(typeHref, notNullValue()) + + def typeId = typeHref.toString().split("/").last() + assertThat(typeId, notNullValue()) + + return typeId + } + + } diff --git a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UsersIT.groovy b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UsersIT.groovy index e9a85973f19..cf884af81ab 100644 --- a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UsersIT.groovy +++ b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UsersIT.groovy @@ -42,7 +42,7 @@ import com.okta.sdk.resource.user.UserBuilder import com.okta.sdk.resource.user.UserCredentials import com.okta.sdk.resource.user.UserList import com.okta.sdk.resource.user.UserStatus -import com.okta.sdk.resource.user.UserType +import com.okta.sdk.resource.user.type.UserType import com.okta.sdk.tests.Scenario import com.okta.sdk.tests.it.util.ITSupport import org.testng.Assert diff --git a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/ClientProvider.groovy b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/ClientProvider.groovy index 171f03718ae..79272b6138a 100644 --- a/integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/ClientProvider.groovy +++ b/integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/ClientProvider.groovy @@ -186,7 +186,6 @@ trait ClientProvider implements IHookable { toBeDeleted.reverse().each { deletable -> try { if (deletable instanceof User || - deletable instanceof GroupRule || deletable instanceof Application || deletable instanceof AuthorizationServer || deletable instanceof EventHook || @@ -195,9 +194,6 @@ trait ClientProvider implements IHookable { deletable instanceof IdentityProvider) { deletable.deactivate() } - if (deletable instanceof LinkedObject) { - deletable.setName(deletable.getPrimary().getName()) - } deletable.delete() } catch (Exception e) { diff --git a/pom.xml b/pom.xml index ef6d2912aec..a0197ee456e 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT pom Okta Java SDK @@ -39,7 +39,7 @@ 1.26 1.68 0.11.1 - 3.0.3 + 3.1.0 1.2.5 okta/okta-sdk-java @@ -72,27 +72,27 @@ com.okta.sdk okta-sdk-api - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT com.okta.sdk okta-sdk-impl - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT com.okta.sdk okta-api-swagger-templates - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT com.okta.sdk okta-sdk-httpclient - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT com.okta.sdk okta-sdk-okhttp - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT @@ -131,14 +131,14 @@ com.okta.sdk okta-sdk-integration-tests - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT com.okta.sdk okta-sdk-examples-quickstart - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT @@ -316,7 +316,7 @@ com.okta.sdk okta-api-swagger-templates - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT @@ -343,8 +343,8 @@ true - true - true + false + false ${root.dir}/src/japicmp/postAnalysisScript.groovy diff --git a/src/swagger/api.yaml b/src/swagger/api.yaml index 2314befb5a4..13cb0282506 100644 --- a/src/swagger/api.yaml +++ b/src/swagger/api.yaml @@ -25,7 +25,7 @@ info: license: name: Apache-2.0 url: 'http://www.apache.org/licenses/LICENSE-2.0.html' - version: 2.2.1 + version: 2.3.0 externalDocs: description: Find more info here url: 'http://developer.okta.com/docs/api/getting_started/design_principles.html' @@ -3999,6 +3999,59 @@ paths: summary: Fetch a list of events from your Okta organization system log. tags: - Log + '/api/v1/meta/schemas/apps/{appInstanceId}/default': + get: + consumes: + - application/json + description: Fetches the Schema for an App User + operationId: getApplicationUserSchema + parameters: + - in: path + name: appInstanceId + required: true + type: string + produces: + - application/json + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/UserSchema' + security: + - api_token: [] + summary: Fetches the Schema for an App User + tags: + - UserSchema + post: + consumes: + - application/json + description: >- + Partial updates on the User Profile properties of the Application User + Schema. + operationId: updateApplicationUserProfile + parameters: + - in: path + name: appInstanceId + required: true + type: string + - in: body + name: body + schema: + $ref: '#/definitions/UserSchema' + produces: + - application/json + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/UserSchema' + security: + - api_token: [] + summary: >- + Partial updates on the User Profile properties of the Application User + Schema. + tags: + - UserSchema /api/v1/meta/schemas/user/linkedObjects: get: consumes: @@ -4082,6 +4135,55 @@ paths: - api_token: [] tags: - LinkedObject + '/api/v1/meta/schemas/user/{schemaId}': + get: + consumes: + - application/json + description: Fetches the schema for a Schema Id. + operationId: getUserSchema + parameters: + - in: path + name: schemaId + required: true + type: string + produces: + - application/json + responses: + '200': + description: Success + schema: + $ref: '#/definitions/UserSchema' + security: + - api_token: [] + summary: Fetches the schema for a Schema Id. + tags: + - UserSchema + post: + consumes: + - application/json + description: Partial updates on the User Profile properties of the user schema. + operationId: updateUserProfile + parameters: + - in: path + name: schemaId + required: true + type: string + - in: body + name: userSchema + required: true + schema: + $ref: '#/definitions/UserSchema' + produces: + - application/json + responses: + '200': + description: Success + schema: + $ref: '#/definitions/UserSchema' + security: + - api_token: [] + tags: + - UserSchema /api/v1/meta/types/user: get: consumes: @@ -5042,7 +5144,7 @@ paths: name: body required: true schema: - $ref: '#/definitions/User' + $ref: '#/definitions/CreateUserRequest' - default: true description: Executes activation lifecycle operation when creating the user in: query @@ -7160,7 +7262,7 @@ definitions: BOOKMARK: '#/definitions/BookmarkApplication' BROWSER_PLUGIN: '#/definitions/BrowserPluginApplication' OPENID_CONNECT: '#/definitions/OpenIdConnectApplication' - SAML_1_1: '#/definitions/SamlApplicationV1' + SAML_1_1: '#/definitions/SamlApplication' SAML_2_0: '#/definitions/SamlApplication' SECURE_PASSWORD_STORE: '#/definitions/SecurePasswordStoreApplication' WS_FEDERATION: '#/definitions/WsFederationApplication' @@ -7669,12 +7771,14 @@ definitions: - dest: policyId src: id operationId: getAuthorizationServerPolicy - - alias: updatePolicy + - alias: update arguments: - dest: policyId src: id + - dest: policy + self: true operationId: updateAuthorizationServerPolicy - - alias: deletePolicy + - alias: delete arguments: - dest: policyId src: id @@ -7747,12 +7851,12 @@ definitions: - dest: policyId parentSrc: id operationId: updateAuthorizationServerPolicyRule - - alias: deletePolicyRule + - alias: delete arguments: - dest: ruleId src: id - dest: policyId - parentSrc: id + parentSrc: policyId operationId: deleteAuthorizationServerPolicyRule x-okta-operations: - alias: activate @@ -7997,7 +8101,6 @@ definitions: type: $ref: '#/definitions/UserType' type: object - x-okta-parent: '#/definitions/User' x-okta-tags: - User Csr: @@ -8085,11 +8188,20 @@ definitions: properties: supportedMDMFrameworks: items: - $ref: '#/definitions/MDMFrameworks' + enum: + - AFW + - SAFE + - NATIVE + type: string type: array types: items: - $ref: '#/definitions/Platforms' + enum: + - IOS + - ANDROID + - OSX + - WINDOWS + type: string type: array type: object x-okta-tags: @@ -8256,6 +8368,7 @@ definitions: x-okta-tags: - EventHook EventSubscriptions: + discriminator: type properties: items: items: @@ -9024,6 +9137,8 @@ definitions: items: $ref: '#/definitions/InlineHookChannelConfigHeaders' type: array + method: + type: string uri: type: string type: object @@ -9163,42 +9278,42 @@ definitions: readOnly: true type: object alg: - readOnly: true + readOnly: false type: string created: format: date-time - readOnly: true + readOnly: false type: string e: - readOnly: true + readOnly: false type: string expiresAt: format: date-time - readOnly: true + readOnly: false type: string key_ops: items: type: string - readOnly: true + readOnly: false type: array kid: - readOnly: true + readOnly: false type: string kty: - readOnly: true + readOnly: false type: string lastUpdated: format: date-time - readOnly: true + readOnly: false type: string 'n': - readOnly: true + readOnly: false type: string status: - readOnly: true + readOnly: false type: string use: - readOnly: true + readOnly: false type: string x5c: items: @@ -9206,13 +9321,13 @@ definitions: readOnly: false type: array x5t: - readOnly: true + readOnly: false type: string - 'x5t#S256': - readOnly: true + x5t#S256: + readOnly: false type: string x5u: - readOnly: true + readOnly: false type: string type: object x-okta-tags: @@ -9243,8 +9358,6 @@ definitions: type: object readOnly: true type: object - name: - type: string associated: $ref: '#/definitions/LinkedObjectDetails' primary: @@ -9262,7 +9375,7 @@ definitions: - alias: delete arguments: - dest: linkedObjectName - src: name + self: true operationId: deleteLinkedObjectDefinition x-okta-tags: - LinkedObject @@ -9369,6 +9482,7 @@ definitions: LogCredentialProvider: enum: - OKTA_AUTHENTICATION_PROVIDER + - OKTA_CREDENTIAL_PROVIDER - RSA - SYMANTEC - GOOGLE @@ -9631,16 +9745,6 @@ definitions: type: object x-okta-tags: - Policy - MDMFrameworks: - enum: - - authorization_code - - implicit - - password - - refresh_token - - client_credentials - type: string - x-okta-tags: - - Policy OAuth2Actor: properties: id: @@ -9963,7 +10067,7 @@ definitions: properties: people: $ref: '#/definitions/PolicyPeopleCondition' - x-okta-parent: '#/definition/PolicyRuleConditions' + x-okta-parent: '#/definitions/PolicyRuleConditions' x-okta-tags: - Policy OktaSignOnPolicyRule: @@ -10053,6 +10157,17 @@ definitions: type: string x-okta-tags: - Application + OpenIdConnectApplicationIdpInitiatedLogin: + properties: + default_scope: + items: + type: string + type: array + mode: + type: string + type: object + x-okta-tags: + - Application OpenIdConnectApplicationIssuerMode: enum: - CUSTOM_URL @@ -10079,6 +10194,8 @@ definitions: items: $ref: '#/definitions/OAuthGrantType' type: array + idp_initiated_login: + $ref: '#/definitions/OpenIdConnectApplicationIdpInitiatedLogin' initiate_login_uri: type: string issuer_mode: @@ -10240,7 +10357,7 @@ definitions: $ref: '#/definitions/PasswordPolicyAuthenticationProviderCondition' people: $ref: '#/definitions/PolicyPeopleCondition' - x-okta-parent: '#/definition/PolicyRuleConditions' + x-okta-parent: '#/definitions/PolicyRuleConditions' x-okta-tags: - Policy PasswordPolicyDelegationSettings: @@ -10473,15 +10590,6 @@ definitions: type: object x-okta-tags: - Policy - Platforms: - enum: - - IOS - - ANDROID - - OSX - - WINDOWS - type: string - x-okta-tags: - - Policy PlatformConditionEvaluatorPlatform: properties: os: @@ -11049,7 +11157,6 @@ definitions: expiresAt: format: date-time type: string - readOnly: true factorResult: $ref: '#/definitions/FactorResultType' profile: @@ -11230,13 +11337,6 @@ definitions: x-okta-parent: '#/definitions/Application' x-okta-tags: - Application - SamlApplicationV1: - properties: - settings: - $ref: '#/definitions/SamlApplicationSettings' - x-okta-parent: '#/definitions/Application' - x-okta-tags: - - Application SamlApplicationSettings: properties: signOn: @@ -11286,6 +11386,10 @@ definitions: type: boolean signatureAlgorithm: type: string + slo: + $ref: '#/definitions/SingleLogout' + spCertificate: + $ref: '#/definitions/SpCertificate' spIssuer: type: string ssoAcsUrl: @@ -11540,6 +11644,16 @@ definitions: type: string x-okta-tags: - Session + SingleLogout: + properties: + enabled: + type: boolean + issuer: + type: string + logoutUrl: + type: string + x-okta-tags: + - Application SmsTemplate: properties: created: @@ -11642,6 +11756,15 @@ definitions: type: object x-okta-tags: - IdentityProvider + SpCertificate: + properties: + x5c: + items: + type: string + readOnly: false + type: array + x-okta-tags: + - Application SwaApplication: properties: name: @@ -12193,7 +12316,7 @@ definitions: $ref: '#/definitions/VerifyFactorRequest' type: object x-okta-crud: - - alias: deleteFactor + - alias: delete arguments: - dest: factorId src: id @@ -12374,6 +12497,196 @@ definitions: x-okta-extensible: true x-okta-tags: - User + UserSchema: + properties: + $schema: + readOnly: true + type: string + _links: + additionalProperties: + type: object + readOnly: true + type: object + created: + readOnly: true + type: string + definitions: + $ref: '#/definitions/UserSchemaDefinitions' + id: + readOnly: true + type: string + lastUpdated: + readOnly: true + type: string + name: + readOnly: true + type: string + properties: + additionalProperties: + type: object + readOnly: true + type: object + title: + type: string + type: + readOnly: true + type: string + type: object + x-okta-tags: + - UserSchema + UserSchemaAttribute: + properties: + description: + type: string + master: + $ref: '#/definitions/UserSchemaAttributeMaster' + maxLength: + type: integer + minLength: + type: integer + mutability: + type: string + permissions: + items: + $ref: '#/definitions/UserSchemaAttributePermission' + type: array + required: + type: boolean + scope: + type: string + title: + type: string + type: + type: string + type: object + x-okta-tags: + - UserSchema + UserSchemaAttributeMaster: + properties: + type: + type: string + type: object + x-okta-tags: + - UserSchema + UserSchemaAttributePermission: + properties: + action: + type: string + principal: + type: string + type: object + x-okta-tags: + - UserSchema + UserSchemaBase: + properties: + id: + readOnly: true + type: string + properties: + $ref: '#/definitions/UserSchemaBaseProperties' + required: + items: + type: string + type: array + type: + type: string + type: object + x-okta-tags: + - UserSchema + UserSchemaBaseProperties: + properties: + city: + $ref: '#/definitions/UserSchemaAttribute' + costCenter: + $ref: '#/definitions/UserSchemaAttribute' + countryCode: + $ref: '#/definitions/UserSchemaAttribute' + department: + $ref: '#/definitions/UserSchemaAttribute' + displayName: + $ref: '#/definitions/UserSchemaAttribute' + division: + $ref: '#/definitions/UserSchemaAttribute' + email: + $ref: '#/definitions/UserSchemaAttribute' + employeeNumber: + $ref: '#/definitions/UserSchemaAttribute' + firstName: + $ref: '#/definitions/UserSchemaAttribute' + honorificPrefix: + $ref: '#/definitions/UserSchemaAttribute' + honorificSuffix: + $ref: '#/definitions/UserSchemaAttribute' + lastName: + $ref: '#/definitions/UserSchemaAttribute' + locale: + $ref: '#/definitions/UserSchemaAttribute' + login: + $ref: '#/definitions/UserSchemaAttribute' + manager: + $ref: '#/definitions/UserSchemaAttribute' + managerId: + $ref: '#/definitions/UserSchemaAttribute' + middleName: + $ref: '#/definitions/UserSchemaAttribute' + mobilePhone: + $ref: '#/definitions/UserSchemaAttribute' + nickName: + $ref: '#/definitions/UserSchemaAttribute' + organization: + $ref: '#/definitions/UserSchemaAttribute' + postalAddress: + $ref: '#/definitions/UserSchemaAttribute' + preferredLanguage: + $ref: '#/definitions/UserSchemaAttribute' + primaryPhone: + $ref: '#/definitions/UserSchemaAttribute' + profileUrl: + $ref: '#/definitions/UserSchemaAttribute' + secondEmail: + $ref: '#/definitions/UserSchemaAttribute' + state: + $ref: '#/definitions/UserSchemaAttribute' + streetAddress: + $ref: '#/definitions/UserSchemaAttribute' + timezone: + $ref: '#/definitions/UserSchemaAttribute' + title: + $ref: '#/definitions/UserSchemaAttribute' + userType: + $ref: '#/definitions/UserSchemaAttribute' + zipCode: + $ref: '#/definitions/UserSchemaAttribute' + type: object + x-okta-tags: + - UserSchema + UserSchemaDefinitions: + properties: + base: + $ref: '#/definitions/UserSchemaBase' + custom: + $ref: '#/definitions/UserSchemaPublic' + type: object + x-okta-tags: + - UserSchema + UserSchemaPublic: + properties: + id: + readOnly: true + type: string + properties: + additionalProperties: + type: object + type: object + required: + items: + type: string + type: array + type: + type: string + type: object + x-okta-tags: + - UserSchema UserStatus: enum: - ACTIVE @@ -12466,7 +12779,7 @@ definitions: src: id operationId: replaceUserType x-okta-tags: - - User + - UserType VerifyFactorRequest: properties: activationToken: diff --git a/swagger-templates/pom.xml b/swagger-templates/pom.xml index 5856f7b0902..b1c8b54a2e9 100644 --- a/swagger-templates/pom.xml +++ b/swagger-templates/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 3.1.1-SNAPSHOT + 4.0.0-SNAPSHOT okta-api-swagger-templates diff --git a/swagger-templates/src/main/java/com/okta/swagger/codegen/AbstractOktaJavaClientCodegen.java b/swagger-templates/src/main/java/com/okta/swagger/codegen/AbstractOktaJavaClientCodegen.java index a4523c3bbb4..6fd148a60d4 100644 --- a/swagger-templates/src/main/java/com/okta/swagger/codegen/AbstractOktaJavaClientCodegen.java +++ b/swagger-templates/src/main/java/com/okta/swagger/codegen/AbstractOktaJavaClientCodegen.java @@ -210,19 +210,22 @@ protected void buildTopLevelResourceList(Swagger swagger) { protected void buildDiscriminationMap(Swagger swagger) { swagger.getDefinitions().forEach((name, model) -> { - ObjectNode discriminatorMapExtention = (ObjectNode) model.getVendorExtensions().get("x-openapi-v3-discriminator"); - if (discriminatorMapExtention != null) { - - String propertyName = discriminatorMapExtention.get("propertyName").asText(); - ObjectNode mapping = (ObjectNode) discriminatorMapExtention.get("mapping"); - + ObjectNode discriminatorMapExtension = + (ObjectNode) model.getVendorExtensions().get("x-openapi-v3-discriminator"); + if (discriminatorMapExtension != null) { + String propertyName = discriminatorMapExtension.get("propertyName").asText(); + ObjectNode mapping = (ObjectNode) discriminatorMapExtension.get("mapping"); ObjectMapper mapper = new ObjectMapper(); Map result = mapper.convertValue(mapping, Map.class); result = result.entrySet().stream() - .collect(Collectors.toMap(e -> e.getValue().substring(e.getValue().lastIndexOf('/')+1), e -> e.getKey())); - result.forEach((key, value) -> { - reverseDiscriminatorMap.put(key, name); - }); + .collect( + Collectors.toMap( + e -> e.getValue().substring(e.getValue().lastIndexOf('/') + 1), + e -> e.getKey(), + (oldValue, newValue) -> newValue + ) + ); + result.forEach((key, value) -> reverseDiscriminatorMap.put(key, name)); discriminatorMap.put(name, new Discriminator(name, propertyName, result)); } }); @@ -352,8 +355,9 @@ private void handleOktaLinkedOperations(Swagger swagger) { boolean canLinkMethod = true; JsonNode aliasNode = n.get("alias"); + String alias = null; if (aliasNode != null) { - String alias = aliasNode.textValue(); + alias = aliasNode.textValue(); cgOperation.vendorExtensions.put("alias", alias); if ("update".equals(alias)) { @@ -388,6 +392,10 @@ else if ("read".equals(alias) || "create".equals(alias)) { if (model.getProperties() != null) { CodegenProperty cgProperty = fromProperty(paramName, model.getProperties().get(paramName)); + if(cgProperty == null && cgOperation.operationId.equals("deleteLinkedObjectDefinition")) { + cgProperty = new CodegenProperty(); + cgProperty.getter = "getPrimary().getName"; + } param.vendorExtensions.put("fromModel", cgProperty); } else { System.err.println("Model '" + model.getTitle() + "' has no properties"); @@ -415,6 +423,11 @@ else if ("read".equals(alias) || "create".equals(alias)) { } }); + //do not implement interface Deletable when delete method has some arguments + if(alias.equals("delete") && cgParamAllList.size() > 0) { + model.getVendorExtensions().put("deletable", false); + } + if (!pathParents.isEmpty()) { cgOperation.vendorExtensions.put("hasPathParents", true); cgOperation.vendorExtensions.put("pathParents", pathParents); @@ -754,6 +767,11 @@ public CodegenOperation fromOperation(String path, definitions, swagger); + // Deep copy for vendorExtensions Map + Map vendorExtensions = new LinkedHashMap<>(); + co.vendorExtensions.forEach(vendorExtensions::put); + co.vendorExtensions = vendorExtensions; + // scan params for X_OPENAPI_V3_SCHEMA_REF, and _correct_ the param co.allParams.forEach(param -> { if (param.vendorExtensions.containsKey(X_OPENAPI_V3_SCHEMA_REF)) { diff --git a/swagger-templates/src/main/java/com/okta/swagger/codegen/OktaJavaClientImplCodegen.java b/swagger-templates/src/main/java/com/okta/swagger/codegen/OktaJavaClientImplCodegen.java index 3eb1f14f365..fa1b29e7362 100644 --- a/swagger-templates/src/main/java/com/okta/swagger/codegen/OktaJavaClientImplCodegen.java +++ b/swagger-templates/src/main/java/com/okta/swagger/codegen/OktaJavaClientImplCodegen.java @@ -71,15 +71,7 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert String propertyTypeMethod; boolean forceCast = false; - if (property.isEnum || enumList.contains(property.datatype)) { - propertyType = "EnumProperty"; - propertyTypeMethod = "getEnumProperty"; - property.vendorExtensions.put("itemType", property.datatypeWithEnum); - property.vendorExtensions.put("constructorTypeExtra", ", " + property.datatypeWithEnum + ".class"); - property.vendorExtensions.put("typeClassExtra", Boolean.TRUE); - } - else if(property.isListContainer) { - + if(property.isListContainer) { if (property.items.baseType.equals("String")) { propertyType = "ListProperty"; propertyTypeMethod = "getListProperty"; @@ -97,8 +89,13 @@ else if(property.isListContainer) { property.vendorExtensions.put("typeClassExtra", Boolean.TRUE); } forceCast = true; - } - else if(property.isMapContainer || "Object".equals(property.datatype)) { + } else if (property.isEnum || enumList.contains(property.datatype)) { + propertyType = "EnumProperty"; + propertyTypeMethod = "getEnumProperty"; + property.vendorExtensions.put("itemType", property.datatypeWithEnum); + property.vendorExtensions.put("constructorTypeExtra", ", " + property.datatypeWithEnum + ".class"); + property.vendorExtensions.put("typeClassExtra", Boolean.TRUE); + } else if(property.isMapContainer || "Object".equals(property.datatype)) { propertyType = "MapProperty"; propertyTypeMethod = "getMap"; } diff --git a/swagger-templates/src/main/resources/OktaJava/modelInnerEnum.mustache b/swagger-templates/src/main/resources/OktaJava/modelInnerEnum.mustache index 71ca7ea3f2e..e839583b5b0 100644 --- a/swagger-templates/src/main/resources/OktaJava/modelInnerEnum.mustache +++ b/swagger-templates/src/main/resources/OktaJava/modelInnerEnum.mustache @@ -13,36 +13,36 @@ See the License for the specific language governing permissions and limitations under the License. }} - /** - * {{^description}}Enum {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} - */ - public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { - {{#gson}} - {{#allowableValues}} - {{#enumVars}} - @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) - {{{name}}}({{{value}}}){{^-last}}, - {{/-last}}{{#-last}};{{/-last}} - {{/enumVars}} - {{/allowableValues}} - {{/gson}} - {{^gson}} - {{#allowableValues}} - {{#enumVars}} - {{{name}}}({{{value}}}){{^-last}}, - {{/-last}}{{#-last}};{{/-last}} - {{/enumVars}} - {{/allowableValues}} - {{/gson}} + /** + * {{^description}}Enum {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} + */ + public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { + {{#gson}} + {{#allowableValues}} + {{#enumVars}} + @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}} + {{/enumVars}} + {{/allowableValues}} + {{/gson}} + {{^gson}} + {{#allowableValues}} + {{#enumVars}} + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}} + {{/enumVars}} + {{/allowableValues}} + {{/gson}} - private {{{datatype}}} value; + private {{{datatype}}} value; - {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) { - this.value = value; - } + {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) { + this.value = value; + } - @Override - public String toString() { - return String.valueOf(value); + @Override + public String toString() { + return String.valueOf(value); + } } - } diff --git a/swagger-templates/src/main/resources/OktaJava/modelInterface.mustache b/swagger-templates/src/main/resources/OktaJava/modelInterface.mustache index 80b1dbbb987..50fbf77223a 100644 --- a/swagger-templates/src/main/resources/OktaJava/modelInterface.mustache +++ b/swagger-templates/src/main/resources/OktaJava/modelInterface.mustache @@ -22,7 +22,7 @@ import com.okta.sdk.resource.Saveable; /** * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} */ -{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}} +{{>generatedAnnotation}} public interface {{classname}} extends ExtensibleResource{{#parent}}, {{.}}{{/parent}}{{#vendorExtensions.x-okta-extensible}}, PropertyRetriever, Map{{/vendorExtensions.x-okta-extensible}}{{#vendorExtensions.deletable}}, Deletable{{/vendorExtensions.deletable}} { {{#vars}} @@ -37,13 +37,13 @@ public interface {{classname}} extends ExtensibleResource{{#parent}}, {{.}}{{/pa {{#isEnum}} {{^isContainer}} - {{>modelInnerEnum}} +{{>modelInnerEnum}} {{/isContainer}} {{/isEnum}} {{#items.isEnum}} {{#items}} {{^isContainer}} - {{>modelInnerEnum}} +{{>modelInnerEnum}} {{/isContainer}} {{/items}} {{/items.isEnum}} diff --git a/swagger-templates/src/main/resources/OktaJava/modelListResourceInterface.mustache b/swagger-templates/src/main/resources/OktaJava/modelListResourceInterface.mustache index 39400c30979..ddf38b1cbf0 100644 --- a/swagger-templates/src/main/resources/OktaJava/modelListResourceInterface.mustache +++ b/swagger-templates/src/main/resources/OktaJava/modelListResourceInterface.mustache @@ -19,5 +19,5 @@ import com.okta.sdk.resource.CollectionResource; /** * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} */ -{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}} +{{>generatedAnnotation}} public interface {{classname}} extends CollectionResource<{{vendorExtensions.baseType}}> {} diff --git a/swagger-templates/src/main/resources/OktaJavaImpl/modelImpl.mustache b/swagger-templates/src/main/resources/OktaJavaImpl/modelImpl.mustache index 2b98a535b00..d3e10d78643 100644 --- a/swagger-templates/src/main/resources/OktaJavaImpl/modelImpl.mustache +++ b/swagger-templates/src/main/resources/OktaJavaImpl/modelImpl.mustache @@ -54,7 +54,7 @@ import static com.okta.commons.lang.Assert.hasText; public class Default{{classname}} extends {{#parent}}{{.}}{{/parent}}{{^parent}}{{#vendorExtensions.top-level}}AbstractInstanceResource<{{classname}}>{{/vendorExtensions.top-level}}{{^vendorExtensions.top-level}}AbstractResource{{/vendorExtensions.top-level}}{{/parent}} implements {{classname}} { {{#vars}} - private final static {{vendorExtensions.propertyType}}{{#vendorExtensions.itemType}}<{{{vendorExtensions.itemType}}}>{{/vendorExtensions.itemType}} {{name}}Property = new {{vendorExtensions.propertyType}}("{{baseName}}"{{vendorExtensions.constructorTypeExtra}}); + private final static {{vendorExtensions.propertyType}}{{#vendorExtensions.itemType}}<{{{vendorExtensions.itemType}}}>{{/vendorExtensions.itemType}} {{name}}Property = new {{vendorExtensions.propertyType}}("{{baseName}}"{{{vendorExtensions.constructorTypeExtra}}}); {{/vars}} private final static Map PROPERTY_DESCRIPTORS = createPropertyDescriptorMap({{#vars}}{{name}}Property{{^-last}}, {{/-last}}{{/vars}});