Skip to content

Conversation

baywet
Copy link

@baywet baywet commented Oct 3, 2025

No description provided.

baywet and others added 30 commits September 23, 2025 21:05
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
adds new OAS vesion and serialization/deserialization infrastructure
sync from upstream main
…ialization-infrastructure-for-v32

Adds serialization/deserialization unit tests for 3.2
* Initial plan

* Add Summary support to OpenApiResponse with serialization/deserialization

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

* Complete implementation with reference support and test fixes

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

* Update IOpenApiResponse to derive from IOpenApiSummarizedElement

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

* Apply suggestions from code review

* Apply suggestion from @baywet

* chore: copy reference implementation

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

* chore: adds missing using

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

* chore: linting

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

* chore: updates public API export

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

---------

Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: Vincent Biret <vincentbiret@hotmail.com>
Co-authored-by: Vincent Biret <vibiret@microsoft.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
…b196-901596c61b07

feat: Implement OpenAPI 3.2.0 server name field
…ization

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Comment on lines +200 to +207
foreach(var type in list)
{
if (type is not null)
{
var schemaType = type.ToJsonSchemaType();
combinedType |= schemaType;
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where Note

This foreach loop
implicitly filters its target sequence
- consider filtering the sequence explicitly using '.Where(...)'.

Copilot Autofix

AI 7 days ago

To address the issue, replace the loop:

foreach(var type in list)
{
    if (type is not null)
    {
        // logic
    }
}

with a loop that explicitly filters non-null values before iteration, using LINQ's .Where():

foreach(var type in list.Where(type => type is not null))
{
    // logic
}

This reduces nesting, improves readability, and explicitly communicates the intent to filter out nulls. Only the relevant region inside the dictionary initializer at lines 190-210 (in the block for "type") needs changing.

No new imports or other method/variable definitions are needed, as System.Linq is already imported.


Suggested changeset 1
src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs
--- a/src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs
+++ b/src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs
@@ -197,13 +197,10 @@
                 {
                     var list = n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc);
                     JsonSchemaType combinedType = 0;
-                    foreach(var type in list)
+                    foreach(var type in list.Where(type => type is not null))
                     {
-                        if (type is not null)
-                        {
-                            var schemaType = type.ToJsonSchemaType();
-                            combinedType |= schemaType;
-                        }                            
+                        var schemaType = type.ToJsonSchemaType();
+                        combinedType |= schemaType;
                     }
                     o.Type = combinedType;
                 }
EOF
@@ -197,13 +197,10 @@
{
var list = n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc);
JsonSchemaType combinedType = 0;
foreach(var type in list)
foreach(var type in list.Where(type => type is not null))
{
if (type is not null)
{
var schemaType = type.ToJsonSchemaType();
combinedType |= schemaType;
}
var schemaType = type.ToJsonSchemaType();
combinedType |= schemaType;
}
o.Type = combinedType;
}
Copilot is powered by AI and may make mistakes. Always verify output.
baywet and others added 23 commits October 3, 2025 13:17
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
…to 3 and 3.1

Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
fix: avoid serializing non-standard operations in 2, 3, and 3.1

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>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
…9aa8-a50a721fd288

feat: Add support for media types components in OAS 3.2.0
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 <vincentbiret@hotmail.com>
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
feat: add new v32 properties for Path Items (query, additional operations)
OpenApiSpecVersion.OpenApi2_0 => _standardHttp2MethodsNames,
OpenApiSpecVersion.OpenApi3_0 => _standardHttp30MethodsNames,
OpenApiSpecVersion.OpenApi3_1 => _standardHttp31MethodsNames,
OpenApiSpecVersion.OpenApi3_2 or _ => _standardHttp32MethodsNames,

Check warning

Code scanning / CodeQL

Constant condition Warning

Pattern always matches.

Copilot Autofix

AI 5 days ago

The best way to fix this pattern matching issue is to restructure the switch expression to properly handle the intended cases. If OpenApiSpecVersion.OpenApi3_2 should have its own branch, then that branch should be written as a separate case. If all other enum values should fall into a generic default, then only the discard arm (_) should be used for the fallback. In this code, to retain the ability to match OpenApiSpecVersion.OpenApi3_2 specifically, use two arms: one for that explicit value, and one (_) as a fallback for anything else. Therefore, line 176 should be split into two lines: one matching only OpenApiSpecVersion.OpenApi3_2, and the next with the discard pattern _.

Edit the switch expression as follows:

  • Replace line 176
    OpenApiSpecVersion.OpenApi3_2 or _ => _standardHttp32MethodsNames,
    
    with
    OpenApiSpecVersion.OpenApi3_2 => _standardHttp32MethodsNames,
    _ => _standardHttp32MethodsNames,
    

OR, since both branches do the same thing, just use the discard (_) as the only branch:

_ => _standardHttp32MethodsNames

However, this latter approach may lose clarity; if the intention is to handle OpenApiSpecVersion.OpenApi3_2 specifically, splitting makes it clearer for future modifications.

No new imports or method definitions are required.

Suggested changeset 1
src/Microsoft.OpenApi/Models/OpenApiPathItem.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs
--- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs
@@ -173,7 +173,8 @@
                 OpenApiSpecVersion.OpenApi2_0 => _standardHttp2MethodsNames,
                 OpenApiSpecVersion.OpenApi3_0 => _standardHttp30MethodsNames,
                 OpenApiSpecVersion.OpenApi3_1 => _standardHttp31MethodsNames,
-                OpenApiSpecVersion.OpenApi3_2 or _ => _standardHttp32MethodsNames,
+                OpenApiSpecVersion.OpenApi3_2 => _standardHttp32MethodsNames,
+                _ => _standardHttp32MethodsNames,
             };
 
             // operations
EOF
@@ -173,7 +173,8 @@
OpenApiSpecVersion.OpenApi2_0 => _standardHttp2MethodsNames,
OpenApiSpecVersion.OpenApi3_0 => _standardHttp30MethodsNames,
OpenApiSpecVersion.OpenApi3_1 => _standardHttp31MethodsNames,
OpenApiSpecVersion.OpenApi3_2 or _ => _standardHttp32MethodsNames,
OpenApiSpecVersion.OpenApi3_2 => _standardHttp32MethodsNames,
_ => _standardHttp32MethodsNames,
};

// operations
Copilot is powered by AI and may make mistakes. Always verify output.
baywet added 3 commits October 5, 2025 17:21
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
chore: disables WPF solution on non windows platforms
@baywet
Copy link
Author

baywet commented Oct 6, 2025

closing in favour of microsoft#2529

@baywet baywet closed this Oct 6, 2025
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.

3 participants