Forum Discussion

dhaval1896's avatar
dhaval1896
New Contributor
3 months ago
Solved

path template expressions is not matched with Parameter Object(s)

I am getting this error in Swagger 3.1.0. Worked fine in 3.0 version. path parameter is well defined in path item object using $ref. However, getting linting error 3040101. If the path parameter is removed, then there is no error. Path parameter has been defined in path items under components. This exact sytax worked fine in Swagger 3.0

  • Tom_S's avatar
    Tom_S
    3 months ago

    In OpenAPI 3.1.0, you can still use pathItems under paths, but there are stricter validation rules regarding path parameters. The main change is that path parameters must be explicitly defined within the parameters section of components and referenced in operations, rather than inside pathItems.

    When you have parameters in the URL, you need to ensure that the path parameters are correctly defined within the pathItem itself or within each operation under the pathItem. The path parameters must be included in the parameters section of the pathItem or the specific operation (e.g., get, post, etc.).

3 Replies

  • dhaval1896's avatar
    dhaval1896
    New Contributor

    Hi Tom_S. Thanks for the response. Does this mean for OpenAPI 3.1 we cannot use pathItems under paths? I am able to use pathItems if I do not have parameter in URL. However, with parameter in URL, do I need to specify the operation there itslef and not at PathItems? This would lead to major rework going from 3.0 to 3.1

    • Tom_S's avatar
      Tom_S
      Icon for Staff rankStaff

      In OpenAPI 3.1.0, you can still use pathItems under paths, but there are stricter validation rules regarding path parameters. The main change is that path parameters must be explicitly defined within the parameters section of components and referenced in operations, rather than inside pathItems.

      When you have parameters in the URL, you need to ensure that the path parameters are correctly defined within the pathItem itself or within each operation under the pathItem. The path parameters must be included in the parameters section of the pathItem or the specific operation (e.g., get, post, etc.).

  • Hi dhaval1896,

    Since OpenAPI 3.1.0 (previously Swagger) has stricter validation rules, some syntax that worked in 3.0.0 may now cause errors. In OpenAPI 3.1, parameters should reference #/components/parameters, NOT #/components/pathItems.