Skip to main content

pre-defined-operation-parameter-for-form-param-of-request-body

Overview

This rule belongs to the apimatic-gavel-validation ruleset and states that:

When defining the request body along with a Content-Type header indicating a form media type (e.g. multipart/form-data, application/x-www-form-urlencoded), each form parameter defined in the body section must also be defined in the corresponding operation for which the test case is being defined.

PropertyValue
EnabledYes
Maximum SeverityError
MessageRequest body's form parameter is not defined in the corresponding operation.
CodeAPIMATICGAVEL_V004
TypeValidation
Rule SystemSemantic
Broad CategoryGavel Request
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsgavel apimatic semantic validation parameter form request body request operation

Suggested Fixes

  • The name of the form parameter in the request body must match exactly with a parameter defined in the operation's parameters list or requestBody section depending upon the OpenAPI format being used.
  • For OpenAPI v2.0, the form parameter must correspond with the name of a parameter in the operation's parameters list whose location in is set as formData.
  • For OpenAPI v3.0 and above, the form parameter must correspond with the name of a property in the operation's requestBody > content > schema section provided that the operation request body content media type is also valid for the test case request's Content-Type header value.
  • Ensure that the form parameter name and the operation level parameter name matches exactly with no typos.
  • Parameter names are compared in a case-sensitive manner.

For More Information