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

JsonSchema.NET Integration #1278

Merged
merged 225 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
225 commits
Select commit Hold shift + click to select a range
bb672c4
Merge branch 'mk/add-json-schema-dialect' into mk/integrate-json-sche…
MaggieKimani1 Jan 30, 2023
1a44fe8
Use JsonSchema.NET for full Json schema support
MaggieKimani1 Feb 21, 2023
dd60371
Merge remote-tracking branch 'origin/release/2.0.0' into mk/integrate…
MaggieKimani1 Mar 8, 2023
3afe5c7
Decouple v3 and v3.1 deserialization logic by adding a separate 3.1 d…
MaggieKimani1 Mar 20, 2023
043f5d7
Parse 3.1 fragments
MaggieKimani1 Mar 20, 2023
4b8f8aa
Clean up tests
MaggieKimani1 Mar 20, 2023
dd62076
Update test
MaggieKimani1 Mar 21, 2023
4fa6efe
Add extensions property to discriminator for 3.1
MaggieKimani1 Mar 23, 2023
3d362c3
Update packages
MaggieKimani1 Mar 23, 2023
ebece81
Add a separate schema31 property to model objects before we figure ou…
MaggieKimani1 Mar 23, 2023
b837812
Assign node values during schema property mapping
MaggieKimani1 Mar 23, 2023
f2b3721
Add test with advanced schema
MaggieKimani1 Mar 23, 2023
accf19c
Clean up tests
MaggieKimani1 Mar 23, 2023
e93c6ca
Merge branch 'mk/use-json-node-for-parsing' into mk/integrate-json-sc…
MaggieKimani1 May 23, 2023
4a46c6f
Auto stash before merge of "mk/integrate-json-schema-library" and "mk…
MaggieKimani1 May 23, 2023
02001c3
Refactor V31 Deserializer
MaggieKimani1 May 29, 2023
cf65ddb
Replace OpenApiSchema with JsonSchema and clean up code
MaggieKimani1 Jun 5, 2023
7ea161c
Adds a JsonSchemaBuilderExtensions class to support draft 4 keywords etc
MaggieKimani1 Jun 15, 2023
c2b83d8
Clean up and add a JsonNode property in ParseNode
MaggieKimani1 Jun 15, 2023
113e07f
Project refactor
MaggieKimani1 Jun 15, 2023
8f4da17
Set format based on the value within the nested schema and clean up code
MaggieKimani1 Jun 15, 2023
66333a9
Clean up tests
MaggieKimani1 Jun 15, 2023
d4c9630
Adds logic to serialize Json schema output to yaml format
MaggieKimani1 Jun 19, 2023
df06a39
Adds a schema keyword attribute
MaggieKimani1 Jun 19, 2023
e2b1602
Clean up test
MaggieKimani1 Jun 19, 2023
151a3ff
Merge branch 'release/2.0.0' into mk/integrate-json-schema-library
MaggieKimani1 Jun 19, 2023
dc4e16f
Clean up deserializers and tests
MaggieKimani1 Jun 20, 2023
2f5bd23
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
MaggieKimani1 Jun 20, 2023
2e85912
Code cleanup on running code analysis
MaggieKimani1 Jun 20, 2023
57c3f39
Reduce code smells
MaggieKimani1 Jun 20, 2023
bcd1ac2
More refactoring
MaggieKimani1 Jun 21, 2023
52468a5
Rename Schema31 to Schema
MaggieKimani1 Jul 18, 2023
4ede8e6
Remove OpenApiSchema as its obsolete
MaggieKimani1 Jul 18, 2023
c762968
Add WriteJsonSchema() method to the interface and implement it in the…
MaggieKimani1 Jul 20, 2023
264bb2b
Revert some changes and clean up code
MaggieKimani1 Jul 20, 2023
541a353
Resolve merger conflicts
MaggieKimani1 Jul 21, 2023
9e69232
Fix json schema format indentation
MaggieKimani1 Jul 25, 2023
4f5e04e
Clean up tests
MaggieKimani1 Jul 25, 2023
3c1f644
Ref resolution
MaggieKimani1 Jul 25, 2023
250ab7b
Fix more tests
MaggieKimani1 Jul 25, 2023
bfc934c
Clean up code
MaggieKimani1 Jul 25, 2023
c4510b9
Merge branch 'mk/integrate-json-schema-library' into is/json-schema-l…
irvinesunday Jul 26, 2023
db7891d
Add pathItems field to the components deserializer
MaggieKimani1 Jul 27, 2023
9482cbd
Remove generic type constraint
irvinesunday Jul 27, 2023
df6006d
Revert removed code; replace OpenApiSchema class with JsonSchema
irvinesunday Jul 27, 2023
8b319ca
Merge branch 'mk/integrate-json-schema-library' into is/json-schema-l…
irvinesunday Jul 27, 2023
dc23acd
Remove unnecessary using
irvinesunday Jul 27, 2023
36aa780
Remove generic type constraint since JsonSchema isn't an IOpenApiElement
MaggieKimani1 Jul 28, 2023
fd7341f
Add discriminator keyword
irvinesunday Jul 28, 2023
65a57c7
Fix schema indentation in tests
MaggieKimani1 Jul 28, 2023
cecde5d
Add extra properties to JsonSchemaWrapper
irvinesunday Aug 3, 2023
20d90e4
Add JsonSchemaWrapper method
irvinesunday Aug 4, 2023
9020fa5
Use JsonSchemaWrapper in place in place of SchemaWrapper
irvinesunday Aug 4, 2023
772f274
Registers schemas to the global SchemaRegistry and retrieving them du…
MaggieKimani1 Aug 15, 2023
3b59e4c
Update ReferenceResolver class with methods to resolve JsonSchema $refs
MaggieKimani1 Aug 15, 2023
108bb1b
Use Any() to test whether the IEnumerable collection is empty or not
MaggieKimani1 Aug 16, 2023
17255f3
If a schema has a $ref, append it to the builder as a Ref keyword
MaggieKimani1 Aug 16, 2023
4cbbab2
Register JSON schemas in components as schemas in the SchemaRegistry …
MaggieKimani1 Aug 16, 2023
f1b659f
Fix failing tests
MaggieKimani1 Aug 16, 2023
9f9d435
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Aug 16, 2023
1c8dacb
More code cleanup
MaggieKimani1 Aug 16, 2023
e2830e6
Add IBaseDocument as a type constraint in generic method
irvinesunday Aug 16, 2023
b64cd83
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Aug 16, 2023
f96918a
Fix validation tests
irvinesunday Aug 21, 2023
8eb57fe
Merge remote-tracking branch 'origin/is/json-schema-lib-integration' …
irvinesunday Aug 21, 2023
878a72c
Add Visitor for IBaseDocument
irvinesunday Aug 21, 2023
b1f4cb7
Revert code
irvinesunday Aug 22, 2023
9ae317a
Check for schema reference
irvinesunday Aug 22, 2023
d11533e
Remove unnecessary class
irvinesunday Aug 22, 2023
c1b774f
Merge remote-tracking branch 'origin/is/json-schema-lib-integration' …
MaggieKimani1 Aug 22, 2023
1fb8547
Auto stash before merge of "mk/integrate-json-schema-library" and "or…
MaggieKimani1 Aug 22, 2023
52db2ec
Clean up build errors
MaggieKimani1 Aug 22, 2023
34154fa
Update $ref path
MaggieKimani1 Aug 22, 2023
02800f3
Fix YamlWriter tests
irvinesunday Aug 22, 2023
4d965dc
Remove unnecessary code
irvinesunday Aug 22, 2023
780a12f
Remove generic constraint
irvinesunday Aug 22, 2023
6376640
Fix tests
irvinesunday Aug 22, 2023
5d44882
Code clean up
MaggieKimani1 Aug 23, 2023
6130485
Add a WriteJsonSchemaWithoutReference() method
MaggieKimani1 Aug 24, 2023
8c41134
Merge branch 'mk/integrate-json-schema-library' into is/json-schema-l…
irvinesunday Aug 24, 2023
9f63183
Add logic for checking self-referencing components and stripping out …
MaggieKimani1 Aug 24, 2023
0629de3
Add missing methods
MaggieKimani1 Aug 24, 2023
3d8019e
Write out individual schema properties
MaggieKimani1 Aug 25, 2023
7d0ac24
Merge branch 'mk/integrate-json-schema-library' into is/json-schema-l…
irvinesunday Aug 28, 2023
322544f
Add extension methods for JsonSchema property getters
irvinesunday Aug 28, 2023
8996c84
Refactor JsonSchema writer into base class
irvinesunday Aug 28, 2023
a435d64
Refactor out WriteJsonSchema from YamlWriter to BaseWriter
irvinesunday Aug 28, 2023
08b4113
Update WriterBase and WriterSettings
irvinesunday Aug 29, 2023
710ccea
Merge remote-tracking branch 'origin/is/json-schema-lib-integration' …
MaggieKimani1 Aug 29, 2023
26943c4
Auto stash before merge of "mk/integrate-json-schema-library" and "or…
MaggieKimani1 Aug 29, 2023
ca9df42
Move if() block inside the outer if() conditional check
MaggieKimani1 Aug 29, 2023
9a15592
Fix write method to avoid duplication of properties and remove unnece…
MaggieKimani1 Aug 29, 2023
4e4da8e
Update verified file
MaggieKimani1 Aug 29, 2023
2bb28f0
Invert conditional; add null check
irvinesunday Aug 29, 2023
b7a014f
Update tests
irvinesunday Aug 29, 2023
f8a616b
Add null check, update verified output files
MaggieKimani1 Aug 29, 2023
b998b7d
Add base uri to schema
irvinesunday Aug 29, 2023
31b946e
Remove base uri
irvinesunday Aug 29, 2023
2672575
Update verified output files
MaggieKimani1 Aug 29, 2023
3e7584b
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Aug 29, 2023
c1f0713
Refactor conditional statement
irvinesunday Aug 30, 2023
1c1388d
Uncomment code
irvinesunday Aug 30, 2023
a6f75df
Add extensions to tests
irvinesunday Aug 30, 2023
bb72685
Update verified txt files
irvinesunday Aug 30, 2023
17d8670
Introduce variable to hold extensions
irvinesunday Aug 30, 2023
3b686a5
Merge branch 'is/json-schema-lib-integration' into mk/integrate-json-…
MaggieKimani1 Aug 31, 2023
bfb0530
Update verified files and expected test output
MaggieKimani1 Aug 31, 2023
22613a1
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Aug 31, 2023
988869f
Auto stash before merge of "is/json-schema-lib-integration" and "orig…
irvinesunday Aug 31, 2023
5257198
Write out UInt types
MaggieKimani1 Aug 31, 2023
f947dc0
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Aug 31, 2023
11edf02
Update conditional for writing out JsonSchema in components
irvinesunday Aug 31, 2023
97f347f
Exclude JsonSchema with $ref from validation
irvinesunday Aug 31, 2023
aef9139
Update validation test
irvinesunday Aug 31, 2023
ad78a6b
Use GetOrCreateJsonSchemaBuilder method
irvinesunday Sep 1, 2023
51492e9
Ensure static fields are always reset before being accessed
irvinesunday Sep 4, 2023
857433f
Remove validation test for JsonSchema refs
irvinesunday Sep 4, 2023
f299eec
Uncomment test
irvinesunday Sep 4, 2023
e3c4070
Return a schema with a Ref keyword if a reference pointer exists
MaggieKimani1 Sep 5, 2023
8445645
Revert change
MaggieKimani1 Sep 5, 2023
43e7d77
Clean up test
MaggieKimani1 Sep 5, 2023
7b8a959
Merge remote-tracking branch 'origin/is/json-schema-lib-integration' …
MaggieKimani1 Sep 5, 2023
0feb273
Remove test as we're now using JsonSchema
MaggieKimani1 Sep 5, 2023
6bc8a1d
Clean up test
MaggieKimani1 Sep 5, 2023
dd97ff3
Remove commented out code
MaggieKimani1 Sep 5, 2023
11e20aa
Code cleanup
MaggieKimani1 Sep 6, 2023
fff29e4
Change how we assign and retrieve schema values from Global.Registry
irvinesunday Sep 6, 2023
f1c4987
Update verified tests txt files
irvinesunday Sep 6, 2023
28969c3
Update tests
irvinesunday Sep 6, 2023
46e8e2e
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Sep 6, 2023
2e81fc2
Merge remote-tracking branch 'origin/is/json-schema-lib-integration' …
MaggieKimani1 Sep 6, 2023
6d228ed
Add a visit method that returns a JsonSchema instance; assign the res…
MaggieKimani1 Sep 11, 2023
8314c31
Clean up code
MaggieKimani1 Sep 11, 2023
4871242
Revert schema reference resolution assignment
irvinesunday Sep 12, 2023
2fd1591
Merge branch 'mk/integrate-json-schema-library' into is/json-schema-l…
irvinesunday Sep 12, 2023
4424c85
Merge remote-tracking branch 'origin/is/json-schema-lib-integration' …
MaggieKimani1 Sep 12, 2023
c9ef228
Pass JsonSchema by reference
irvinesunday Sep 12, 2023
eb633a1
Temporarily comment out test
irvinesunday Sep 12, 2023
a579c4c
Merge remote-tracking branch 'origin/is/json-schema-lib-integration' …
MaggieKimani1 Sep 12, 2023
e74d93c
Add method for registering schemas in the components section to the g…
MaggieKimani1 Sep 13, 2023
7591c32
Remove unnecessary refs
MaggieKimani1 Sep 13, 2023
2ff2667
Add null check
MaggieKimani1 Sep 13, 2023
58a1183
Clean up test
MaggieKimani1 Sep 13, 2023
7991022
Remove test due to alternate reference resolution logic
MaggieKimani1 Sep 13, 2023
38077d9
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Sep 13, 2023
3d321be
Remove unnecessary ref
MaggieKimani1 Sep 14, 2023
b5805a0
Add SchemaSpecVersion attribute
irvinesunday Sep 14, 2023
c946aba
Use OpenApiDiscriminator
irvinesunday Sep 14, 2023
e3fbee8
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Sep 14, 2023
eb75b6b
Add missing fields to the content-type schema generated
MaggieKimani1 Sep 14, 2023
601a3f6
Add a summary keyword to the JsonSchemaBuilder
MaggieKimani1 Sep 14, 2023
f904f32
Retrieve the summary keyword value
MaggieKimani1 Sep 14, 2023
b167d6d
Add logic for replacing the resolved schema's summary and description…
MaggieKimani1 Sep 14, 2023
4faf403
Update test
MaggieKimani1 Sep 14, 2023
978486e
Remove unused class
irvinesunday Sep 14, 2023
242edaf
Rename from OpenApiSchema to JsonSchema
irvinesunday Sep 14, 2023
7960421
Remove redundant class
MaggieKimani1 Sep 14, 2023
99c0a63
Auto stash before merge of "mk/integrate-json-schema-library" and "or…
MaggieKimani1 Sep 18, 2023
890c37a
Remove class
MaggieKimani1 Sep 18, 2023
63a48fd
Merge branch 'mk/integrate-json-schema-library' into is/json-schema-l…
irvinesunday Sep 18, 2023
2b52cbc
Add methods to retrieve the summary and description values from the n…
MaggieKimani1 Sep 18, 2023
7e963e7
Retrieve the description and summary values from the nodes and append…
MaggieKimani1 Sep 18, 2023
2351e24
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Sep 18, 2023
85937c7
Refactor test
MaggieKimani1 Sep 19, 2023
9b7e488
Remove commented code
MaggieKimani1 Sep 19, 2023
15bd390
Resolve components schemas; assign resolved referenceable properties;…
irvinesunday Sep 19, 2023
ff5899b
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
irvinesunday Sep 19, 2023
e323149
Serialize components before asserting equality
irvinesunday Sep 19, 2023
2e27cd9
Add temporary JsonSchema $ref validation
irvinesunday Sep 19, 2023
478e08f
Rename schema to disambiguate from other schemas with similar name
irvinesunday Sep 20, 2023
767399f
Merge remote-tracking branch 'origin/is/json-schema-lib-integration' …
MaggieKimani1 Sep 21, 2023
6a28240
Add whitespace between key and value
MaggieKimani1 Sep 21, 2023
f9781e3
Use null coalesce
MaggieKimani1 Sep 22, 2023
3f43391
Clean up test
MaggieKimani1 Sep 27, 2023
6a72c05
Split the reference string and pick the last segment for resolution
MaggieKimani1 Oct 2, 2023
4ed5251
Resolve JSON schema references from within the workspace
MaggieKimani1 Oct 2, 2023
c0f878f
Refactor code
MaggieKimani1 Oct 3, 2023
62b089a
Refactor failing test
MaggieKimani1 Oct 3, 2023
5f8b0ce
Update test
MaggieKimani1 Oct 3, 2023
2a4a780
Add a method for processing JSON schemas as references
MaggieKimani1 Oct 17, 2023
e417084
Fix failing test
MaggieKimani1 Oct 17, 2023
907e1df
Revert "Add a method for processing JSON schemas as references"
MaggieKimani1 Oct 17, 2023
50fec01
Adds a method for visiting IBaseDocument instances
MaggieKimani1 Oct 17, 2023
adc4b67
Remove unused/commented out code
MaggieKimani1 Oct 17, 2023
bcb7fc7
Update public API
MaggieKimani1 Oct 17, 2023
1410672
Delete tests
MaggieKimani1 Oct 17, 2023
d92509f
More cleanup
MaggieKimani1 Oct 17, 2023
69e6d81
Fix code smells
MaggieKimani1 Oct 18, 2023
26ae208
Use constant
MaggieKimani1 Oct 18, 2023
0cfe904
Upgrade java version
MaggieKimani1 Oct 18, 2023
2b21a91
Reduce code smells
MaggieKimani1 Oct 18, 2023
984aa09
Delete test
MaggieKimani1 Oct 19, 2023
2b1613f
Make static fields readonly
MaggieKimani1 Oct 19, 2023
45edb76
Update src/Microsoft.OpenApi.Readers/V31/JsonSchemaDeserializer.cs
MaggieKimani1 Oct 19, 2023
4e664e0
Update src/Microsoft.OpenApi.Readers/V31/OpenApiCallbackDeserializer.cs
MaggieKimani1 Oct 19, 2023
cefc069
Update src/Microsoft.OpenApi.Readers/V31/OpenApiCallbackDeserializer.cs
MaggieKimani1 Oct 19, 2023
1d81b81
Update src/Microsoft.OpenApi.Readers/V31/OpenApiCallbackDeserializer.cs
MaggieKimani1 Oct 19, 2023
585a5af
Update src/Microsoft.OpenApi.Readers/V31/OpenApiComponentsDeserialize…
MaggieKimani1 Oct 19, 2023
9989cf1
Make static fields readonly
MaggieKimani1 Oct 19, 2023
16c6251
Normalize the incoming value
MaggieKimani1 Oct 19, 2023
2c2f973
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
MaggieKimani1 Oct 19, 2023
e6de4a8
Add missing using
MaggieKimani1 Oct 19, 2023
1075617
Simplify string normalization
MaggieKimani1 Oct 23, 2023
32bf960
Use the null ternary operator
MaggieKimani1 Oct 23, 2023
e69035b
Explicit sequence filtering using Linq's .Where
MaggieKimani1 Oct 23, 2023
f268d9a
Remove redundant cast
MaggieKimani1 Oct 23, 2023
ba12d86
Avoid using virtual calls in constructor
MaggieKimani1 Oct 23, 2023
8b4cc04
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
MaggieKimani1 Oct 23, 2023
1f00b44
Use ternary operator
MaggieKimani1 Oct 24, 2023
6b72765
Revert change
MaggieKimani1 Oct 24, 2023
6e65633
Remove unnecessary usings
MaggieKimani1 Oct 24, 2023
f9b52cd
Attempt at fixing sonarcloud virtual call in ctor flag
MaggieKimani1 Oct 24, 2023
0b717a4
Add a protected modifier to the virtual property
MaggieKimani1 Oct 24, 2023
bf51aa8
Revert "Add a protected modifier to the virtual property"
MaggieKimani1 Oct 24, 2023
8389913
Assign to a backing property in copy constructor instead of the virtu…
MaggieKimani1 Oct 24, 2023
9d228ae
Fix sonarcloud bug
MaggieKimani1 Oct 24, 2023
29173e0
Fix another bug
MaggieKimani1 Oct 24, 2023
8072bad
Reduce code smells
MaggieKimani1 Oct 24, 2023
76a41de
Use camel casing for property name
MaggieKimani1 Nov 8, 2023
78b65b5
Merge remote-tracking branch 'origin/mk/integrate-json-schema-library…
MaggieKimani1 Nov 8, 2023
d4eef1b
Add test
MaggieKimani1 Nov 9, 2023
236a48d
Address PR feedback
MaggieKimani1 Nov 16, 2023
076009c
Clean up code
MaggieKimani1 Nov 16, 2023
e8ecc1a
Return previously deleted method
MaggieKimani1 Nov 16, 2023
1afe195
Update the schema registry reference URI and public API
MaggieKimani1 Nov 21, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
name: Build
runs-on: windows-latest
steps:
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 11
java-version: 17
- name: Setup .NET 5 # At the moment the scanner requires dotnet 5 https://www.nuget.org/packages/dotnet-sonarscanner
uses: actions/setup-dotnet@v3
with:
Expand Down
74 changes: 37 additions & 37 deletions src/Microsoft.OpenApi.Hidi/OpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
using System.IO;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using System.Text.Json;
using Microsoft.Extensions.Logging;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Xsl;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.OData.Edm.Csdl;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
Expand All @@ -21,11 +26,6 @@
using Microsoft.OpenApi.Services;
using Microsoft.OpenApi.Writers;
using static Microsoft.OpenApi.Hidi.OpenApiSpecVersionHelper;
using System.Threading;
using System.Xml.Xsl;
using System.Xml;
using System.Reflection;
using Microsoft.Extensions.Configuration;

namespace Microsoft.OpenApi.Hidi
{
Expand All @@ -40,7 +40,7 @@
string csdlFilter,
FileInfo output,
bool cleanoutput,
string? version,

Check warning on line 43 in src/Microsoft.OpenApi.Hidi/OpenApiService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 43 in src/Microsoft.OpenApi.Hidi/OpenApiService.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
string metadataVersion,
OpenApiFormat? format,
bool terseOutput,
Expand Down Expand Up @@ -98,7 +98,7 @@
}
}

private static void WriteOpenApi(FileInfo output, bool terseOutput, bool inlineLocal, bool inlineExternal, OpenApiFormat openApiFormat, OpenApiSpecVersion openApiVersion, OpenApiDocument document, ILogger logger)
private static void WriteOpenApi(FileInfo output, bool terseOutput, bool inlineLocal, bool inlineExternal, OpenApiFormat openApiFormat, OpenApiSpecVersion openApiVersion, OpenApiDocument document, ILogger logger)
{
using (logger.BeginScope("Output"))
{
Expand Down Expand Up @@ -135,7 +135,7 @@
{
OpenApiDocument document;
Stream stream;

if (!string.IsNullOrEmpty(csdl))
{
var stopwatch = new Stopwatch();
Expand Down Expand Up @@ -168,7 +168,7 @@
return document;
}

private static async Task<OpenApiDocument> FilterOpenApiDocument(string filterbyoperationids, string filterbytags, string filterbycollection, OpenApiDocument document, ILogger logger, CancellationToken cancellationToken)
private static async Task<OpenApiDocument> FilterOpenApiDocument(string filterbyoperationids, string filterbytags, string filterbycollection, OpenApiDocument document, ILogger logger, CancellationToken cancellationToken)
{
using (logger.BeginScope("Filter"))
{
Expand Down Expand Up @@ -239,8 +239,8 @@
/// Implementation of the validate command
/// </summary>
public static async Task ValidateOpenApiDocument(
string openapi,
ILogger logger,
string openapi,
ILogger logger,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(openapi))
Expand Down Expand Up @@ -285,7 +285,7 @@
result = await new OpenApiStreamReader(new OpenApiReaderSettings
{
LoadExternalRefs = inlineExternal,
BaseUrl = openApiFile.StartsWith("http", StringComparison.OrdinalIgnoreCase) ?
BaseUrl = openApiFile.StartsWith("http", StringComparison.OrdinalIgnoreCase) ?
new Uri(openApiFile) :
new Uri("file://" + new FileInfo(openApiFile).DirectoryName + Path.DirectorySeparatorChar)
}
Expand All @@ -296,7 +296,7 @@
LogErrors(logger, result);
stopwatch.Stop();
}

return result;
}

Expand All @@ -310,7 +310,7 @@

return config;
}

/// <summary>
/// Converts CSDL to OpenAPI
/// </summary>
Expand All @@ -329,7 +329,7 @@
{
settings.SemVerVersion = metadataVersion;
}

config.GetSection("OpenApiConvertSettings").Bind(settings);

OpenApiDocument document = edmModel.ConvertToOpenApi(settings);
Expand All @@ -354,7 +354,7 @@

return doc;
}

/// <summary>
/// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods
/// </summary>
Expand All @@ -377,13 +377,13 @@
private static Dictionary<string, List<string>> EnumerateJsonDocument(JsonElement itemElement, Dictionary<string, List<string>> paths)
{
var itemsArray = itemElement.GetProperty("item");

foreach (var item in itemsArray.EnumerateArray())
{
if(item.ValueKind == JsonValueKind.Object)
if (item.ValueKind == JsonValueKind.Object)
{
if(item.TryGetProperty("request", out var request))
{
if (item.TryGetProperty("request", out var request))
{
// Fetch list of methods and urls from collection, store them in a dictionary
var path = request.GetProperty("url").GetProperty("raw").ToString();
var method = request.GetProperty("method").ToString();
Expand All @@ -395,11 +395,11 @@
{
paths[path].Add(method);
}
}
else
{
}
else
{
EnumerateJsonDocument(item, paths);
}
}
}
else
{
Expand Down Expand Up @@ -508,11 +508,11 @@
if (output == null)
{
var tempPath = Path.GetTempPath() + "/hidi/";
if(!File.Exists(tempPath))
if (!File.Exists(tempPath))
{
Directory.CreateDirectory(tempPath);
}
}

var fileName = Path.GetRandomFileName();

output = new FileInfo(Path.Combine(tempPath, fileName + ".html"));
Expand All @@ -528,7 +528,7 @@
process.StartInfo.FileName = output.FullName;
process.StartInfo.UseShellExecute = true;
process.Start();

return output.FullName;
}
else // Write diagram as Markdown document to output file
Expand All @@ -540,7 +540,7 @@
}
logger.LogTrace("Created markdown document with diagram ");
return output.FullName;
}
}
}
}
catch (TaskCanceledException)
Expand All @@ -563,7 +563,7 @@
{
foreach (var error in context.Errors)
{
logger.LogError($"Detected error during parsing: {error}",error.ToString());
logger.LogError($"Detected error during parsing: {error}", error.ToString());
}
}
}
Expand All @@ -581,7 +581,7 @@
// write a span for each mermaidcolorscheme
foreach (var style in OpenApiUrlTreeNode.MermaidNodeStyles)
{
writer.WriteLine($"<span style=\"padding:2px;background-color:{style.Value.Color};border: 2px solid\">{style.Key.Replace("_"," ")}</span>");
writer.WriteLine($"<span style=\"padding:2px;background-color:{style.Value.Color};border: 2px solid\">{style.Key.Replace("_", " ")}</span>");
}
writer.WriteLine("</div>");
writer.WriteLine();
Expand Down Expand Up @@ -609,7 +609,7 @@
writer.WriteLine("<h1>" + document.Info.Title + "</h1>");
writer.WriteLine();
writer.WriteLine($"<h3> API Description: <a href='{sourceUrl}'>{sourceUrl}</a></h3>");

writer.WriteLine(@"<div>");
// write a span for each mermaidcolorscheme
foreach (var style in OpenApiUrlTreeNode.MermaidNodeStyles)
Expand All @@ -622,8 +622,8 @@
rootNode.WriteMermaid(writer);
writer.WriteLine("</code>");

// Write script tag to include JS library for rendering markdown
writer.WriteLine(@"<script>
// Write script tag to include JS library for rendering markdown
writer.WriteLine(@"<script>
var config = {
startOnLoad:true,
theme: 'forest',
Expand All @@ -635,8 +635,8 @@
mermaid.initialize(config);
window.mermaid.init(undefined, document.querySelectorAll('.language-mermaid'));
</script>");
// Write script tag to include JS library for rendering mermaid
writer.WriteLine("</html");
// Write script tag to include JS library for rendering mermaid
writer.WriteLine("</html");
}
}
}
5 changes: 1 addition & 4 deletions src/Microsoft.OpenApi.Hidi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.CommandLine;
using System.CommandLine.Parsing;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Hidi.Handlers;
Expand Down Expand Up @@ -43,15 +40,15 @@
var cleanOutputOption = new Option<bool>("--clean-output", "Overwrite an existing file");
cleanOutputOption.AddAlias("--co");

var versionOption = new Option<string?>("--version", "OpenAPI specification version");

Check warning on line 43 in src/Microsoft.OpenApi.Hidi/Program.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 43 in src/Microsoft.OpenApi.Hidi/Program.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
versionOption.AddAlias("-v");

var metadataVersionOption = new Option<string?>("--metadata-version", "Graph metadata version to use.");

Check warning on line 46 in src/Microsoft.OpenApi.Hidi/Program.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 46 in src/Microsoft.OpenApi.Hidi/Program.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
metadataVersionOption.AddAlias("--mv");

var formatOption = new Option<OpenApiFormat?>("--format", "File format");
formatOption.AddAlias("-f");

var terseOutputOption = new Option<bool>("--terse-output", "Produce terse json output");
terseOutputOption.AddAlias("--to");

Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.OpenApi.Hidi/StatsVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using Json.Schema;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Services;

Expand All @@ -19,7 +20,7 @@ public override void Visit(OpenApiParameter parameter)

public int SchemaCount { get; set; } = 0;

public override void Visit(OpenApiSchema schema)
public override void Visit(ref JsonSchema schema)
{
SchemaCount++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Exceptions;
using SharpYaml.Serialization;

namespace Microsoft.OpenApi.Readers.Exceptions
{
Expand All @@ -30,7 +29,8 @@ public OpenApiReaderException(string message) : base(message) { }
/// </summary>
/// <param name="message">Plain text error message for this exception.</param>
/// <param name="context">Context of current parsing process.</param>
public OpenApiReaderException(string message, ParsingContext context) : base(message) {
public OpenApiReaderException(string message, ParsingContext context) : base(message)
{
Pointer = context.GetLocation();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Readers.ParseNodes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
Expand Down Expand Up @@ -35,7 +35,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JsonSchema.Net" Version="4.1.5" />
<PackageReference Include="JsonSchema.Net.OpenApi" Version="1.1.0" />
<PackageReference Include="SharpYaml" Version="2.1.0" />
<PackageReference Include="Yaml2JsonNode" Version="1.1.1" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>

Expand Down
7 changes: 3 additions & 4 deletions src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Readers.Interface;
using Microsoft.OpenApi.Validations;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json.Nodes;

namespace Microsoft.OpenApi.Readers
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public OpenApiStreamReader(OpenApiReaderSettings settings = null)
{
_settings = settings ?? new OpenApiReaderSettings();

if((_settings.ReferenceResolution == ReferenceResolutionSetting.ResolveAllReferences || _settings.LoadExternalRefs)
if ((_settings.ReferenceResolution == ReferenceResolutionSetting.ResolveAllReferences || _settings.LoadExternalRefs)
&& _settings.BaseUrl == null)
{
throw new ArgumentException("BaseUrl must be provided to resolve external references.");
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.OpenApi.Readers/OpenApiTextReaderReader.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System.Collections;
using System.IO;
using System.Linq;
using System.Text.Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static bool is2_0(this string version)
{
result = true;
}

return result;
}

Expand Down
5 changes: 1 addition & 4 deletions src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -17,7 +15,6 @@
using Microsoft.OpenApi.Readers.Services;
using Microsoft.OpenApi.Services;
using Microsoft.OpenApi.Validations;
using SharpYaml.Serialization;

namespace Microsoft.OpenApi.Readers
{
Expand Down Expand Up @@ -71,7 +68,7 @@ public OpenApiDocument Read(JsonNode input, out OpenApiDiagnostic diagnostic)
}

// Validate the document
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count() > 0)
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Any())
{
var openApiErrors = document.Validate(_settings.RuleSet);
foreach (var item in openApiErrors.OfType<OpenApiValidatorError>())
Expand Down
Loading
Loading