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

How to describe dynamic keys in response schema #1505

Closed
satkunas opened this issue Mar 10, 2018 · 4 comments
Closed

How to describe dynamic keys in response schema #1505

satkunas opened this issue Mar 10, 2018 · 4 comments

Comments

@satkunas
Copy link

How could the following response schema properties be described in YAML?

   "192.168.0.0/24": {
        "members": {
            "10:1f:74:b2:f6:a5": "192.168.0.2"
        }
}

Both the network address key 192.168.0.0/24 and each of the member key(s) 10:1f:74:b2:f6:a5 are dynamic and must follow a specific regular expression pattern. I've found documentation on how to define regular expression patterns for the value, but there's no details on how to define a pattern for the key.

@handrews
Copy link
Member

@satkunas this is not currently possible in OpenAPI's Schema Object.

In normal JSON Schema you could use patternProperties, but OpenAPI forbids it. If JSON Schema draft-06 or later were supported you could use propertyNames, but OpenAPI is based on draft-04

@handrews
Copy link
Member

See also #1443 (alternate schema languages)

@terraboops
Copy link

Hello! This is a very clear and helpful explanation, thank you!

I was curious if there are any plans to move to JSON schema draft-06 or later? Cheers.

@handrews
Copy link
Member

@tylermauthe @satkunas OpenAPI 3.1 is moving to the latest JSON Schema draft (#1977), so this will be possible with regular JSON Schema features in that version. There's no way to do it in 3.0.x, and none can be added due to the patch release compatibility requirements.

Since it's fixed in 3.1 and can't be fixed in earlier versions, I'm going to go ahead and close this.

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

No branches or pull requests

3 participants