Skip to content

Commit

Permalink
maintain: use json tag for property names
Browse files Browse the repository at this point in the history
BREAKING CHANGE: change LoginResponse polymorphicId to polymorphicID
  • Loading branch information
mxyng committed Apr 5, 2022
1 parent 7cd72d7 commit 5fa6413
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions api/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ type LoginRequestOIDC struct {

type LoginRequestPasswordCredentials struct {
Email string `json:"email" validate:"required"`
Password string `json:"password" validate:"required"`
Password string `json:"password" validate:"required"`
}

type LoginRequest struct {
OIDC *LoginRequestOIDC `json:"oidc" validate:"excluded_with=KeyExchange,excluded_with=PasswordCredentials"`
AccessKey string `json:"accessKey" validate:"excluded_with=OIDC,excluded_with=PasswordCredentials"`
AccessKey string `json:"accessKey" validate:"excluded_with=OIDC,excluded_with=PasswordCredentials"`
PasswordCredentials *LoginRequestPasswordCredentials `json:"passwordCredentials" validate:"excluded_with=OIDC,excluded_with=AccessKey"`
OIDC *LoginRequestOIDC `json:"oidc" validate:"excluded_with=KeyExchange,excluded_with=PasswordCredentials"`
}

type LoginResponse struct {
PolymorphicID uid.PolymorphicID `json:"polymorphicId"`
PolymorphicID uid.PolymorphicID `json:"polymorphicID"`
Name string `json:"name"`
AccessKey string `json:"accessKey"`
PasswordUpdateRequired bool `json:"passwordUpdateRequired,omitempty"`
Expand Down
28 changes: 14 additions & 14 deletions docs/api/openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@
"properties": {
"connection": {
"properties": {
"CA": {
"ca": {
"example": "-----BEGIN CERTIFICATE-----\nMIIDNTCCAh2gAwIBAgIRALRetnpcTo9O3V2fAK3ix+c\n-----END CERTIFICATE-----\n",
"type": "string"
},
"URL": {
"url": {
"example": "aa60eexample.us-west-2.elb.amazonaws.com",
"type": "string"
}
Expand Down Expand Up @@ -173,13 +173,13 @@
"fieldErrors": {
"items": {
"properties": {
"Errors": {
"errors": {
"items": {
"type": "string"
},
"type": "array"
},
"FieldName": {
"fieldName": {
"type": "string"
}
},
Expand Down Expand Up @@ -344,7 +344,7 @@
"passwordUpdateRequired": {
"type": "boolean"
},
"polymorphicId": {
"polymorphicID": {
"example": "i:4yJ3n3D8E3",
"format": "poly-uid",
"pattern": "\\w:[\\da-zA-HJ-NP-Z]{1,11}",
Expand Down Expand Up @@ -805,11 +805,11 @@
"properties": {
"connection": {
"properties": {
"CA": {
"ca": {
"example": "-----BEGIN CERTIFICATE-----\nMIIDNTCCAh2gAwIBAgIRALRetnpcTo9O3V2fAK3ix+c\n-----END CERTIFICATE-----\n",
"type": "string"
},
"URL": {
"url": {
"example": "aa60eexample.us-west-2.elb.amazonaws.com",
"type": "string"
}
Expand Down Expand Up @@ -1095,11 +1095,11 @@
"properties": {
"connection": {
"properties": {
"CA": {
"ca": {
"example": "-----BEGIN CERTIFICATE-----\nMIIDNTCCAh2gAwIBAgIRALRetnpcTo9O3V2fAK3ix+c\n-----END CERTIFICATE-----\n",
"type": "string"
},
"URL": {
"url": {
"example": "aa60eexample.us-west-2.elb.amazonaws.com",
"type": "string"
}
Expand Down Expand Up @@ -2667,16 +2667,16 @@
},
"oidc": {
"properties": {
"Code": {
"code": {
"type": "string"
},
"ProviderID": {
"providerID": {
"example": "4yJ3n3D8E2",
"format": "uid",
"pattern": "[\\da-zA-HJ-NP-Z]{1,11}",
"type": "string"
},
"RedirectURL": {
"redirectURL": {
"type": "string"
}
},
Expand All @@ -2689,10 +2689,10 @@
},
"passwordCredentials": {
"properties": {
"Email": {
"email": {
"type": "string"
},
"Password": {
"password": {
"type": "string"
}
},
Expand Down
2 changes: 1 addition & 1 deletion internal/server/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func buildProperty(f reflect.StructField, t, parent reflect.Type, parentSchema *

for i := 0; i < t.NumField(); i++ {
f2 := t.Field(i)
s.Properties[f2.Name] = buildProperty(f2, f2.Type, t, s)
s.Properties[getFieldName(f2, t)] = buildProperty(f2, f2.Type, t, s)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/store/AuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const AuthContextProvider = ({ children }) => {

const redirectToDashboard = async (loginInfor) => {
setUser({
id: loginInfor.polymorphicId,
id: loginInfor.polymorphicID,
name: loginInfor.name
})
setAuthReady(true)
Expand Down

0 comments on commit 5fa6413

Please sign in to comment.