Skip to content
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

Support for format 'email' #204

Closed
laurentkvb opened this issue Oct 13, 2020 · 9 comments
Closed

Support for format 'email' #204

laurentkvb opened this issue Oct 13, 2020 · 9 comments
Assignees

Comments

@laurentkvb
Copy link

laurentkvb commented Oct 13, 2020

Will there be support for email being supported for the format field?

Like described here it is an open value: https://swagger.io/docs/specification/data-models/data-types/

Or is there a way to include custom types as a valid format values?

@jorge-ibm
Copy link
Contributor

jorge-ibm commented Oct 13, 2020

@mkistler - any thoughts on this issue? We currently throw an error if a user specified email as the format. Here's the official text from oas3 regarding using email:

However, format is an open value, so you can use any formats, even not those defined by the OpenAPI Specification, such as:
email

@mkistler
Copy link
Contributor

There is a registry of "formats" to extend the OpenAPI spec here:

http://spec.openapis.org/registry/format/

But I don't see email in this list.

The intent of this warning in the validator is to flag any formats that are not "well-defined". Is there some special behavior you are expecting from format: email? If so, where is this defined? If not, then is there any value in specifying this format?

@mvasin
Copy link

mvasin commented Oct 14, 2020

Not sure what's the ultimate source of truth for the OpenAPI spec, but google takes me here: https://swagger.io/specification/#data-types

There's a table that lists the types, and that list doesn't mention email, but there's also the phrase

Formats such as "email", "uuid", and so on, MAY be used even though undefined by this specification.

@laurentkvb
Copy link
Author

@mkistler

The intent of this warning in the validator is to flag any formats that are not "well-defined". Is there some special behavior you are expecting from format: email? If so, where is this defined? If not, then is there any value in specifying this format?

From https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md &
https://swagger.io/specification/#data-types:

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

Would it be possible to have open values that can be accepted in some way (via a rule or as custom value that you can add to the list)? Because in the documentation it also suggest the following: Formats such as "email", "uuid", and so on, **MAY be used even though undefined by this specification**. So it seems to suggest that this format field may include formats that are not included in the OAS - but can be accepted. A reason is to explicitly for this field indicate what format should be used, most preferably format that already known such as an email.

@jorge-ibm
Copy link
Contributor

@mkistler ^^

@AgentGoldPaw
Copy link

What is the status of this issue? I also would like email to be added to the formats, as well as uuid. I have run my schema through other validators and it passes with no issues, however using this linter produces an error.

@mkistler
Copy link
Contributor

Now that we have integrated Spectral, which supports custom rules, I think the appropriate path forward is to replace the hard-coded invalid_type_format_pair rule with a Spectral rule that does more or less the same thing but allows a configurable set of formats. I expect we will get to this at some point but it honestly isn't at the top of our priority list, so we would welcome a PR from the community along these lines.

@AgentGoldPaw
Copy link

That makes sense, I am sure there are definitely higher priority items than allowing formats. Just was asking. I will look into Spectral rules. Thanks for pointing me in the right direction @mkistler

@dpopp07
Copy link
Member

dpopp07 commented Jan 21, 2022

This much anticipated support has been added with the latest release (0.51.3) ! email and uuid, among other formats, are now supported. Closing this issue as resolved

@dpopp07 dpopp07 closed this as completed Jan 21, 2022
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

6 participants