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.
| Property | Value |
|---|---|
| Enabled | Yes |
| Maximum Severity | Error |
| Message | Request body's form parameter is not defined in the corresponding operation. |
| Code | APIMATICGAVEL_V004 |
| Type | Validation |
| Rule System | Semantic |
| Broad Category | Gavel Request |
| Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
| Tags | gavel apimatic semantic validation parameter form request body request operation |
Suggested Fixes
- The name of the form parameter in the request
bodymust match exactly with a parameter defined in the operation'sparameterslist orrequestBodysection 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
parameterslist whose locationinis set asformData. - For OpenAPI v3.0 and above, the form parameter must correspond with the name of a property in the operation's
requestBody > content > schemasection provided that the operation request body content media type is also valid for the test caserequest'sContent-Typeheader 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
- https://docs.apimatic.io/specification-extensions/swagger-test-cases-extensions/#http-request
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#request-body-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operation-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#request-body-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#operation-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#parameter-object
- https://docs.apimatic.io/specification-extensions/swagger-test-cases-extensions/#gavel-specification
- https://docs.apimatic.io/specification-extensions/swagger-test-cases-extensions/#specifying-test-cases-using-gavel-specification
- https://docs.apimatic.io/rulesets/overview/