Analysis and Solution for the "should NOT have additional properties" Error in Swagger Editor Path Parameters

Dec 08, 2025 · Programming · 13 views · 7.8

Keywords: Swagger Editor | path parameters | required property

Abstract: This article provides an in-depth analysis of the common "Schema error: should NOT have additional properties" error in Swagger Editor. This error typically occurs when defining API path parameters, superficially indicating extra properties, but its root cause lies in the Swagger 2.0 specification requiring path parameters to be explicitly declared as required (required: true). Through concrete YAML code examples, the article explains the error cause in detail and offers standard fixes. It also compares syntax differences between Swagger 2.0 and OpenAPI 3.0 in parameter definitions to help developers avoid similar issues from version confusion. Finally, best practices are summarized to ensure API documentation standardization and compatibility.

Problem Phenomenon and Error Analysis

When using Swagger Editor to design APIs, developers often encounter the following error message:

Schema error at paths['/employees/{employeeId}/roles'].get.parameters[0]
should NOT have additional properties
additionalProperty: type, format, name, in, description
Jump to line 24

This error message superficially indicates "extra properties" in the path parameter definition, but it is actually misleading. According to the Swagger 2.0 specification, path parameters (i.e., in: path) must be explicitly set as required because they are essential components in the URL path. The properties listed in the error message (such as type, format, etc.) are legitimate, but the absence of required: true causes validation failure, triggering this generic error prompt.

Root Cause and Solution

Below is a typical erroneous YAML code example, corresponding to line 24 in the problem:

parameters:
  - name: employeeId
    in: path
    description: Id of employee whose roles we are fetching
    type: integer
    format: int64

This code snippet defines the path parameter employeeId but does not include required: true. According to the Swagger 2.0 specification, all path parameters must be marked as required because they are part of the URL structure and indispensable. The fix is straightforward: add required: true to the parameter definition. The corrected code is as follows:

parameters:
  - name: employeeId
    in: path
    description: Id of employee whose roles we are fetching
    type: integer
    format: int64
    required: true

After adding this, the error will disappear, and the API documentation will validate correctly. This requirement stems from RESTful API design principles, where path parameters are used to identify resources and must be present to ensure endpoint validity.

Version Confusion and Supplementary Notes

In addition to the core issue above, developers sometimes encounter similar errors due to mixing Swagger 2.0 and OpenAPI 3.0 syntax. OpenAPI 3.0 introduces components to restructure definitions, but the basic rules for parameters remain consistent. For example, in OpenAPI 3.0, path parameters also require required: true, but the overall structure may differ. If using an online editor, conversion between versions can be done via the "Edit > Convert to OpenAPI 3" function, but syntax adjustments must be noted. The key point is: regardless of the version, the required nature of path parameters is mandatory, so avoid overlooking this detail during version switches.

Best Practices and Conclusion

To avoid such errors, it is recommended to follow these practices:

In summary, the "should NOT have additional properties" error is often an indirect manifestation of missing required: true for path parameters in Swagger 2.0. By understanding specification requirements and applying standard fixes, developers can efficiently resolve this issue, enhancing the quality and reliability of API documentation.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.