Skip to content

Commit

Permalink
Rework polymorphic deserialization to use built-in support in OpenAPI…
Browse files Browse the repository at this point in the history
… generator (#957)

* Rework polymorphic deserialization to use built-in support in OpenAPI generator (#948)

Rework polymorphic deserialization
- Add required code in pojo.mustache (copied from current version of OpenAPI generator) to add polymorphic annotations to model classes
- Remove now useless custom deserializers, *ApiHelper classes and HelperUtil
- Update README with modified snippets

Co-authored-by: Arvind Krishnakumar <61501885+arvindkrishnakumar-okta@users.noreply.github.com>

* Fix ITs

* minor updates

---------

Co-authored-by: Clément Denis <clement.denis@gmail.com>
  • Loading branch information
arvindkrishnakumar-okta and clementdenis authored Nov 7, 2023
1 parent b8578c5 commit 8e5bbca
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 953 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,47 +366,47 @@ UserFactor userFactor = userFactorApi.getFactor("userId", "factorId");

[//]: # (method: enrollUserInFactor)
```java
UserFactorApiHelper<UserFactor> userFactorApiHelper = new UserFactorApiHelper<>(new UserFactorApi(client));
UserFactorApi userFactorApi = new UserFactorApi(client);
SmsUserFactorProfile smsUserFactorProfile = new SmsUserFactorProfile();
smsUserFactorProfile.setPhoneNumber("555 867 5309");
SmsUserFactor smsUserFactor = new SmsUserFactor();
smsUserFactor.setProvider(FactorProvider.OKTA);
smsUserFactor.setFactorType(FactorType.SMS);
smsUserFactor.setProfile(smsUserFactorProfile);
userFactorApiHelper.enrollFactorOfType(SmsUserFactor.class, "userId", smsUserFactor, true, "templateId", 30, true);
userFactorApi.enrollFactor("userId", smsUserFactor, true, "templateId", 30, true);
```
[//]: # (end: enrollUserInFactor)

### Activate a Factor

[//]: # (method: activateFactor)
```java
UserFactorApiHelper<UserFactor> userFactorApiHelper = new UserFactorApiHelper<>(new UserFactorApi(client));
CallUserFactor userFactor = (CallUserFactor) userFactorApiHelper.getFactor("userId", "factorId");
UserFactorApi userFactorApi = new UserFactorApi(client);
CallUserFactor userFactor = (CallUserFactor) userFactorApi.getFactor("userId", "factorId");
ActivateFactorRequest activateFactorRequest = new ActivateFactorRequest();
activateFactorRequest.setPassCode("123456");
userFactorApiHelper.activateFactorOfType(CallUserFactor.class, "userId", "factorId", activateFactorRequest);
userFactorApi.activateFactor("userId", "factorId", activateFactorRequest);
```
[//]: # (end: activateFactor)

### Verify a Factor

[//]: # (method: verifyFactor)
```java
UserFactorApiHelper<UserFactor> userFactorApiHelper = new UserFactorApiHelper<>(new UserFactorApi(client));
UserFactor userFactor = userFactorApiHelper.getFactor( "userId", "factorId");
UserFactorApi userFactorApi = new UserFactorApi(client);
UserFactor userFactor = userFactorApi.getFactor( "userId", "factorId");
VerifyFactorRequest verifyFactorRequest = new VerifyFactorRequest();
verifyFactorRequest.setPassCode("123456");
VerifyUserFactorResponse verifyUserFactorResponse =
userFactorApiHelper.verifyFactor("userId", "factorId", "templateId", 10, "xForwardedFor", "userAgent", "acceptLanguage", verifyFactorRequest);
userFactorApi.verifyFactor("userId", "factorId", "templateId", 10, "xForwardedFor", "userAgent", "acceptLanguage", verifyFactorRequest);
```
[//]: # (end: verifyFactor)

### Create a SWA Application

[//]: # (method: createSwaApplication)
```java
ApplicationApiHelper<Application> applicationApiHelper = new ApplicationApiHelper<>(new ApplicationApi(client));
ApplicationApi applicationApi = new ApplicationApi(client);
SwaApplicationSettingsApplication swaApplicationSettingsApplication = new SwaApplicationSettingsApplication();
swaApplicationSettingsApplication.buttonField("btn-login")
.passwordField("txtbox-password")
Expand All @@ -421,7 +421,7 @@ browserPluginApplication.settings(swaApplicationSettings);

// create BrowserPluginApplication app type
BrowserPluginApplication createdApp =
applicationApiHelper.createApplicationOfType(BrowserPluginApplication.class, browserPluginApplication, true, null);
(BrowserPluginApplication) applicationApi.createApplication(browserPluginApplication, true, null);
```
[//]: # (end: createSwaApplication)

Expand Down
137 changes: 0 additions & 137 deletions api/src/main/java/com/okta/sdk/helper/ApplicationApiHelper.java

This file was deleted.

160 changes: 0 additions & 160 deletions api/src/main/java/com/okta/sdk/helper/HelperUtil.java

This file was deleted.

Loading

0 comments on commit 8e5bbca

Please sign in to comment.