Home > database >  REST strict validation or not?
REST strict validation or not?

Time:11-25

I'm using Java spring boot microservices that uses the Jackson json parser. In regards to json schemas that i define in my open api specification I've noticed that my implementation will allow fields over and above what is defined in my schema through....

i.e. My schema currently allows for:

{
    "Name": "Denu",
    "Contact": 12345678
}

My code does not fail when I provide the blah property as per below. It simply ignores it:

{
    "Name": "Denu",
    "Contact": 12345678,
    "blah": "example"
}

I can change this using strict validation which can be configured for the Jackson parser but I want to know from an industry standard point of view is there any reference standard documented to whether i should go with strict or not?

thanks

CodePudding user response:

My schema currently allows...

If you are in a context where you need the option to extend the schema, then you will want to be considering design principles like "must ignore" and "must forward".

See, for example David Orchard 2003; the concepts then applied to XML schema designs are still useful when designing a JSON schema.

Other useful references:

  • Related