Skip to content

Commit

Permalink
fix: make courier.TemplateType an enum (ory#2875)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Nov 8, 2022
1 parent 35ad72d commit 148ee73
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
7 changes: 5 additions & 2 deletions courier/email_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
)

type (
TemplateType string

EmailTemplate interface {
json.Marshaler
EmailSubject(context.Context) (string, error)
Expand All @@ -23,6 +21,11 @@ type (
}
)

// A Template's type
//
// swagger:enum TemplateType
type TemplateType string

const (
TypeRecoveryInvalid TemplateType = "recovery_invalid"
TypeRecoveryValid TemplateType = "recovery_valid"
Expand Down
22 changes: 19 additions & 3 deletions internal/httpclient/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3649,8 +3649,6 @@ components:
title: RecoveryAddressType must not exceed 16 characters as that is the limitation
in the SQL Schema.
type: string
TemplateType:
type: string
Time:
format: date-time
type: string
Expand Down Expand Up @@ -4297,7 +4295,7 @@ components:
recipient: recipient
created_at: 2000-01-23T04:56:07.000+00:00
send_count: 0
template_type: template_type
template_type: recovery_invalid
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
body: body
properties:
Expand All @@ -4320,7 +4318,25 @@ components:
subject:
type: string
template_type:
enum:
- recovery_invalid
- recovery_valid
- recovery_code_invalid
- recovery_code_valid
- verification_invalid
- verification_valid
- otp
- stub
type: string
x-go-enum-desc: |-
recovery_invalid TypeRecoveryInvalid
recovery_valid TypeRecoveryValid
recovery_code_invalid TypeRecoveryCodeInvalid
recovery_code_valid TypeRecoveryCodeValid
verification_invalid TypeVerificationInvalid
verification_valid TypeVerificationValid
otp TypeOTP
stub TypeTestStub
type:
$ref: '#/components/schemas/courierMessageType'
updated_at:
Expand Down
16 changes: 12 additions & 4 deletions spec/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,6 @@
"title": "RecoveryAddressType must not exceed 16 characters as that is the limitation in the SQL Schema.",
"type": "string"
},
"TemplateType": {
"type": "string"
},
"Time": {
"format": "date-time",
"type": "string"
Expand Down Expand Up @@ -940,7 +937,18 @@
"type": "string"
},
"template_type": {
"$ref": "#/components/schemas/TemplateType"
"enum": [
"recovery_invalid",
"recovery_valid",
"recovery_code_invalid",
"recovery_code_valid",
"verification_invalid",
"verification_valid",
"otp",
"stub"
],
"type": "string",
"x-go-enum-desc": "recovery_invalid TypeRecoveryInvalid\nrecovery_valid TypeRecoveryValid\nrecovery_code_invalid TypeRecoveryCodeInvalid\nrecovery_code_valid TypeRecoveryCodeValid\nverification_invalid TypeVerificationInvalid\nverification_valid TypeVerificationValid\notp TypeOTP\nstub TypeTestStub"
},
"type": {
"$ref": "#/components/schemas/courierMessageType"
Expand Down
16 changes: 12 additions & 4 deletions spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3059,9 +3059,6 @@
"type": "string",
"title": "RecoveryAddressType must not exceed 16 characters as that is the limitation in the SQL Schema."
},
"TemplateType": {
"type": "string"
},
"UUID": {"type": "string", "format": "uuid4"},
"adminCreateIdentityBody": {
"type": "object",
Expand Down Expand Up @@ -3641,7 +3638,18 @@
"type": "string"
},
"template_type": {
"$ref": "#/definitions/TemplateType"
"type": "string",
"enum": [
"recovery_invalid",
"recovery_valid",
"recovery_code_invalid",
"recovery_code_valid",
"verification_invalid",
"verification_valid",
"otp",
"stub"
],
"x-go-enum-desc": "recovery_invalid TypeRecoveryInvalid\nrecovery_valid TypeRecoveryValid\nrecovery_code_invalid TypeRecoveryCodeInvalid\nrecovery_code_valid TypeRecoveryCodeValid\nverification_invalid TypeVerificationInvalid\nverification_valid TypeVerificationValid\notp TypeOTP\nstub TypeTestStub"
},
"type": {
"$ref": "#/definitions/courierMessageType"
Expand Down

0 comments on commit 148ee73

Please sign in to comment.