Skip to content

Commit

Permalink
fix: schemas encoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 23, 2024
1 parent 60e13b9 commit 3a1503c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions internal/client-go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
2 changes: 1 addition & 1 deletion internal/client-go/model_identity_schema_container.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/httpclient/model_identity_schema_container.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion schema/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ func (h *Handler) RegisterAdminRoutes(admin *x.RouterAdmin) {
//lint:ignore U1000 Used to generate Swagger and OpenAPI definitions
type identitySchema json.RawMessage

func (m identitySchema) MarshalJSON() ([]byte, error) {
return json.RawMessage(m).MarshalJSON()
}

func (m *identitySchema) UnmarshalJSON(data []byte) error {
mm := json.RawMessage(*m)
return mm.UnmarshalJSON(data)
}

// Get Identity JSON Schema Response
//
// swagger:parameters getIdentitySchema
Expand Down Expand Up @@ -151,7 +160,7 @@ type identitySchemaContainer struct {
// The ID of the Identity JSON Schema
ID string `json:"id"`
// The actual Identity JSON Schema
Schema identitySchema `json:"schema"`
Schema json.RawMessage `json:"schema"`
}

// List Identity JSON Schemas Response
Expand Down
2 changes: 1 addition & 1 deletion schema/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestHandler(t *testing.T) {
body := getFromTSPaginated(t, 0, 2, http.StatusOK)

var result []client.IdentitySchemaContainer
require.NoError(t, json.Unmarshal(body, &result))
require.NoError(t, json.Unmarshal(body, &result), "%s", body)

ids_orig := []string{}
for _, s := range schemas {
Expand Down
3 changes: 2 additions & 1 deletion spec/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,8 @@
"type": "string"
},
"schema": {
"$ref": "#/components/schemas/identitySchema"
"description": "The actual Identity JSON Schema",
"type": "object"
}
},
"type": "object"
Expand Down
3 changes: 2 additions & 1 deletion spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4319,7 +4319,8 @@
"type": "string"
},
"schema": {
"$ref": "#/definitions/identitySchema"
"description": "The actual Identity JSON Schema",
"type": "object"
}
}
},
Expand Down

0 comments on commit 3a1503c

Please sign in to comment.