Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.0.0-preview5 #2077

Merged
merged 134 commits into from
Jan 21, 2025
Merged
Changes from 4 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
30ee6ed
fix: single copy and maintain for references
baywet Dec 27, 2024
6f4e7a2
fix: uses backing fields instead of schema copy
baywet Dec 27, 2024
0a7b4f6
chore: linting
baywet Dec 30, 2024
10e548a
feat: adds components registration method for schemas
baywet Dec 30, 2024
72db982
chore: linting
baywet Dec 30, 2024
efd2bfb
feat; adds a method to register and add the component schemas
baywet Dec 30, 2024
7994691
fix: null propagation for most failed reference lookup
baywet Dec 30, 2024
e3325b9
fix: aligns missing properties for override
baywet Dec 31, 2024
8d57b81
fix: aligns to null propagation operator
baywet Dec 31, 2024
b727581
fix: updates public api file
baywet Dec 31, 2024
5b4c94e
chore: linting
baywet Dec 31, 2024
e366566
chore: linting
baywet Dec 31, 2024
a231748
chore: linting
baywet Dec 31, 2024
878593b
fix: side effects in tag references
baywet Dec 31, 2024
9db6e2d
fix: potential NRT
baywet Dec 31, 2024
ff1406c
fix: passes missing host document references to all layers
baywet Dec 31, 2024
1368eed
chore(deps): bump coverlet.collector from 6.0.2 to 6.0.3
dependabot[bot] Dec 31, 2024
d5becc5
Merge pull request #2034 from microsoft/dependabot/nuget/coverlet.col…
baywet Dec 31, 2024
df3744d
chore(deps): bump coverlet.msbuild from 6.0.2 to 6.0.3
dependabot[bot] Dec 31, 2024
4a0ef24
Merge pull request #2035 from microsoft/dependabot/nuget/coverlet.msb…
baywet Dec 31, 2024
45329e4
fix: adds missing culture argument to date serialization
baywet Jan 2, 2025
818414d
fix: uses the json node clone API to avoid unecessary allocs
baywet Jan 2, 2025
a6a44a7
fix: date time and date time offset shifting zones
baywet Jan 2, 2025
e861c08
fix: removes all obsolete APIs
baywet Jan 2, 2025
e478b75
chore: updates public api document
baywet Jan 2, 2025
4a50c77
fix: removes useless condition for null check
baywet Jan 2, 2025
5de1bf2
Merge pull request #2037 from microsoft/fix/missing-culture
baywet Jan 3, 2025
6655ded
Merge pull request #2040 from microsoft/chore/remove-obsolete
baywet Jan 3, 2025
af55d61
Merge pull request #2039 from microsoft/fix/json-node-serialization
baywet Jan 3, 2025
ffac64e
Merge pull request #2038 from microsoft/fix/clone-api
baywet Jan 3, 2025
ec9c01b
fix: v2 references for properties do not work as expected
baywet Jan 3, 2025
8b4833c
fix: v2 request body content null propagation
baywet Jan 3, 2025
8d70195
fix: removes redundant assignment
baywet Jan 3, 2025
0ce92cc
fix: conditional version for extension causes invalid json
baywet Jan 3, 2025
4030c1f
Merge pull request #2043 from microsoft/fix/invalid-json-by-extension
baywet Jan 6, 2025
6d064c4
Merge pull request #2042 from microsoft/fix/v2-request-body-content
baywet Jan 6, 2025
f7dbe74
chore: adds unit test for properties references
baywet Jan 6, 2025
ebdbcd8
chore: switches to the other registration method
baywet Jan 6, 2025
8a73b54
fix: adds support for all component types
baywet Jan 6, 2025
45d49f1
chore: updates public api test
baywet Jan 6, 2025
799d161
chore(deps): bump Verify.Xunit from 28.7.0 to 28.8.1
dependabot[bot] Jan 6, 2025
b394a47
Merge pull request #2044 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Jan 6, 2025
aa90edf
Merge pull request #2041 from microsoft/fix/v2-properties-references
baywet Jan 7, 2025
1394da7
Merge pull request #2031 from microsoft/fix/reference-proxy-single-copy
baywet Jan 7, 2025
b69922e
Merge branch 'dev' into fix/tag-references
baywet Jan 8, 2025
66e4101
chore: removes unused method
baywet Jan 8, 2025
88daad5
fix: components schema copy
baywet Jan 8, 2025
9d07ebb
fix: enum parsing when encountering unknown values should not default…
baywet Jan 8, 2025
fd25660
chore: aligns parsing pattern
baywet Jan 8, 2025
97ce7a8
chore(deps): bump xunit from 2.9.2 to 2.9.3
dependabot[bot] Jan 8, 2025
47ad76b
fix: inconsistant API surface usage
baywet Jan 8, 2025
a201aa2
feat: adds a net8 target to benefit from all the conditional compilation
baywet Jan 8, 2025
f517deb
fix: potential NRT for net8 build
baywet Jan 8, 2025
1a1e013
fix: updates public API surface with net8 target
baywet Jan 8, 2025
15c1122
Merge pull request #2050 from microsoft/dependabot/nuget/xunit-2.9.3
baywet Jan 8, 2025
e9e214f
Merge pull request #2051 from microsoft/fix/async-surface
baywet Jan 9, 2025
2348814
Merge branch 'dev' into fix/enum-parsing
MaggieKimani1 Jan 9, 2025
23c8fdf
Merge branch 'dev' into fix/tag-references
baywet Jan 9, 2025
d4e155b
Merge pull request #2049 from microsoft/fix/enum-parsing
baywet Jan 9, 2025
d405592
make IDiagnosticExtensions internal and fix namespace
mus65 Jan 10, 2025
a398fc4
chore(deps): bump xunit.runner.visualstudio from 3.0.0 to 3.0.1
dependabot[bot] Jan 10, 2025
0347f01
Merge pull request #2054 from microsoft/dependabot/nuget/xunit.runner…
baywet Jan 10, 2025
6cf9059
Merge pull request #2053 from mus65/addrangeinternal
MaggieKimani1 Jan 13, 2025
25765f9
chore(deps): bump docker/build-push-action from 6.10.0 to 6.11.0
dependabot[bot] Jan 13, 2025
055a6e1
Merge pull request #2056 from microsoft/dependabot/github_actions/doc…
baywet Jan 13, 2025
8178037
chore(deps): bump Microsoft.Extensions.Logging, Microsoft.Extensions.…
dependabot[bot] Jan 14, 2025
3311cb8
chore(deps): bump Verify.Xunit from 28.8.1 to 28.9.0
dependabot[bot] Jan 14, 2025
105b029
chore(deps): bump System.Formats.Asn1 from 9.0.0 to 9.0.1
dependabot[bot] Jan 14, 2025
b10f79f
Merge pull request #2059 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Jan 14, 2025
22a14ea
Merge pull request #2057 from microsoft/dependabot/nuget/multi-1eea05…
baywet Jan 14, 2025
d087d24
Merge pull request #2061 from microsoft/dependabot/nuget/System.Forma…
baywet Jan 14, 2025
45a544e
Enable trimming for clients using net5 or higher
MaggieKimani1 Jan 15, 2025
a5e9058
Add a reference to readers
MaggieKimani1 Jan 15, 2025
1093d93
Use JsonSerializer context for source generation; compatible with AOT
MaggieKimani1 Jan 15, 2025
8ebab68
Annotate enumType param to preserve metadata during trimming
MaggieKimani1 Jan 15, 2025
ad1d5d7
simplify code
MaggieKimani1 Jan 15, 2025
e809945
Upgrade TFM and update API
MaggieKimani1 Jan 15, 2025
74f2c43
Add workflow to validate project for trimming
MaggieKimani1 Jan 15, 2025
5d56fac
Update .github/workflows/ci-cd.yml
baywet Jan 15, 2025
7880216
chore: migrates of FA to xunit first batch
baywet Jan 15, 2025
1a0153b
chore: FA replacement additional batch
baywet Jan 15, 2025
3ceaa12
chore: removes unused usings
baywet Jan 15, 2025
865872d
chore: FA replacement additional batch
baywet Jan 15, 2025
b15de7a
chore: FA replacement additional batch
baywet Jan 15, 2025
0cca61a
chore: additional FA replacementtttttttttt
baywet Jan 15, 2025
4ecf8a4
chore: additional batch of FA replacement
baywet Jan 15, 2025
d0bacd2
chore: additional FA replacement batch
baywet Jan 15, 2025
d841a2a
chore: additional FA replacement batch
baywet Jan 15, 2025
c3a1fab
chore: additional FA replacement
baywet Jan 15, 2025
19d7935
chore: additional FA replacement batch
baywet Jan 15, 2025
a704fad
chore: additional FA replacement batch
baywet Jan 15, 2025
06e13ff
chore(deps): bump System.Formats.Asn1 and Microsoft.Windows.Compatibi…
dependabot[bot] Jan 15, 2025
717deb0
Merge pull request #2032 from microsoft/fix/tag-references
baywet Jan 15, 2025
7a7bba1
Merge pull request #2065 from microsoft/dependabot/nuget/multi-a1e380…
baywet Jan 15, 2025
c4a446c
Ensure trimmer preserves metadata for DisplayAttribute properties
MaggieKimani1 Jan 16, 2025
e1a3795
Merge remote-tracking branch 'origin/mk/implement-AOT' into mk/implem…
MaggieKimani1 Jan 16, 2025
4357373
Merge branch 'dev' into fix/missing-document-references
baywet Jan 16, 2025
068b8e6
Merge branch 'dev' into chore/reduce-fluent-assertions-dependency
baywet Jan 16, 2025
b63d760
Merge branch 'dev' into fix/reference-copy
baywet Jan 16, 2025
0bf3dbb
Ignore warning
MaggieKimani1 Jan 16, 2025
99c0824
chore: additional FA replacement batch
baywet Jan 16, 2025
18ec0d0
chore: naming convention
baywet Jan 16, 2025
a8153e9
chore: additional FA removal batch
baywet Jan 16, 2025
faca076
chore: linting
baywet Jan 16, 2025
d7c4621
Merge pull request #2033 from microsoft/fix/missing-document-references
baywet Jan 16, 2025
0c8ccf2
Merge branch 'dev' into chore/reduce-fluent-assertions-dependency
baywet Jan 16, 2025
aae81ad
Merge branch 'dev' into fix/reference-copy
baywet Jan 16, 2025
268a398
Fix trimming errors
MaggieKimani1 Jan 16, 2025
d88c36f
Merge pull request #2064 from microsoft/chore/reduce-fluent-assertion…
baywet Jan 16, 2025
88adb9f
Merge branch 'dev' into fix/reference-copy
baywet Jan 16, 2025
7836a2c
Merge branch 'dev' into mk/implement-AOT
baywet Jan 16, 2025
3a35cb9
Add MSBuild property to identify project-specific trimmer warnings
MaggieKimani1 Jan 16, 2025
7e512ab
Resolve trimmer warnings
MaggieKimani1 Jan 16, 2025
7a82174
Revert change
MaggieKimani1 Jan 16, 2025
b4f9c3e
Merge pull request #2063 from microsoft/mk/implement-AOT
MaggieKimani1 Jan 16, 2025
962e929
Replicate copying logic for other component types
MaggieKimani1 Jan 17, 2025
dbf4d39
chore(deps): bump FluentAssertions from 7.0.0 to 7.1.0
dependabot[bot] Jan 17, 2025
7069446
Implement an interface for IOpenApiReferenceable items with a target …
MaggieKimani1 Jan 20, 2025
32f75a1
Add reusable pathItems to components
MaggieKimani1 Jan 20, 2025
733185f
Add test and update API surface
MaggieKimani1 Jan 20, 2025
c87a3c2
Merge pull request #2070 from microsoft/dependabot/nuget/FluentAssert…
baywet Jan 20, 2025
6e904d0
Merge branch 'dev' into fix/reference-copy
baywet Jan 20, 2025
613a8e0
chore(deps): bump docker/build-push-action from 6.11.0 to 6.12.0
dependabot[bot] Jan 20, 2025
e0f9763
chore(deps): bump coverlet.msbuild from 6.0.3 to 6.0.4
dependabot[bot] Jan 20, 2025
81c7474
Merge pull request #2073 from microsoft/dependabot/nuget/coverlet.msb…
baywet Jan 20, 2025
aa44c46
Merge pull request #2071 from microsoft/dependabot/github_actions/doc…
baywet Jan 20, 2025
445b628
chore(deps): bump coverlet.collector from 6.0.3 to 6.0.4
dependabot[bot] Jan 20, 2025
b522f9f
Merge pull request #2072 from microsoft/dependabot/nuget/coverlet.col…
baywet Jan 20, 2025
995528e
Merge pull request #2046 from microsoft/fix/reference-copy
baywet Jan 21, 2025
4a72387
Bump preview versions
MaggieKimani1 Jan 21, 2025
8a83c6f
Merge pull request #2074 from microsoft/chore/bump-preview-versions
MaggieKimani1 Jan 21, 2025
a3d0541
pass host document for reference resolution
MaggieKimani1 Jan 21, 2025
c39fa84
Add test
MaggieKimani1 Jan 21, 2025
9ccdd80
Merge pull request #2076 from microsoft/mk/fix-loading-error
MaggieKimani1 Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ public ListNode(ParsingContext context, JsonArray jsonArray) : base(
_nodeList = jsonArray;
}

public override List<T> CreateList<T>(Func<MapNode, OpenApiDocument, T> map, OpenApiDocument hostDocument = null)
public override List<T> CreateList<T>(Func<MapNode, OpenApiDocument, T> map, OpenApiDocument hostDocument)
{
if (_nodeList == null)
{
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ public PropertyNode this[string key]
}
}

public override Dictionary<string, T> CreateMap<T>(Func<MapNode, OpenApiDocument, T> map, OpenApiDocument hostDocument = null)
public override Dictionary<string, T> CreateMap<T>(Func<MapNode, OpenApiDocument, T> map, OpenApiDocument hostDocument)
{
var jsonMap = _node ?? throw new OpenApiReaderException($"Expected map while parsing {typeof(T).Name}", Context);
var nodes = jsonMap.Select(
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs
Original file line number Diff line number Diff line change
@@ -46,12 +46,12 @@ public static ParseNode Create(ParsingContext context, JsonNode node)
return new ValueNode(context, node as JsonValue);
}

public virtual List<T> CreateList<T>(Func<MapNode, OpenApiDocument, T> map, OpenApiDocument hostDocument = null)
public virtual List<T> CreateList<T>(Func<MapNode, OpenApiDocument, T> map, OpenApiDocument hostDocument)
{
throw new OpenApiReaderException("Cannot create list from this type of node.", Context);
}

public virtual Dictionary<string, T> CreateMap<T>(Func<MapNode, OpenApiDocument, T> map, OpenApiDocument hostDocument = null)
public virtual Dictionary<string, T> CreateMap<T>(Func<MapNode, OpenApiDocument, T> map, OpenApiDocument hostDocument)
{
throw new OpenApiReaderException("Cannot create map from this type of node.", Context);
}
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public void ParseField<T>(
T parentInstance,
IDictionary<string, Action<T, ParseNode, OpenApiDocument>> fixedFields,
IDictionary<Func<string, bool>, Action<T, string, ParseNode, OpenApiDocument>> patternFields,
OpenApiDocument hostDocument = null)
OpenApiDocument hostDocument)
{
if (fixedFields.TryGetValue(Name, out var fixedFieldMap))
{
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

public static OpenApiContact LoadContact(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiContact LoadContact(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node as MapNode;
var contact = new OpenApiContact();
10 changes: 4 additions & 6 deletions src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs
Original file line number Diff line number Diff line change
@@ -64,20 +64,18 @@ internal static partial class OpenApiV2Deserializer
},
{
"parameters",
(o, n, _) =>
(o, n, doc) =>
{
if (o.Components == null)
{
o.Components = new();
}
o.Components ??= new();

o.Components.Parameters = n.CreateMap(LoadParameter, o);

o.Components.RequestBodies = n.CreateMap((p, d) =>
{
var parameter = LoadParameter(node: p, loadRequestBody: true, hostDocument: d);
return parameter != null ? CreateRequestBody(p.Context, parameter) : null;
}
},
doc
);
}
},
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

public static OpenApiExternalDocs LoadExternalDocs(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiExternalDocs LoadExternalDocs(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("externalDocs");

Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ internal static partial class OpenApiV2Deserializer
},
{
"items",
(o, n, _) => GetOrCreateSchema(o).Items = LoadSchema(n)
(o, n, doc) => GetOrCreateSchema(o).Items = LoadSchema(n, doc)
},
{
"collectionFormat",
@@ -102,14 +102,14 @@ private static OpenApiSchema GetOrCreateSchema(OpenApiHeader p)
return p.Schema ??= new();
}

public static OpenApiHeader LoadHeader(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiHeader LoadHeader(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("header");
var header = new OpenApiHeader();

foreach (var property in mapNode)
{
property.ParseField(header, _headerFixedFields, _headerPatternFields);
property.ParseField(header, _headerFixedFields, _headerPatternFields, hostDocument);
}

var schema = node.Context.GetFromTempStorage<OpenApiSchema>("schema");
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

public static OpenApiInfo LoadInfo(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiInfo LoadInfo(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("Info");

Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

public static OpenApiLicense LoadLicense(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiLicense LoadLicense(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("OpenApiLicense");

Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

internal static OpenApiOperation LoadOperation(ParseNode node, OpenApiDocument hostDocument = null)
internal static OpenApiOperation LoadOperation(ParseNode node, OpenApiDocument hostDocument)
{
// Reset these temp storage parameters for each operation.
node.Context.SetTempStorage(TempStorageKeys.BodyParameter, null);
@@ -131,7 +131,7 @@ internal static OpenApiOperation LoadOperation(ParseNode node, OpenApiDocument h
return operation;
}

public static OpenApiResponses LoadResponses(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiResponses LoadResponses(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("Responses");

@@ -205,7 +205,7 @@ internal static OpenApiRequestBody CreateRequestBody(
}

private static OpenApiTagReference LoadTagByReference(
string tagName, OpenApiDocument hostDocument = null)
string tagName, OpenApiDocument hostDocument)
{
return new OpenApiTagReference(tagName, hostDocument);
}
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ internal static partial class OpenApiV2Deserializer
},
{
"items",
(o, n, t) => GetOrCreateSchema(o).Items = LoadSchema(n)
(o, n, t) => GetOrCreateSchema(o).Items = LoadSchema(n, t)
},
{
"collectionFormat",
@@ -138,7 +138,7 @@ private static void LoadStyle(OpenApiParameter p, string v)
}
}

private static void LoadParameterExamplesExtension(OpenApiParameter parameter, ParseNode node, OpenApiDocument hostDocument = null)
private static void LoadParameterExamplesExtension(OpenApiParameter parameter, ParseNode node, OpenApiDocument hostDocument)
{
var examples = LoadExamplesExtension(node);
node.Context.SetTempStorage(TempStorageKeys.Examples, examples, parameter);
@@ -149,7 +149,7 @@ private static OpenApiSchema GetOrCreateSchema(OpenApiParameter p)
return p.Schema ??= new();
}

private static void ProcessIn(OpenApiParameter o, ParseNode n, OpenApiDocument hostDocument = null)
private static void ProcessIn(OpenApiParameter o, ParseNode n, OpenApiDocument hostDocument)
{
var value = n.GetScalarValue();
switch (value)
@@ -183,12 +183,12 @@ private static void ProcessIn(OpenApiParameter o, ParseNode n, OpenApiDocument h
}
}

public static OpenApiParameter LoadParameter(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiParameter LoadParameter(ParseNode node, OpenApiDocument hostDocument)
{
return LoadParameter(node, false, hostDocument);
}

public static OpenApiParameter LoadParameter(ParseNode node, bool loadRequestBody, OpenApiDocument hostDocument = null)
public static OpenApiParameter LoadParameter(ParseNode node, bool loadRequestBody, OpenApiDocument hostDocument)
{
// Reset the local variables every time this method is called.
node.Context.SetTempStorage(TempStorageKeys.ParameterIsBodyOrFormData, false);
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))},
};

public static OpenApiPathItem LoadPathItem(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiPathItem LoadPathItem(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("PathItem");

@@ -54,12 +54,12 @@ public static OpenApiPathItem LoadPathItem(ParseNode node, OpenApiDocument hostD
return pathItem;
}

private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node, OpenApiDocument hostDocument = null)
private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node, OpenApiDocument hostDocument)
{
node.Context.SetTempStorage(TempStorageKeys.BodyParameter, null);
node.Context.SetTempStorage(TempStorageKeys.FormParameters, null);

pathItem.Parameters = node.CreateList(LoadParameter);
pathItem.Parameters = node.CreateList(LoadParameter, hostDocument);

// Build request body based on information determined while parsing OpenApiOperation
var bodyParameter = node.Context.GetFromTempStorage<OpenApiParameter>(TempStorageKeys.BodyParameter);
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

public static OpenApiPaths LoadPaths(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiPaths LoadPaths(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("Paths");

Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P
context.SetTempStorage(TempStorageKeys.ResponseProducesSet, true, response);
}

private static void LoadResponseExamplesExtension(OpenApiResponse response, ParseNode node, OpenApiDocument hostDocument = null)
private static void LoadResponseExamplesExtension(OpenApiResponse response, ParseNode node, OpenApiDocument hostDocument)
{
var examples = LoadExamplesExtension(node);
node.Context.SetTempStorage(TempStorageKeys.Examples, examples, response);
@@ -145,7 +145,7 @@ private static Dictionary<string, OpenApiExample> LoadExamplesExtension(ParseNod
return examples;
}

private static void LoadExamples(OpenApiResponse response, ParseNode node, OpenApiDocument hostDocument = null)
private static void LoadExamples(OpenApiResponse response, ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("examples");

@@ -178,7 +178,7 @@ private static void LoadExample(OpenApiResponse response, string mediaType, Pars
mediaTypeObject.Example = exampleNode;
}

public static OpenApiResponse LoadResponse(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiResponse LoadResponse(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("response");

@@ -193,7 +193,7 @@ public static OpenApiResponse LoadResponse(ParseNode node, OpenApiDocument hostD

foreach (var property in mapNode)
{
property.ParseField(response, _responseFixedFields, _responsePatternFields);
property.ParseField(response, _responseFixedFields, _responsePatternFields, hostDocument);
}

foreach (var mediaType in response.Content.Values)
14 changes: 7 additions & 7 deletions src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs
Original file line number Diff line number Diff line change
@@ -93,22 +93,22 @@ internal static partial class OpenApiV2Deserializer
},
{
"items",
(o, n, _) => o.Items = LoadSchema(n)
(o, n, doc) => o.Items = LoadSchema(n, doc)
},
{
"properties",
(o, n, t) => o.Properties = n.CreateMap(LoadSchema, t)
},
{
"additionalProperties", (o, n, _) =>
"additionalProperties", (o, n, doc) =>
{
if (n is ValueNode)
{
o.AdditionalPropertiesAllowed = bool.Parse(n.GetScalarValue());
}
else
{
o.AdditionalProperties = LoadSchema(n);
o.AdditionalProperties = LoadSchema(n, doc);
}
}
},
@@ -139,11 +139,11 @@ internal static partial class OpenApiV2Deserializer
},
{
"xml",
(o, n, _) => o.Xml = LoadXml(n)
(o, n, doc) => o.Xml = LoadXml(n, doc)
},
{
"externalDocs",
(o, n, _) => o.ExternalDocs = LoadExternalDocs(n)
(o, n, doc) => o.ExternalDocs = LoadExternalDocs(n, doc)
},
{
"example",
@@ -156,7 +156,7 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

public static OpenApiSchema LoadSchema(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiSchema LoadSchema(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("schema");

@@ -171,7 +171,7 @@ public static OpenApiSchema LoadSchema(ParseNode node, OpenApiDocument hostDocum

foreach (var propertyNode in mapNode)
{
propertyNode.ParseField(schema, _openApiSchemaFixedFields, _openApiSchemaPatternFields);
propertyNode.ParseField(schema, _openApiSchemaFixedFields, _openApiSchemaPatternFields, hostDocument);
}

return schema;
Original file line number Diff line number Diff line change
@@ -80,10 +80,10 @@
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

public static OpenApiSecurityScheme LoadSecurityScheme(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiSecurityScheme LoadSecurityScheme(ParseNode node, OpenApiDocument hostDocument)
{
// Reset the local variables every time this method is called.
// TODO: Change _flow to a tempStorage variable to make the deserializer thread-safe.

Check warning on line 86 in src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
_flowValue = null;
_flow = new();

@@ -92,7 +92,7 @@
var securityScheme = new OpenApiSecurityScheme();
foreach (var property in mapNode)
{
property.ParseField(securityScheme, _securitySchemeFixedFields, _securitySchemePatternFields);
property.ParseField(securityScheme, _securitySchemeFixedFields, _securitySchemePatternFields, hostDocument);
}

// Put the Flow object in the right Flows property based on the string in "flow"
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi/Reader/V2/OpenApiTagDeserializer.cs
Original file line number Diff line number Diff line change
@@ -34,15 +34,15 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
};

public static OpenApiTag LoadTag(ParseNode n, OpenApiDocument hostDocument = null)
public static OpenApiTag LoadTag(ParseNode n, OpenApiDocument hostDocument)
{
var mapNode = n.CheckMapNode("tag");

var domainObject = new OpenApiTag();

foreach (var propertyNode in mapNode)
{
propertyNode.ParseField(domainObject, _tagFixedFields, _tagPatternFields);
propertyNode.ParseField(domainObject, _tagFixedFields, _tagPatternFields, hostDocument);
}

return domainObject;
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ private static void ProcessAnyFields<T>(
}
}

public static JsonNode LoadAny(ParseNode node, OpenApiDocument hostDocument = null)
public static JsonNode LoadAny(ParseNode node, OpenApiDocument hostDocument)
{
return node.CreateAny();
}
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi/Reader/V2/OpenApiXmlDeserializer.cs
Original file line number Diff line number Diff line change
@@ -54,14 +54,14 @@ internal static partial class OpenApiV2Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p,n))}
};

public static OpenApiXml LoadXml(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiXml LoadXml(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("xml");

var xml = new OpenApiXml();
foreach (var property in mapNode)
{
property.ParseField(xml, _xmlFixedFields, _xmlPatternFields);
property.ParseField(xml, _xmlFixedFields, _xmlPatternFields, hostDocument);
}

return xml;
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ internal static partial class OpenApiV3Deserializer
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p,n))},
};

public static OpenApiCallback LoadCallback(ParseNode node, OpenApiDocument hostDocument = null)
public static OpenApiCallback LoadCallback(ParseNode node, OpenApiDocument hostDocument)
{
var mapNode = node.CheckMapNode("callback");

Loading

Unchanged files with check annotations Beta

/// Comparer for OpenApiSecurityScheme that only considers the Id in the Reference
/// (i.e. the string that will actually be displayed in the written document)
/// </summary>
private class OpenApiSecuritySchemeReferenceEqualityComparer : IEqualityComparer<OpenApiSecurityScheme>

Check warning on line 126 in src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs

GitHub Actions / Build

Private classes which are not derived in the current assembly should be marked as 'sealed'. (https://rules.sonarsource.com/csharp/RSPEC-3260)
{
/// <summary>
/// Determines whether the specified objects are equal.
var currentScope = CurrentScope();
// If the object is empty, indicate it by writing { }

Check warning on line 75 in src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs

GitHub Actions / Build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
if (previousScope.ObjectCount == 0)
{
// If we are in an object, write a white space preceding the braces.
namespace Microsoft.OpenApi
{
internal static class OpenAPIWriterExtensions

Check warning on line 5 in src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs

GitHub Actions / Build

Rename class 'OpenAPIWriterExtensions' to match pascal case naming rules, consider using 'OpenApiWriterExtensions'. (https://rules.sonarsource.com/csharp/RSPEC-101)
{
/// <summary>
/// Temporary extension method until we add Settings property to IOpenApiWriter in next major version
return schemaType switch
{
JsonSchemaType.Null => "null",
JsonSchemaType.Boolean => "boolean",

Check warning on line 41 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

GitHub Actions / Build

Define a constant instead of using this literal 'boolean' 4 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
JsonSchemaType.Integer => "integer",

Check warning on line 42 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

GitHub Actions / Build

Define a constant instead of using this literal 'integer' 8 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
JsonSchemaType.Number => "number",

Check warning on line 43 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

GitHub Actions / Build

Define a constant instead of using this literal 'number' 14 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
JsonSchemaType.String => "string",

Check warning on line 44 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

GitHub Actions / Build

Define a constant instead of using this literal 'string' 13 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
JsonSchemaType.Array => "array",
JsonSchemaType.Object => "object",
_ => null,
"null" => JsonSchemaType.Null,
"boolean" => JsonSchemaType.Boolean,
"integer" or "int" => JsonSchemaType.Integer,
"number" or "double" or "float" or "decimal"=> JsonSchemaType.Number,

Check warning on line 64 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

GitHub Actions / Build

Define a constant instead of using this literal 'double' 7 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)

Check warning on line 64 in src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

GitHub Actions / Build

Define a constant instead of using this literal 'float' 5 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
"string" => JsonSchemaType.String,
"array" => JsonSchemaType.Array,
"object" => JsonSchemaType.Object,