Skip to content

Utilizing JSONSchema For Parameter Validation #168

@its-hammer-time

Description

@its-hammer-time

Summary

Poking through the code, it looks like your parameter validation logic is fairly custom and doesn't hook in with the JSONSchema library you're using; line in the body validation. Taking a look at both the OpenAPI 3.0.0 and 3.1.0 specs, it looks like all parameters follow the same structure of having some custom fields (e.g. in, style, required, etc.), but for the actual format of the parameter they both have a schema section which in 3.0.0 is the custom OpenAPI Schema object, but in 3.1.0 that's native JSONSchema. So my question is:

What are your thoughts on using the JSONSchema library for format validation and only keeping the OpenAPI specific pieces like style, required, etc.?

I'm working on wiring up libopenapi-validator in my own service and something I need to do is understand what "type" of error is being raised. For body issues this is fairly straight forward as the JSONSchema error that you raise with your error has a Kind on it that tells me what the issue was. However, for parameter issues, since you're not using the JSONSchema library those errors aren't there so I've been doing regex checking on your error strings which is obviously a brittle solution.

I'm curious to hear what your thoughts are on this? 🤔 I thought about working on getting a PR out, but I was hoping to get your insights before spending time on using JSONSchema validation for the parameters. Is that something you tried to do and there's a reason you're not using it there? Is it just a lack of bandwidth and it's on the roadmap? etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions