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

V2-preview1 release #1906

Open
wants to merge 796 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
796 commits
Select commit Hold shift + click to select a range
21bed6b
Update PublicAPI
irvinesunday Apr 4, 2024
1e57b38
Merge pull request #1612 from microsoft/mk/sync-v2-with-vnext-changes
MaggieKimani1 Apr 4, 2024
d744e64
Merge remote-tracking branch 'origin/release/2.0.0' into is/component…
irvinesunday Apr 4, 2024
54712c1
Update Public API
irvinesunday Apr 4, 2024
11b3399
Update comment
irvinesunday Apr 4, 2024
77cd25a
Merge pull request #1609 from microsoft/is/component-registry
irvinesunday Apr 5, 2024
b3c6995
Fix JsonNode cloning
irvinesunday Apr 5, 2024
f884968
Nit fixes
irvinesunday Apr 5, 2024
b9d5360
Merge pull request #1616 from microsoft/is/v2-fixes
irvinesunday Apr 5, 2024
d4b6e8d
Split host document resolution from Json Schema ref resolution
irvinesunday Apr 13, 2024
cfd35a8
Refactor nullable schema mappings
MaggieKimani1 Apr 15, 2024
92dc278
Use JsonSchema.NET's Evaluate() method to validate a Json schema inst…
MaggieKimani1 Apr 15, 2024
b90aa03
Remove unnecessary using
MaggieKimani1 Apr 15, 2024
bb52f57
Do not resolve JsonSchema refs when parsing a doc
irvinesunday Apr 15, 2024
681f60a
Add a null check
MaggieKimani1 Apr 15, 2024
dd08d86
Update Public Api document
irvinesunday Apr 15, 2024
b511167
Update tests
irvinesunday Apr 15, 2024
4e07923
Rename class and public method
irvinesunday Apr 15, 2024
e8d504f
Make method public to expose it to clients
MaggieKimani1 Apr 16, 2024
1ecc6fd
Remove whitespace
MaggieKimani1 Apr 16, 2024
6b743fd
Merge pull request #1625 from microsoft/mk/fix-nullable-type-mapping
MaggieKimani1 Apr 16, 2024
1d6b0a6
Decorate the nullable keyword with SchemaSpecVersion attribute for ev…
MaggieKimani1 Apr 16, 2024
afc40be
Merge pull request #1631 from microsoft/vnext
baywet Apr 17, 2024
f770dd6
Update assertions with correct test output post validation
MaggieKimani1 Apr 17, 2024
f069dc1
Merge pull request #1627 from microsoft/is/do-not-resolve-jsonschema
irvinesunday Apr 22, 2024
6ac327f
Fix failing test
MaggieKimani1 Apr 22, 2024
3f058f4
Refactor code to create JSON schema mappings without a Ref in the com…
MaggieKimani1 Apr 22, 2024
bd5287e
Merge remote-tracking branch 'origin/release/2.0.0' into mk/validate-…
MaggieKimani1 Apr 22, 2024
6e7c5a8
Fix failing tests
MaggieKimani1 Apr 22, 2024
e76101a
Adds an optional host document param to use during validation in orde…
MaggieKimani1 Apr 23, 2024
c829276
Walk each schema to resolve any present $refs
MaggieKimani1 Apr 26, 2024
2baf2f4
Code cleanup
MaggieKimani1 Apr 26, 2024
4591988
Update API interface
MaggieKimani1 Apr 26, 2024
efa812a
Register and retrieve `JsonSchema` references with `$id` value pointe…
irvinesunday Apr 26, 2024
3cae500
Adds an optional host document parameter
MaggieKimani1 Apr 29, 2024
7f5d24c
Register the host document with the schema registry for reference res…
MaggieKimani1 Apr 29, 2024
ff38301
Implement FindSubschema by fetching the referenced schema from our co…
MaggieKimani1 Apr 29, 2024
dcc7b7f
Fix failing tests
MaggieKimani1 Apr 29, 2024
babc887
Set the new schema's baseUri to match the document's
MaggieKimani1 Apr 29, 2024
d6593ab
Refactor V2 schema deserializer to update the referenceable schema's …
MaggieKimani1 Apr 29, 2024
0fb689d
Register the OpenApi-based vocabs
MaggieKimani1 Apr 29, 2024
85a2b54
Add a null check
MaggieKimani1 Apr 29, 2024
b09eb62
Revert the V31 deserializer
MaggieKimani1 Apr 29, 2024
a278267
Use the extension method from JsonSchema.NET to get a dicriminator ob…
MaggieKimani1 Apr 30, 2024
bb2726c
Merge branch 'mk/validate-json-schema' of https://github.com/microsof…
MaggieKimani1 Apr 30, 2024
e93cd4c
Use System.Text to deserialize a node into a JSON schema
MaggieKimani1 Apr 30, 2024
d1cb002
Replace Enumerable methods with indexing
MaggieKimani1 May 2, 2024
5c96d1c
Exclude files from build
MaggieKimani1 May 2, 2024
71c3963
Revert code to fix failing tests
MaggieKimani1 May 2, 2024
d0380ce
Remove static field modifier
MaggieKimani1 May 2, 2024
6cd0f02
Merge branch 'release/2.0.0' into mk/validate-json-schema
MaggieKimani1 May 2, 2024
5015239
Merge pull request #1626 from microsoft/mk/validate-json-schema
darrelmiller May 8, 2024
4e54dfd
Make the readers dictionary in the registry concurrent to avoid corru…
MaggieKimani1 May 8, 2024
15ce520
Implement PR feedback
MaggieKimani1 May 8, 2024
aa5e01e
Merge pull request #1659 from microsoft/mk/reader-concurrent-dictionary
MaggieKimani1 May 9, 2024
bb3fcfe
Fix fragment typo
MaggieKimani1 May 14, 2024
4afdd15
Merge pull request #1664 from microsoft/mk/fix-isFragment-typo
MaggieKimani1 May 15, 2024
c06a9f1
feat: Added nullable enable to OpenApiComponents.
HavenDV Jun 27, 2024
2deb4aa
feat: Added nullable enable to OpenApiDocument.
HavenDV Jun 27, 2024
9146269
feat: Added nullable enable to OpenApiMediaType.
HavenDV Jun 27, 2024
38f35c2
feat: Added nullable enable to OpenApiOperation.
HavenDV Jun 27, 2024
ead99b1
feat: Updated PublicApi.approved.txt.
HavenDV Jun 27, 2024
ff0d4f8
Update packages
MaggieKimani1 Jul 16, 2024
286c317
Use async Task as async void is obsolete
MaggieKimani1 Jul 16, 2024
a9075aa
Merge vnext into v2; Resolve merge conflicts
MaggieKimani1 Jul 16, 2024
5c56379
Merge pull request #1729 from microsoft/mk/update-packages
MaggieKimani1 Jul 16, 2024
3bfa1fc
Merge branch 'release/2.0.0' into nullability-work-1
baywet Jul 19, 2024
cf27ffa
Add an OpenApiSchema model with known keywords
MaggieKimani1 Jul 25, 2024
6fed385
Add a copy constructor
MaggieKimani1 Jul 25, 2024
71215ac
Add an OpenApiSchema model with all known keywords
MaggieKimani1 Jul 29, 2024
3000226
Add V2 schema deserializer
MaggieKimani1 Jul 29, 2024
5d3580c
Add v31 schema property names as constants
MaggieKimani1 Jul 30, 2024
7761651
Add license info; implement IOpenApiReferenceable interface
MaggieKimani1 Jul 30, 2024
6bb2546
Add serialization logic
MaggieKimani1 Jul 30, 2024
f76fddf
clean up file
MaggieKimani1 Jul 30, 2024
5cfce6e
Add a V3 schema deserializer
MaggieKimani1 Jul 30, 2024
a124aa2
Make the host document an optional param
MaggieKimani1 Jul 30, 2024
0600002
Serialize type array in v31
MaggieKimani1 Jul 30, 2024
902bd62
Update namespace
MaggieKimani1 Jul 30, 2024
a59ba31
Remove unnecessary usings
MaggieKimani1 Jul 30, 2024
902936e
Add a v31 schema deserializer
MaggieKimani1 Jul 30, 2024
266896b
Update import, code cleanup
MaggieKimani1 Jul 30, 2024
536218c
Add null conditional operator
MaggieKimani1 Jul 30, 2024
2ffebe7
Update public API interface
MaggieKimani1 Jul 30, 2024
e943068
Update src/Microsoft.OpenApi/Models/OpenApiDocument.cs
baywet Jul 30, 2024
5727db5
Update src/Microsoft.OpenApi/Models/OpenApiDocument.cs
baywet Jul 30, 2024
81b41e9
Write string value for Type for V2 and V3, allow type array for V3
MaggieKimani1 Aug 7, 2024
be9e5a2
code cleanup
MaggieKimani1 Aug 7, 2024
13d5061
Add schema loader
MaggieKimani1 Aug 7, 2024
ee2495f
if node value is string, get the scalar value, else cast it into an a…
MaggieKimani1 Aug 7, 2024
57ca1cc
Clean up type array support logic
MaggieKimani1 Aug 8, 2024
58e3cd6
Add tests and update public API
MaggieKimani1 Aug 8, 2024
4ff2176
clean up code block
MaggieKimani1 Aug 8, 2024
6f28adf
Use ternary operator
MaggieKimani1 Aug 8, 2024
da64594
Replace JsonSchema with OpenApiSchema
MaggieKimani1 Aug 12, 2024
6cd1db6
Uninstall JSON schema library
MaggieKimani1 Aug 12, 2024
66a033c
Code cleanup
MaggieKimani1 Aug 12, 2024
f0233f8
Delete JSON schema extension classes
MaggieKimani1 Aug 13, 2024
8b0fb29
Add support for examples
MaggieKimani1 Aug 13, 2024
6d32cc1
Add support for pattern properties
MaggieKimani1 Aug 13, 2024
f5811e9
Add support for pattern properties
MaggieKimani1 Aug 13, 2024
8f62e54
Revert "Add support for pattern properties"
MaggieKimani1 Aug 13, 2024
8e020d8
Merge branch 'mk/add-json-schema-model' into mk/use-json-schema-model
MaggieKimani1 Aug 13, 2024
7f754b7
Code refactoring; replace JsonSchema with OpenApiSchema
MaggieKimani1 Aug 13, 2024
396d450
Clean up tests
MaggieKimani1 Aug 13, 2024
086fc56
Create a proxy object for resolving referenced schemas
MaggieKimani1 Aug 13, 2024
e9b1c57
Mark all properties as virtual to be overriden in the proxy class
MaggieKimani1 Aug 13, 2024
e09fe00
Update public API surface
MaggieKimani1 Aug 19, 2024
ecbdd5f
Return schema proxy reference if reference pointer exists
MaggieKimani1 Aug 19, 2024
853c2f9
code cleanup
MaggieKimani1 Aug 19, 2024
d2cf6c8
Refactor validation logic for examples
MaggieKimani1 Aug 19, 2024
49a9435
code cleanup
MaggieKimani1 Aug 20, 2024
82ea7b7
Fix failing tests
MaggieKimani1 Aug 20, 2024
8261af6
Update public API
MaggieKimani1 Aug 20, 2024
e9c5c05
Use schema 'id' as a locator for schema registration and performing l…
MaggieKimani1 Aug 20, 2024
1dbd870
Add test to validate
MaggieKimani1 Aug 20, 2024
86b6944
Merge pull request #1766 from microsoft/mk/add-json-schema-model
MaggieKimani1 Aug 20, 2024
04d3952
Add support for pattern properties
MaggieKimani1 Aug 13, 2024
6bf026f
Code refactoring; replace JsonSchema with OpenApiSchema
MaggieKimani1 Aug 13, 2024
4b8c697
Clean up tests
MaggieKimani1 Aug 13, 2024
883aba1
Create a proxy object for resolving referenced schemas
MaggieKimani1 Aug 13, 2024
d79beef
Mark all properties as virtual to be overriden in the proxy class
MaggieKimani1 Aug 13, 2024
b79e374
Return schema proxy reference if reference pointer exists
MaggieKimani1 Aug 19, 2024
ca19f45
code cleanup
MaggieKimani1 Aug 19, 2024
eb0cc24
Refactor validation logic for examples
MaggieKimani1 Aug 19, 2024
919c869
code cleanup
MaggieKimani1 Aug 20, 2024
f9f01b7
Fix failing tests
MaggieKimani1 Aug 20, 2024
7fd7ca9
Update public API
MaggieKimani1 Aug 20, 2024
c11bf82
Use schema 'id' as a locator for schema registration and performing l…
MaggieKimani1 Aug 20, 2024
33b4a07
Add test to validate
MaggieKimani1 Aug 20, 2024
9f4e1b7
Merge branch 'mk/use-json-schema-model' of https://github.com/microso…
MaggieKimani1 Aug 20, 2024
2f29a30
Merge branch 'release/2.0.0' into mk/use-json-schema-model
MaggieKimani1 Aug 20, 2024
cc1439e
Use JsonNode in place of OpenApiAny for Enums and Examples
MaggieKimani1 Aug 22, 2024
38bd152
Fix codeQL warnings
MaggieKimani1 Aug 22, 2024
af42af2
Avoid virtual calls in constructors
MaggieKimani1 Aug 22, 2024
4cd04c6
Clean up tests; add test for schema examples
MaggieKimani1 Aug 22, 2024
887748e
Cleanup and add test for cloning examples
MaggieKimani1 Aug 22, 2024
5901f49
Add test to bump up test coverage
MaggieKimani1 Aug 22, 2024
8fd03c9
Clean up serializers
MaggieKimani1 Aug 27, 2024
a9803f7
clean up tests
MaggieKimani1 Aug 27, 2024
e4b0adf
Add tests and samples
MaggieKimani1 Aug 27, 2024
97a13db
Bump test coverage
MaggieKimani1 Aug 27, 2024
9f118b9
Update public API
MaggieKimani1 Aug 27, 2024
264f910
copy file to output directory
MaggieKimani1 Aug 27, 2024
4fdd0e8
Merge pull request #1787 from microsoft/mk/use-json-schema-model
MaggieKimani1 Aug 27, 2024
9d9fb6a
Add logic for upcasting and downcasting type arrays
MaggieKimani1 Sep 5, 2024
9e9ff78
Add tests to validate
MaggieKimani1 Sep 5, 2024
7118be6
Add constants
MaggieKimani1 Sep 5, 2024
c80b407
Merge branch 'refs/heads/release/2.0.0' into nullability-work-1
HavenDV Sep 5, 2024
7e0f1e0
fix: Resolved conflicts.
HavenDV Sep 5, 2024
45b0e5e
feat: Make REQUIRED properties as non-nullable and revert some change…
HavenDV Sep 5, 2024
06d499a
Check whether the $ref pointer is a locator or identifier and assign …
MaggieKimani1 Sep 6, 2024
76763dd
Add tests to verify external reference resolution both by $id and $re…
MaggieKimani1 Sep 6, 2024
989c6cf
Merge nested if statement
MaggieKimani1 Sep 9, 2024
99b8140
If a schema is nullable, read type as an array, and remove "x-nullable"
MaggieKimani1 Sep 11, 2024
be414df
Add tests
MaggieKimani1 Sep 11, 2024
4cbd66d
code refactor
MaggieKimani1 Sep 23, 2024
4b4d31d
Make private field readonly
MaggieKimani1 Sep 23, 2024
524a03d
Fix merge conflicts
MaggieKimani1 Sep 30, 2024
f04d45e
se workspace baseUrl to settings.BaseUrl
MaggieKimani1 Oct 1, 2024
5046131
Use current working directory to resolve file path
MaggieKimani1 Oct 1, 2024
e85e478
Clean up
MaggieKimani1 Oct 1, 2024
c3fac4e
Use ternary operator
MaggieKimani1 Oct 1, 2024
41b3d9d
code cleanup
MaggieKimani1 Oct 1, 2024
16ba3b7
Move method to workspace and remove unnecessary param
MaggieKimani1 Oct 1, 2024
983c576
Update XML comment
MaggieKimani1 Oct 1, 2024
74d8866
Update public API
MaggieKimani1 Oct 1, 2024
a60b992
Use null coalesce ?? operator
MaggieKimani1 Oct 1, 2024
aa3781b
If type array has been provided alongside a nullable keyword, don't e…
MaggieKimani1 Oct 2, 2024
6ac0bd1
Add test
MaggieKimani1 Oct 2, 2024
f1c9297
Merge pull request #1820 from microsoft/mk/handle-schemas-with-multip…
MaggieKimani1 Oct 2, 2024
e0a3bb2
Merge pull request #1849 from microsoft/mk/set-workspace-baseUrl
MaggieKimani1 Oct 2, 2024
43351ca
If the reference is a url identifier, serialize it as is
MaggieKimani1 Oct 2, 2024
e827598
Clean up logic for determining whether a locator or identifier refere…
MaggieKimani1 Oct 2, 2024
ec420d7
Remove unnecessary usings
MaggieKimani1 Oct 2, 2024
ee880e2
Add test to validate
MaggieKimani1 Oct 2, 2024
2a95547
Update src/Microsoft.OpenApi/Models/OpenApiReference.cs
MaggieKimani1 Oct 2, 2024
66fb599
Update src/Microsoft.OpenApi/Models/OpenApiReference.cs
MaggieKimani1 Oct 2, 2024
ed5c771
Merge pull request #1851 from microsoft/mk/fix-$ref-with-$id-serializ…
MaggieKimani1 Oct 2, 2024
55c3036
Add support for transforming 3.1 docs
MaggieKimani1 Oct 2, 2024
3ab3071
set 3.1 as the default version
MaggieKimani1 Oct 2, 2024
7261ad9
Merge pull request #1854 from microsoft/mk/allow-hidi-to-emit-31
MaggieKimani1 Oct 3, 2024
1941a57
Remove validation rule to make paths and webhooks optional
MaggieKimani1 Oct 3, 2024
e958896
If the input stream is JSON, read directly from stream, otherwise buf…
MaggieKimani1 Oct 3, 2024
4e50523
Merge pull request #1826 from microsoft/mk/fix-external-ref-resolution
MaggieKimani1 Oct 3, 2024
e0f20d0
Clean up comment
MaggieKimani1 Oct 3, 2024
19463dd
Merge remote-tracking branch 'origin/release/2.0.0' into mk/sync-v2-w…
MaggieKimani1 Oct 3, 2024
3c64451
Fix merge conflicts
MaggieKimani1 Oct 7, 2024
63c096e
Update code owners
MaggieKimani1 Oct 7, 2024
9c64bea
Remove commented out code
MaggieKimani1 Oct 7, 2024
23fde05
Merge pull request #1856 from microsoft/mk/make-update-validation-rule
MaggieKimani1 Oct 8, 2024
2102659
Merge pull request #1857 from microsoft/mk/avoid-buffering-json-data-…
MaggieKimani1 Oct 8, 2024
d04b22b
Remove threading package and disable warnings
MaggieKimani1 Oct 8, 2024
d302b5d
Fix merge conflict
MaggieKimani1 Oct 8, 2024
2e516a5
Merge branch 'release/2.0.0' into mk/sync-v2-with-vnext
MaggieKimani1 Oct 8, 2024
d2dc8ec
Declare Annotations as nullable to prevent null reference assignment
MaggieKimani1 Oct 8, 2024
9c4fd10
Merge pull request #1861 from microsoft/mk/sync-v2-with-vnext
MaggieKimani1 Oct 8, 2024
08154c7
Bump lib versions to 2.0.0-preview1
MaggieKimani1 Oct 8, 2024
fed868c
Merge pull request #1865 from microsoft/mk/bump-lib-versions-to-v2
MaggieKimani1 Oct 9, 2024
21d71e9
Merge remote-tracking branch 'origin/vnext' into mk/sync-dependabot-u…
MaggieKimani1 Oct 9, 2024
a572a5f
Bump up STJ version
MaggieKimani1 Oct 9, 2024
264226b
Merge pull request #1866 from microsoft/mk/sync-dependabot-updates
MaggieKimani1 Oct 9, 2024
125bda9
Simplify null checks and remove unnecessary usings
MaggieKimani1 Oct 23, 2024
c3373af
Merge pull request #1887 from microsoft/mk/simplify-null-check
MaggieKimani1 Oct 23, 2024
9bf3f08
remove depracated validation rule
MaggieKimani1 Oct 23, 2024
ad3b65d
clean up tests and update public API interface
MaggieKimani1 Oct 23, 2024
cb394dc
Register the Yaml reader with our factory's registry for parsing of Y…
MaggieKimani1 Oct 23, 2024
924661c
Update tool to parse 3.1 docs
MaggieKimani1 Oct 23, 2024
3c5e279
Revert "remove depracated validation rule"
MaggieKimani1 Oct 24, 2024
9c19f93
Isolate the data mismatch rule into a separate class to allow clients…
MaggieKimani1 Oct 24, 2024
2d8640a
code cleanup
MaggieKimani1 Oct 24, 2024
ae0c5a0
Add test case for opting into using the data mismatch validation rule
MaggieKimani1 Oct 24, 2024
a478bd2
Use Where for sequence filtering
MaggieKimani1 Oct 24, 2024
1e6e654
Merge branch 'vnext' into merge/vnext-to-release2
baywet Oct 24, 2024
fe13c56
fix: adds missing type mappings tests
baywet Oct 24, 2024
ab0ecf9
Merge pull request #1893 from microsoft/merge/vnext-to-release2
baywet Oct 24, 2024
5c35c7b
Merge pull request #1890 from microsoft/mk/update-workbench-to-parse-…
MaggieKimani1 Oct 28, 2024
79f3e94
Define JSON schema type as a flaggable enum to allow storing strings …
MaggieKimani1 Oct 28, 2024
8c9047f
Implement helper methods for switching between enum types and their e…
MaggieKimani1 Oct 28, 2024
2e03505
Refactor tests to reflect change
MaggieKimani1 Oct 28, 2024
d0fb2c7
Update API interface
MaggieKimani1 Oct 28, 2024
42614be
Resolve merge conflicts
MaggieKimani1 Oct 28, 2024
314880d
Fix failing tests
MaggieKimani1 Oct 29, 2024
b2e1026
code cleanup
MaggieKimani1 Oct 29, 2024
1825825
Remove recursive Ref and recursive anchor keywords as they are not su…
MaggieKimani1 Oct 29, 2024
3178fc3
Remove keywords from the proxy class and update public API
MaggieKimani1 Oct 29, 2024
aa3895f
Refactor vocabulary object to represent a dictionary; implement seria…
MaggieKimani1 Oct 29, 2024
e1feafe
Clean up V31 serialization logic to write out 3.1 keywords correctly
MaggieKimani1 Oct 29, 2024
f45de4c
Add test to validate parsing of 3.1 JSON schema keywords and update p…
MaggieKimani1 Oct 29, 2024
6987f7b
Merge pull request #1899 from microsoft/mk/remove-recursive-keywords
MaggieKimani1 Oct 29, 2024
34b81ce
Merge pull request #1888 from microsoft/mk/remove-validation-rule
MaggieKimani1 Oct 29, 2024
924ff0d
Merge remote-tracking branch 'origin/release/2.0.0' into mk/define-js…
MaggieKimani1 Oct 29, 2024
56c47cb
Remove JsonSchemaType.Any type
MaggieKimani1 Oct 29, 2024
5af79d4
Add condition to check whether the flag matches the type before appen…
MaggieKimani1 Oct 30, 2024
e12301c
Add test for sample document with 3.1 features
MaggieKimani1 Oct 30, 2024
e13fb01
throw OpenApiException for it to be caught gracefully and appended to…
MaggieKimani1 Oct 30, 2024
2e2ad57
Fix string formatting
MaggieKimani1 Oct 30, 2024
656259a
Fix failing tests
MaggieKimani1 Oct 30, 2024
07987ae
Update src/Microsoft.OpenApi/Models/OpenApiSchema.cs
MaggieKimani1 Oct 30, 2024
3abe36c
Convert the JsonSchemaType helper methods to extensions
MaggieKimani1 Oct 30, 2024
38954dc
Add null check for type; simplify condition to verify flag has been set
MaggieKimani1 Oct 30, 2024
b806323
Clean up tests
MaggieKimani1 Oct 30, 2024
5eb0010
Add null check
MaggieKimani1 Oct 30, 2024
6d34a77
chore(deps): bump Verify.Xunit from 27.1.0 to 28.0.0
dependabot[bot] Oct 30, 2024
46b18cd
Merge pull request #1900 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Oct 31, 2024
bf4a9ea
Merge pull request #1897 from microsoft/mk/define-json-schema-type-as…
MaggieKimani1 Oct 31, 2024
3c597ea
Merge branch 'vnext' into mk/sync-vnext-changes
MaggieKimani1 Nov 4, 2024
b490348
update file path to moved file
MaggieKimani1 Nov 4, 2024
5bbb344
Merge pull request #1903 from microsoft/mk/sync-vnext-changes
MaggieKimani1 Nov 4, 2024
7f4f935
Merge pull request #1904 from microsoft/release/2.0.0
MaggieKimani1 Nov 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ internal static class OpenApiExtensibleExtensions
/// <returns>A <see cref="string"/> value matching the provided extensionKey. Return null when extensionKey is not found. </returns>
internal static string GetExtension(this IDictionary<string, IOpenApiExtension> extensions, string extensionKey)
{
if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiString castValue)
if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiAny castValue)
{
return castValue.Value;
return castValue.Node.GetValue<string>();
}
return string.Empty;
}
Expand Down
21 changes: 11 additions & 10 deletions src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public override void Visit(OpenApiSchema schema)

public override void Visit(OpenApiPathItem pathItem)
{
if (pathItem.Operations.TryGetValue(OperationType.Put, out var value))
if (pathItem.Operations.TryGetValue(OperationType.Put, out var value) &&
value.OperationId != null)
{
var operationId = value.OperationId;
pathItem.Operations[OperationType.Put].OperationId = ResolvePutOperationId(operationId);
Expand All @@ -67,14 +68,14 @@ public override void Visit(OpenApiOperation operation)
throw new ArgumentException($"OperationId is required {PathString}", nameof(operation));

var operationId = operation.OperationId;
var operationTypeExtension = operation.Extensions.GetExtension("x-ms-docs-operation-type");
var operationTypeExtension = operation.Extensions?.GetExtension("x-ms-docs-operation-type");
if (operationTypeExtension.IsEquals("function"))
operation.Parameters = ResolveFunctionParameters(operation.Parameters);
operation.Parameters = ResolveFunctionParameters(operation.Parameters ?? new List<OpenApiParameter>());

// Order matters. Resolve operationId.
operationId = RemoveHashSuffix(operationId);
if (operationTypeExtension.IsEquals("action") || operationTypeExtension.IsEquals("function"))
operationId = RemoveKeyTypeSegment(operationId, operation.Parameters);
operationId = RemoveKeyTypeSegment(operationId, operation.Parameters ?? new List<OpenApiParameter>());
operationId = SingularizeAndDeduplicateOperationId(operationId.SplitByChar('.'));
operationId = ResolveODataCastOperationId(operationId);
operationId = ResolveByRefOperationId(operationId);
Expand Down Expand Up @@ -165,10 +166,10 @@ private static IList<OpenApiParameter> ResolveFunctionParameters(IList<OpenApiPa
parameter.Content = null;
parameter.Schema = new()
{
Type = "array",
Type = JsonSchemaType.Array,
Items = new()
{
Type = "string"
Type = JsonSchemaType.String
}
};
}
Expand All @@ -177,9 +178,9 @@ private static IList<OpenApiParameter> ResolveFunctionParameters(IList<OpenApiPa

private void AddAdditionalPropertiesToSchema(OpenApiSchema schema)
{
if (schema != null && !_schemaLoop.Contains(schema) && "object".Equals(schema.Type, StringComparison.OrdinalIgnoreCase))
if (schema != null && !_schemaLoop.Contains(schema) && schema.Type.Equals(JsonSchemaType.Object))
{
schema.AdditionalProperties = new() { Type = "object" };
schema.AdditionalProperties = new() { Type = JsonSchemaType.Object };

/* Because 'additionalProperties' are now being walked,
* we need a way to keep track of visited schemas to avoid
Expand All @@ -191,7 +192,7 @@ private void AddAdditionalPropertiesToSchema(OpenApiSchema schema)

private static void ResolveOneOfSchema(OpenApiSchema schema)
{
if (schema.OneOf?.FirstOrDefault() is {} newSchema)
if (schema.OneOf?.FirstOrDefault() is { } newSchema)
{
schema.OneOf = null;
FlattenSchema(schema, newSchema);
Expand All @@ -200,7 +201,7 @@ private static void ResolveOneOfSchema(OpenApiSchema schema)

private static void ResolveAnyOfSchema(OpenApiSchema schema)
{
if (schema.AnyOf?.FirstOrDefault() is {} newSchema)
if (schema.AnyOf?.FirstOrDefault() is { } newSchema)
{
schema.AnyOf = null;
FlattenSchema(schema, newSchema);
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
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>
<OutputType>Exe</OutputType>
Expand Down
50 changes: 34 additions & 16 deletions src/Microsoft.OpenApi.Hidi/OpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using Microsoft.OpenApi.Hidi.Utilities;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Readers;
using Microsoft.OpenApi.Services;
using Microsoft.OpenApi.Writers;
Expand All @@ -38,6 +39,12 @@ namespace Microsoft.OpenApi.Hidi
{
internal static class OpenApiService
{
static OpenApiService()
{
OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader());
OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader());
}

/// <summary>
/// Implementation of the transform command
/// </summary>
Expand All @@ -52,7 +59,12 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
{
if (options.Output == null)
{
var inputExtension = GetInputPathExtension(options.OpenApi, options.Csdl);
#pragma warning disable CA1308 // Normalize strings to uppercase
var extension = options.OpenApiFormat?.GetDisplayName().ToLowerInvariant();
var inputExtension = !string.IsNullOrEmpty(extension) ? string.Concat(".", extension)
: GetInputPathExtension(options.OpenApi, options.Csdl);

#pragma warning restore CA1308 // Normalize strings to uppercase
options.Output = new($"./output{inputExtension}");
};

Expand All @@ -67,7 +79,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog

// Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion
var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiFormat.Yaml);
var openApiVersion = options.Version != null ? TryParseOpenApiSpecVersion(options.Version) : OpenApiSpecVersion.OpenApi3_0;
var openApiVersion = options.Version != null ? TryParseOpenApiSpecVersion(options.Version) : OpenApiSpecVersion.OpenApi3_1;

// If ApiManifest is provided, set the referenced OpenAPI document
var apiDependency = await FindApiDependencyAsync(options.FilterOptions.FilterByApiManifest, logger, cancellationToken).ConfigureAwait(false);
Expand All @@ -85,7 +97,8 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
}

// Load OpenAPI document
var document = await GetOpenApiAsync(options, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false);
var format = OpenApiModelFactory.GetFormat(options.OpenApi);
var document = await GetOpenApiAsync(options, format, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false);

if (options.FilterOptions != null)
{
Expand Down Expand Up @@ -212,7 +225,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma
}

// Get OpenAPI document either from OpenAPI or CSDL
private static async Task<OpenApiDocument> GetOpenApiAsync(HidiOptions options, ILogger logger, string? metadataVersion = null, CancellationToken cancellationToken = default)
private static async Task<OpenApiDocument> GetOpenApiAsync(HidiOptions options, string format, ILogger logger, string? metadataVersion = null, CancellationToken cancellationToken = default)
{
OpenApiDocument document;
Stream stream;
Expand All @@ -233,7 +246,7 @@ private static async Task<OpenApiDocument> GetOpenApiAsync(HidiOptions options,
await stream.DisposeAsync().ConfigureAwait(false);
}

document = await ConvertCsdlToOpenApiAsync(filteredStream ?? stream, metadataVersion, options.SettingsConfig, cancellationToken).ConfigureAwait(false);
document = await ConvertCsdlToOpenApiAsync(filteredStream ?? stream, format, metadataVersion, options.SettingsConfig, cancellationToken).ConfigureAwait(false);
stopwatch.Stop();
logger.LogTrace("{Timestamp}ms: Generated OpenAPI with {Paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count);
}
Expand Down Expand Up @@ -375,14 +388,16 @@ private static async Task<ReadResult> ParseOpenApiAsync(string openApiFile, bool
{
stopwatch.Start();

result = await new OpenApiStreamReader(new()
{
var settings = new OpenApiReaderSettings
{
LoadExternalRefs = inlineExternal,
BaseUrl = openApiFile.StartsWith("http", StringComparison.OrdinalIgnoreCase) ?
new(openApiFile) :
new Uri("file://" + new FileInfo(openApiFile).DirectoryName + Path.DirectorySeparatorChar)
}
).ReadAsync(stream, cancellationToken).ConfigureAwait(false);
};

var format = OpenApiModelFactory.GetFormat(openApiFile);
result = await OpenApiDocument.LoadAsync(stream, format, settings, cancellationToken).ConfigureAwait(false);

logger.LogTrace("{Timestamp}ms: Completed parsing.", stopwatch.ElapsedMilliseconds);

Expand All @@ -398,15 +413,15 @@ private static async Task<ReadResult> ParseOpenApiAsync(string openApiFile, bool
/// </summary>
/// <param name="csdl">The CSDL stream.</param>
/// <returns>An OpenAPI document.</returns>
public static async Task<OpenApiDocument> ConvertCsdlToOpenApiAsync(Stream csdl, string? metadataVersion = null, IConfiguration? settings = null, CancellationToken token = default)
public static async Task<OpenApiDocument> ConvertCsdlToOpenApiAsync(Stream csdl, string format, string? metadataVersion = null, IConfiguration? settings = null, CancellationToken token = default)
{
using var reader = new StreamReader(csdl);
var csdlText = await reader.ReadToEndAsync(token).ConfigureAwait(false);
var edmModel = CsdlReader.Parse(XElement.Parse(csdlText).CreateReader());
settings ??= SettingsUtilities.GetConfiguration();

var document = edmModel.ConvertToOpenApi(SettingsUtilities.GetOpenApiConvertSettings(settings, metadataVersion));
document = FixReferences(document);
document = FixReferences(document, format);

return document;
}
Expand All @@ -416,14 +431,15 @@ public static async Task<OpenApiDocument> ConvertCsdlToOpenApiAsync(Stream csdl,
/// </summary>
/// <param name="document"> The converted OpenApiDocument.</param>
/// <returns> A valid OpenApiDocument instance.</returns>
public static OpenApiDocument FixReferences(OpenApiDocument document)
public static OpenApiDocument FixReferences(OpenApiDocument document, string format)
{
// This method is only needed because the output of ConvertToOpenApi isn't quite a valid OpenApiDocument instance.
// So we write it out, and read it back in again to fix it up.

var sb = new StringBuilder();
document.SerializeAsV3(new OpenApiYamlWriter(new StringWriter(sb)));
var doc = new OpenApiStringReader().Read(sb.ToString(), out _);

var doc = OpenApiDocument.Parse(sb.ToString(), format).OpenApiDocument;

return doc;
}
Expand Down Expand Up @@ -571,7 +587,8 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl
throw new ArgumentException("Please input a file path or URL");
}

var document = await GetOpenApiAsync(options, logger, null, cancellationToken).ConfigureAwait(false);
var format = OpenApiModelFactory.GetFormat(options.OpenApi);
var document = await GetOpenApiAsync(options, format, logger, null, cancellationToken).ConfigureAwait(false);

using (logger.BeginScope("Creating diagram"))
{
Expand Down Expand Up @@ -732,7 +749,8 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg
}

// Load OpenAPI document
var document = await GetOpenApiAsync(options, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false);
var format = OpenApiModelFactory.GetFormat(options.OpenApi);
var document = await GetOpenApiAsync(options, format, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false);

cancellationToken.ThrowIfCancellationRequested();

Expand All @@ -750,7 +768,7 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg
// Write OpenAPI to Output folder
options.Output = new(Path.Combine(options.OutputFolder, "openapi.json"));
options.TerseOutput = true;
WriteOpenApi(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_0, document, logger);
WriteOpenApi(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_1, document, logger);

// Create OpenAIPluginManifest from ApiDependency and OpenAPI document
var manifest = new OpenAIPluginManifest
Expand Down
28 changes: 20 additions & 8 deletions src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

using System;
using System.Linq;

namespace Microsoft.OpenApi.Hidi
{
Expand All @@ -14,17 +13,30 @@ public static OpenApiSpecVersion TryParseOpenApiSpecVersion(string value)
{
throw new InvalidOperationException("Please provide a version");
}
var res = value.Split('.', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
// Split the version string by the dot
var versionSegments = value.Split('.', StringSplitOptions.RemoveEmptyEntries);

if (int.TryParse(res, out var result))
if (!int.TryParse(versionSegments[0], out var majorVersion)
|| !int.TryParse(versionSegments[1], out var minorVersion))
{
if (result is >= 2 and < 3)
{
return OpenApiSpecVersion.OpenApi2_0;
}
throw new InvalidOperationException("Invalid version format. Please provide a valid OpenAPI version (e.g., 2.0, 3.0, 3.1).");
}

return OpenApiSpecVersion.OpenApi3_0; // default
// Check for specific version matches
if (majorVersion == 2)
{
return OpenApiSpecVersion.OpenApi2_0;
}
else if (majorVersion == 3 && minorVersion == 0)
{
return OpenApiSpecVersion.OpenApi3_0;
}
else if (majorVersion == 3 && minorVersion == 1)
{
return OpenApiSpecVersion.OpenApi3_1;
}

return OpenApiSpecVersion.OpenApi3_1; // default
}
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Hidi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System.CommandLine;
Expand Down
23 changes: 0 additions & 23 deletions src/Microsoft.OpenApi.Readers/Interface/IOpenApiReader.cs

This file was deleted.

11 changes: 9 additions & 2 deletions src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.6.22</Version>
<Version>2.0.0-preview1</Version>
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
<SignAssembly>true</SignAssembly>
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
Expand All @@ -17,6 +17,12 @@
<AssemblyOriginatorKeyFile>..\Microsoft.OpenApi.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<Compile Remove="V31\**" />
<EmbeddedResource Remove="V31\**" />
<None Remove="V31\**" />
</ItemGroup>

<ItemGroup>

<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20">
Expand All @@ -25,6 +31,7 @@
</PackageReference>

<PackageReference Include="SharpYaml" Version="2.1.1" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading