Yelp / bravado-core

Other
109 stars 98 forks source link

uuid format is not registered with bravado-core #376

Closed mrmaxformax closed 4 years ago

mrmaxformax commented 4 years ago

Hello, Got the warning: "uuid format is not registered with bravado-core" it's not critical issue but could you pls add the uuid not the next release? I added it based on the description and the Warning gone but not sure if it is 100% correct. May I ask you to check and help to fix (if it is incorrect)

class UUIDFormat:
    def __init__(self, uuid):
        self.uuid = uuid

def validate_uuid(uuid):
    try:
        UUID(uuid)
     except SwaggerValidationError:
         LOG.debug(f"UUID {uuid} is invalid")
         raise SwaggerValidationError

uuid_format = SwaggerFormat(format='uuid', 
    to_wire=lambda uuid_object: uuid_object.uuid,
    to_python=lambda uuid_str: UUIDFormat(uuid_str),
    validate=validate_uuid, description='validate UUID')

Thanks!

sjaensch commented 4 years ago

It looks correct to me, but you should be able to make sure it is correct by adding appropriate tests to your project.

le91688 commented 1 year ago

Was UUID ever added? I get this warning using bravado 11.0.3