mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
Add Workaround for inconsistent API Response
This commit is contained in:
parent
360cc3748e
commit
e13f484bcb
2 changed files with 22 additions and 7 deletions
|
@ -41,7 +41,22 @@ func validateSecretData(rType *api.ResourceType, secretData string) error {
|
|||
var schemaDefinition api.ResourceTypeSchema
|
||||
err := json.Unmarshal([]byte(rType.Definition), &schemaDefinition)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unmarshal Json Schema: %w", err)
|
||||
// Workaround for inconsistant API Responses where sometime the Schema is embedded directly and sometimes it's escaped as a string
|
||||
if err.Error() == "json: cannot unmarshal string into Go value of type api.ResourceTypeSchema" {
|
||||
var tmp string
|
||||
err = json.Unmarshal([]byte(rType.Definition), &tmp)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Workaround Unmarshal Json Schema String: %w", err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(tmp), &schemaDefinition)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Workaround Unmarshal Json Schema: %w", err)
|
||||
}
|
||||
|
||||
} else {
|
||||
return fmt.Errorf("Unmarshal Json Schema: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
comp := jsonschema.NewCompiler()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue