Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Reasons to choose format of "guid" over "uuid" for string? #1322

Closed
martin-shields-sage opened this issue Feb 23, 2021 · 5 comments · Fixed by #1325
Closed

Question: Reasons to choose format of "guid" over "uuid" for string? #1322

martin-shields-sage opened this issue Feb 23, 2021 · 5 comments · Fixed by #1325

Comments

@martin-shields-sage
Copy link
Contributor

I have a question, I see that the JsonFormatStrings has an obsolete value for UUID and states to use GUID instead as uuid is redundant. However, if I have a JSON schema of..

"SubType" : {
              "type": "object",
              "properties": {
                "Id": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "required": [
                "Id"
              ]
            }
...

This does not get validated as a UUID or GUID type when running the validation against this schema without putting a new custom validator in to add UUID. Was there any reason why this was made redundant? When I look at the JSON schema specification I still see links to UUID being there - https://json-schema.org/draft/2020-12/json-schema-validation.html

@RicoSuter
Copy link
Owner

I think even if UUID is obsolete we should support it in the validator:
https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema/Validation/JsonSchemaValidator.cs#L28

@martin-shields-sage
Copy link
Contributor Author

martin-shields-sage commented Feb 23, 2021

I think even if UUID is obsolete we should support it in the validator:
https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema/Validation/JsonSchemaValidator.cs#L28

I would agree, it looks like the line which you have highlighted does not validate the example I have provided above (being a uuid instead of GUID)?

@martin-shields-sage
Copy link
Contributor Author

Would you suggest that we add a new format validator to the list based on https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema/Validation/JsonSchemaValidator.cs#L28?

@RicoSuter
Copy link
Owner

Would you suggest that we add a new format validator to the list based on

Yes. Can you create a PR?

@martin-shields-sage
Copy link
Contributor Author

Would you suggest that we add a new format validator to the list based on

Yes. Can you create a PR?

Sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants