to-json-schema
to-json-schema copied to clipboard
Added support for format uuid.
This PR adds support for string typed format uuid
. As it is a widely used format, it would help a lot if present.
Let me know if there is a problem with uuid
regex.
Coverage remained the same at 97.929% when pulling 88ac339f6558ceff9e4459bfb02265cccdee3631 on VShingala:feature/support-format-uuid into bc6a31b939493ba2e363eebeb25663e7910696c2 on ruzicka:master.
Coverage remained the same at 97.929% when pulling 88ac339f6558ceff9e4459bfb02265cccdee3631 on VShingala:feature/support-format-uuid into bc6a31b939493ba2e363eebeb25663e7910696c2 on ruzicka:master.
As far as I know, JSON schema specification doesn't include uuid format. Adding uuid support here would result in generation of invalid schema. I guess there are some validators out there that might support it but on the other hand there might be some that doesn't.
@ruzicka Thanks for the awesome repo and reply 😄 . It's true that JSON schema doesn't support uuid
as a format. I thought that as module is already supporting other formats which are also not supported by JSON schema like utc-millisec
, color
, style
, phone
etc. (Source correct me if I wrong here)
Let me know also if we can somehow use the options for uuid
support. And keep the default generation of the schema as is.
@VShingala Hmm, you're right 🤔 If I'm not mistaken I took those from https://github.com/tdegrunt/jsonschema and didn't verify that these format options are actually in specification. On the other hand, I just take a look into specification again and it seems they specify that implementations should not fail if unknown format option is used:
Implementations MAY support custom format attributes. Save for agreement between parties, schema authors SHALL NOT expect a peer implementation to support such custom format attributes. An implementation MUST NOT fail validation or cease processing due to an unknown format attribute.
Let me gather some more info on this first, but it seems it should be possible to support it.
Thanks for bringing this up 👍
@ruzicka Sure, let me know if any changes are required after your research.