Skip to content

"format" should accept any value #41

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

Closed
yohanboniface opened this issue May 29, 2018 · 2 comments
Closed

"format" should accept any value #41

yohanboniface opened this issue May 29, 2018 · 2 comments

Comments

@yohanboniface
Copy link

Hi,

According to the spec, "format" should accept any value:

However, to support documentation needs, the format property is an open string-valued property, and can have any value. Formats such as "email", "uuid", and so on, MAY be used even though undefined by this specification. Types that are not accompanied by a format property follow the type definition in the JSON Schema. Tools that do not recognize a specific format MAY default back to the type alone, as if the format is not specified.

However, this will raise: ValueError: 'custom' is not a valid SchemaFormat

from openapi_core import create_spec


schema = {
    "components": {
        "schemas": {
            "Foo": {
                "type": "object",
                "properties": {
                    "propname": {
                        "type": "string",
                        "format": "custom"
                    }
                }
            }
        }
    },
    "info": {
        "title": "xxx",
        "version": "1.0.0"
    },
    "openapi": "3.0.0",
    "paths": {
        "/simulate": {
            "get": {
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Foo"
                                }
                            }
                        },
                        "description": "OK"
                    }
                }
            }
        }
    }
}


spec = create_spec(schema)

Am I missing something?

Thanks! :)

@p1c2u
Copy link
Collaborator

p1c2u commented May 30, 2018

@yohanboniface Yup, you're right. Thanks for the report.

@yohanboniface
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants