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

input matches more than one oneOf schemas when trying to validate IPv4 or IPv6 addresses #430

Closed
thediveo opened this issue Sep 29, 2021 · 2 comments · Fixed by #431
Closed

Comments

@thediveo
Copy link

Given this schema definition snippet for validating a string to be either a correct IPv4 or IPv6 textual representation:

        IPvX-Address:
            description: |-
                Represents either an IPv4 or IPv6 address (without prefix or any
                associated lifetimes, et cetera)
            type: string
            oneOf:
                - type: string
                  format: ipv4
                - type: string
                  format: ipv6

and using github.com/getkin/kin-openapi v0.76.0 I end up with for a value, such as Value: <string>"127.0.1.1" with this validation errorr: input matches more than one oneOf schemas.

Am I defining IPvX-Address wrong or is this an issue with kin-openapi v0.76.0?

fenollp added a commit to fenollp/kin-openapi that referenced this issue Oct 2, 2021
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
@fenollp
Copy link
Collaborator

fenollp commented Oct 2, 2021

ipv4/ipv6 formats are not defined by openapiv3 thus the validity of values associated to them is not enforced by default, however you can use this to fix your issue:

openapi3.DefineIPv4Format()
openapi3.DefineIPv6Format()

@fenollp fenollp closed this as completed Oct 2, 2021
@thediveo
Copy link
Author

thediveo commented Oct 2, 2021

Ah, thank you! I've seen these but missed the fact that they're not enforced for v3. Works now for me.

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

Successfully merging a pull request may close this issue.

2 participants