Skip to content

Fix invalid cast for x-ms-paths required arrays - #103

Open
Jerry-Johnson-3 wants to merge 1 commit into
criteo:mainfrom
Jerry-Johnson-3:fix/x-ms-paths-required-cast
Open

Jerry-Johnson-3 wants to merge 1 commit into
criteo:mainfrom
Jerry-Johnson-3:fix/x-ms-paths-required-cast

Conversation

@Jerry-Johnson-3

@Jerry-Johnson-3 Jerry-Johnson-3 commented Aug 24, 2026

Copy link
Copy Markdown

Summary

  • Stop casting a LINQ Select projection to ISet<string> when converting required arrays on x-ms-paths schemas.
  • Add a regression test that converts a schema with required: [name].

That cast throws InvalidCastException whenever a custom path schema includes required.

Spec

required is a JSON Schema array of unique strings (OAS Schema Object takes this keyword unchanged). The crash is a C# invalid cast: Enumerable.Select returns IEnumerable<string>, not ISet<string>.

x-ms-paths itself is an AutoRest specification extension, not an OAS keyword; the required array on schemas inside it is still JSON Schema required.

Testing

  • Red: ToOpenApiPaths_ConvertsSchemaRequiredArray threw InvalidCastException.
  • Green: the same test passed after building a HashSet<string>.

Build a HashSet from required property names instead of casting a LINQ projection to ISet<string>.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant