-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add Defined Format: MAC Address #49
Comments
I can see an argument for this on the grounds of fitting in with network address formats in general. I can see an argument against this on the grounds that it's not as common as IP addresses, and it's also not hard to validate with a regexp (unlike, say, IPv6 addresses which can technically be validated with a regexp but the regexp is excessively long and complicated). Let's leave this open and give more folks a chance to weigh in. |
Thanks, I work for a networking company so they float through our API's a lot. I guess that it makes sense that it isn't all that common in the rest of the industry. |
Not sure if pre-defined patterns should be within the spec at all thought because you'll end up cherry picking. Today's "common" patterns may be of no use tomorrow but the spec is there to potentially stay for a long time. |
There's no reason you can't add a regex for this in your schema, and then use allOf and $ref to validate. |
Personally, given recent discussion and potential direction, I'm leaning towards thinking we shouldn't have IPv4 or v6 format... format is a bit of a mess =/ |
(Based upon a previous discussion with @handrews around I18N) I would be a fan of separating out related formats into their own "modules", in order that an implementation can choose to actively support a set of formats. Existing RFCs and drafts might suggest natural groupings for formats. For example, the IETF inet types YANG module specifies many of the same formats as in the validation draft. |
Given that we (in other issues) decided that "duration" and "uuid" would make sense for now, I think it's sensible to add in "mac-address". As @Relequestual notes, |
OK on further investigation, I don't have access to IEEE docs, and I can't figure out what to cite here. It also seems like the formats should really be "eui-48" and "eui-64". @JLLeitschuh or anyone- advice on this? If this turns out to be straightforward we can put it in the about-to-be-published draft, if not we can deal with it when we do more clean-up on |
I'm really not sure what to do about this and don't have the bandwidth to sort it out before publication. Bumping to the next draft unless someone shows up with an obvious way forward. |
Note to myself: Pydantic is adding support for generating JSON Schema for IP addresses using custom
The work is being done in this PR: pydantic/pydantic#532 If later there's an official, spec-defined |
@tiangolo there are already |
You are right @handrews, I don't know how I missed them. Thanks! |
MAC addresses have now been in use for 42 continuous years and are not going away anytime soon. The MAC address format is six two-digit hexadecimal fragments, zero-prefixed and separated by colons. Both upper and lower case letters are used in different systems and use-cases. My suggestion would be to allow the user to set all-lower or all-upper for output, defaulting to upper, and allow any-case on input. MAC addresses are fundamentally a positive integer, not a string, similar to IP addresses. They are six bytes programmed into PROM or flash on the NICs (ignoring virtual devices which would then just be in RAM). If you want to get fancy, MACs have a prefix that is assigned to vendors and then the vendor generates the lower half. The 802.x networking specs have been sponsored and are currently available free-of-charge. |
We are no longer adding formats. The correct approach is to create an extension vocabulary for this (and, we hope, for the existing formats, although of course those need not be all done by the same people or project). Extension vocabularies that prove popular might be adopted into the spec in the future. I am moving this to the vocabularies repo, which ideas for extensions are held. |
Proposal: Add a defined format for Mac Address.
The schema already has support for IPv4 and IPv6 data types. It would be useful to have support for the colon delimited MAC address format in the base schema.
Something similar to the following:
The text was updated successfully, but these errors were encountered: