-
Notifications
You must be signed in to change notification settings - Fork 262
Duplicate response processing causes schema corruption #368
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
Duplicate response processing causes schema corruption #368
Conversation
Any chance you have an example handy to illustrate what exactly is turning out incorrectly? I believe @darrelmiller added this change to allow reading |
I'll add a test, but in short the problem is that ProcessProduces fetches schema by context.GetFromTempStorage(TempStorageKeys.ResponseSchema) which is, if responses are already processed, the last schema. And that is the schema that gets assigned to all responses. |
There. Test added, implementation fixed. I feel that previous implementation was wrong to assume that ParseProduces may be called at any point during parsing, since list of produces media types may be not available when we parse responses. |
I had made this change because I believe one of the tests in APIM had the produces at the end of the response. I'll review this change and provide feedback. |
I tested this before and after the fix and was able to repro the problem and confirm the fix solves it. Much appreciated @VitaliyKurokhtin ! |
test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
Show resolved
Hide resolved
Thanks @darrelmiller & @VitaliyKurokhtin @VitaliyKurokhtin Could you help resolve the merge conflict by removing all the tags and verify that there is no impact on your code and tests? Once you confirm that, I'll check in the code. Thank you for this fix :) |
Sure, done! |
There is an issue with this fix if there are multiple produces. It clears the temp storage for the responseSchema in temp storage inside of the produces foreach, so if there are multiple content types (i.e. xml and json), only the first content type gets the schema assigned. Shouldn't this clear the temp storage outside of the produces foreach? src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs in the ProcessProduces method. |
@tobindh Moving the clear to outside the Produces loop solves the problem with multiple produces, but it then breaks the issue with multiple responses. Not sure why. I will continue investigating. |
No description provided.