Skip to content

Commit

Permalink
fix: empty user status not handled
Browse files Browse the repository at this point in the history
  • Loading branch information
rickycpadilla committed May 6, 2024
1 parent bb498ef commit 2434541
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 20 additions & 2 deletions passage/fix_generated_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,26 @@
# User model requires `webauthn_types` property, but webauthn start returns user WITHOUT it, so we must make it optional.
(
'./generated/src/main/kotlin/id/passage/android/model/User.kt',
'val webauthnTypes: kotlin.collections.List<WebAuthnType>',
'val webauthnTypes: kotlin.collections.List<WebAuthnType>?'
'''val webauthnTypes: kotlin.collections.List<WebAuthnType>
''',
'''val webauthnTypes: kotlin.collections.List<WebAuthnType>?
'''
),

# Some endpoints return a user with a status set to "". This is incompatible with the spec, so we have to add the statusUnavailable option.
(
'./generated/src/main/kotlin/id/passage/android/model/UserStatus.kt',
'''@Json(name = "pending")
pending("pending");
''',
'''@Json(name = "pending")
pending("pending"),
@Json(name = "")
statusUnavailable("");
'''
),

# Add more replacements here as needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ enum class UserStatus(val value: kotlin.String) {
inactive("inactive"),

@Json(name = "pending")
pending("pending");
pending("pending"),

@Json(name = "")
statusUnavailable("");

/**
* Override toString() to avoid using the enum variable name as the value, and instead use
* the actual value defined in the API spec file.
Expand Down

0 comments on commit 2434541

Please sign in to comment.