Skip to content

JSON Validation on API calls #1243

Closed
Closed

Description

@ejemba

Some users warn that error messages we get from malformed json on API calls are unclear. So they spent time to debug their json input.

I propose to add something like json-schema ( http://json-schema.org ) with the go associated library ( https://github.com/xeipuuv/gojsonschema )

JSON Schema allow to validate an input JSON against a schema definition. And we get fine grained error messages.

For instance a schema can be this

{
    "title":  "Example Schema",
    "type":  "object",
    "properties":  {
        "firstName":  {
            "type":  "string"
        },
        "lastName":  {
            "type":  "string"
        },
        "age":  {
            "description":  "Age in years",
            "type":  "integer",
            "minimum":  0
        }
    },
    "required":  ["firstName",  "lastName"]
}

I do not think this can impact performance or if yes we can just activate it for test & quality purpose.

What do you think about this ?

Epo

Activity

  1. smarterclayton commented on Mar 9, 2015

    @smarterclayton
    Contributor

    We have swagger, which is supposed to most of this. Upstream has been tracking towards a fix for some of the issues. However, we're still gated by the golang JSON parser which (while generally awesome) has some limitations when you want to deeply control the structure. That's covered by kubernetes/kubernetes#3338 which I'll say covers this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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