s-knibbs / dataclasses-jsonschema

JSON schema generation from dataclasses
MIT License
166 stars 38 forks source link

UUID field validation fails when using latest fastjsonschema release #106

Open s-knibbs opened 4 years ago

s-knibbs commented 4 years ago

It seems the latest release of fastjsonschema now raises an error when using custom string formats:

            elif format_ == 'regex':
                with self.l('try:'):
                    self.l('re.compile({variable})')
                with self.l('except Exception:'):
                    self.exc('{name} must be a valid regex', rule='format')
            else:
>               raise JsonSchemaDefinitionException('Unknown format: {}'.format(format_))
E               fastjsonschema.exceptions.JsonSchemaDefinitionException: Unknown format: uuid

For now, the dependency can be pinned. But it looks like custom formats have to be passed explicitly to the compile schema function.

Garito commented 4 years ago

My opinion on this: I guess that fastjsonschema is about performace cause it is not for convenience (it stops on the 1st error making useless to mark the errors in a form) Perhaps is time to open views to other libraries like https://github.com/p1c2u/openapi-spec-validator?