Skip to content

feat/path conversions#2827

Draft
baywet wants to merge 8 commits intomainfrom
feat/path-conversions
Draft

feat/path conversions#2827
baywet wants to merge 8 commits intomainfrom
feat/path-conversions

Conversation

@baywet
Copy link
Copy Markdown
Member

@baywet baywet commented Apr 16, 2026

fixes #2806

baywet added 4 commits April 16, 2026 13:46
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
@baywet baywet self-assigned this Apr 16, 2026
Comment thread src/Microsoft.OpenApi/Services/OpenApiPathHelper.cs Fixed
@baywet baywet requested a review from davidrea-MS April 17, 2026 11:17
Comment thread src/Microsoft.OpenApi/Attributes/ExperimentalAttribute.cs Outdated
Comment thread src/Microsoft.OpenApi/Services/OpenApiPathHelper.cs Outdated
…ce and rename V3_0 to V30

Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/0fac65d3-0bbb-44db-b82e-7648c8fb8f86

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

@baywet
Copy link
Copy Markdown
Member Author

baywet commented Apr 19, 2026

@copilot we're missing a policy to map the requestBody property to a in:body parameter for the path conversion to v2

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

@copilot we're missing a policy to map the requestBody property to a in:body parameter for the path conversion to v2

Added in c0d89d1. The new V2RequestBodyToBodyParameterPolicy maps:

  • #/paths/~1items/post/requestBody#/paths/~1items/post/parameters/0
  • #/paths/~1items/post/requestBody/content/application~1json/schema#/paths/~1items/post/parameters/0/schema
  • #/paths/~1items/post/requestBody/{prop}#/paths/~1items/post/parameters/0/{prop}

requestBody was also removed from V2UnsupportedPathPolicy.UnsupportedSegments so it's no longer returned as null.

@baywet
Copy link
Copy Markdown
Member Author

baywet commented Apr 19, 2026

@copilot the policies aren't 'rooted' in the document then they can have false positive matches. For example the V2ResponseContentUnwrappingPolicy can match an extension or schema that just happens to have a path that matches ./responses/[^/]/content/[^/]*.

Example paths that can cause incorrect path conversions: #/paths/1items/get/requestBody/content/application1json/schema/properties/responses/properties/content/properties/foo#/x-ms-sneaky-extension/additionalReference/responses/data/content/0

Attempt to root the regexes where possible (dollar sign), add additional negative tests

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

@copilot the policies aren't 'rooted' in the document then they can have false positive matches. For example the V2ResponseContentUnwrappingPolicy can match an extension or schema that just happens to...

Addressed in c063087. Two rooting strategies were applied:

  1. HTTP method anchor for operation-level keywords — V2RequestBodyToBodyParameterPolicy now requires requestBody to be immediately preceded by an HTTP method, and V2ResponseContentUnwrappingPolicy requires responses to be immediately preceded by an HTTP method. This prevents both example false positives: the schema-property responses/content inside a deep schema tree, and the #/x-ms-sneaky-extension/additionalReference/responses/data/content/0 extension path.

  2. IsSchemaContext guard for the remaining policies — a new helper returns true when any prior segment is properties or additionalProperties, indicating the path has entered a JSON Schema property map. Applied to V2UnsupportedPathPolicy, V2HeaderSchemaUnwrappingPolicy, and V2ComponentRenamePolicy's inline unwrapping checks.

Added negative tests covering schema-property false positives, extension-path false positives, and component-schema paths where only the rename applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenApiVisitorBase PathString is not correct for v2 documents

3 participants