-
Notifications
You must be signed in to change notification settings - Fork 241
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
Fix: loading the document requires knowing the format in advance #1929
base: dev
Are you sure you want to change the base?
Conversation
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this started.
A couple of remarks
test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs
Outdated
Show resolved
Hide resolved
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
{ | ||
JsonNode jsonNode; | ||
|
||
// Parse the YAML | ||
try | ||
{ | ||
jsonNode = LoadJsonNodesFromYamlDocument(input); | ||
jsonNode = await Task.Run(() => LoadJsonNodesFromYamlDocument(input)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we adding the task run here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller is async here
public static async Task<ReadFragmentResult<T>> LoadAsync<T>(Stream input, |
And the interface method's equivalent in the JsonReader class is also async
public async Task<ReadFragmentResult<T>> ReadFragmentAsync<T>(TextReader input, |
If I change this method's signature to be synchronous, I'll also need to update this JSON content to be read synchronously:
var content = await input.ReadToEndAsync(); |
@baywet just a head's up, the functionality on inspecting the input stream to determine the format might change based on my discussion with @darrelmiller here #1918 (comment) |
@MaggieKimani1 are we going to implement those changes in this PR or in a subsequent one? |
I can implement it here so as not to lose the other changes on moving to async |
Co-authored-by: Vincent Biret <vibiret@microsoft.com>
This PR:
OpenApiModelFactory.GetStreamAsync
to allow for cancellation of tasks/requestsFixes #1917, #1918