Skip to content
\n

and

\n
  type: string\n  pattern: '^.+$'\n\n
\n

But the unmarshaller ignores these specifications.

\n

I upgraded to 0.19.0a1 to add a custom validator, per https://openapi-core.readthedocs.io/_/downloads/en/latest/pdf/ by @p1c2u Artur Maciag but his example doesn't seem to do anything:

\n
    from datetime import datetime\n\n    def unmarshal_usdate(value):\n        return datetime.strptime(value, \"%m/%d/%y\").date\n\n    extra_format_unmarshallers = {\n        \"usdate\": unmarshal_usdate,\n    }\n\n    def validate_usdate(value):\n        return bool(re.match(r\"^\\d{1,2}/\\d{1,2}/\\d{4}$\", value))\n\n    extra_format_validators = {\n        \"usdate\": validate_usdate,\n    }\n\n    config = Config(\n        extra_format_validators=extra_format_validators,\n        extra_format_unmarshallers=extra_format_unmarshallers,\n    )\n\n    return OpenAPI.from_file_path(spec_file_path, config=config)\n\n
\n

The unmarshaller for the YAML:

\n
                test:\n                    type: string\n                    description: Test\n                    format: usdate\n\n
\n

Happily returns:

\n
RequestUnmarshalResult(errors=[], body={'test': 'not a date', 'description': 'A multiple choice activity focusing on synonyms', 'binary_result': True, 'directionality': 'passive', 'modality': 'text', 'interaction_type': 'match', 'activity_context': 'synonym', 'activity_visibility': 'public', 'activity_type_name': 'ok ok ok'}, parameters=Parameters(query={}, header={}, cookie={}, path={}), security={})\n
\n

tldr; it would be nice to get this custom validator working, but can anyone give me a workaround in the meantime to make sure a string isn't blank?

\n

Thanks,
\nHeidi

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Hi @heidiLinguist

\n

thanks for the report, I prepared fix for that. It's part of 0.19.0a2 version

","upvoteCount":2,"url":"https://github.com/python-openapi/openapi-core/discussions/778#discussioncomment-8431590"}}}
Discussion options

You must be logged in to vote

Hi @heidiLinguist

thanks for the report, I prepared fix for that. It's part of 0.19.0a2 version

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@heidiLinguist
Comment options

Answer selected by p1c2u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants