V John
V John

Reputation: 147

how to validate OpenAPI-specific request query parameters against corresponding open api specs in spring boot

I am using com.networknt:json-schema-validator lib to validate the incoming json request body in my spring boot server against the pre loaded schema and its working fine. Now I also want to validate the request query parameter against the corresponding open api specs.

I was researching and found that com.networknt:json-schema-validator does not handle OpenAPI-specific query parameter parsing (i.e., style and explode handling). It only validates data once it's in JSON format but OpenAPI query parameters are not inherently JSON.

Can you please suggest some other library for this purpose or something else can be done to validate these query param using existing library itself?

Example apen api spec:

 "name" : "query-param-1",
  "in" : "query",
  "required" : true,
   style: form
   explode: false
  "schema" : {
    "minItems" : 2,
    "uniqueItems" : true,
    "type" : "array",
    "items" : {
      "anyOf" : [ {
        "type" : "string",
        "enum" : [ "AM", "SMF_SEL", "UEC_SMF", "UEC_SMSF", "SMS_SUB", "SM", "TRACE", "SMS_MNG", "LCS_PRIVACY", "LCS_MO", "UEC_AMF", "V2X" ]
      }, {
        "type" : "string"
      } ]
    }
  }
}

Sample query params:

query-param-1=AM,SMF_SEL,UEC_SMF

OR

query-param-1=AM&query-param-1=SMF_SEL&query-param-1=UEC_SMF

Upvotes: 3

Views: 125

Answers (0)

Related Questions