Skip to content

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

Merged

Conversation

VitaliyKurokhtin
Copy link
Contributor

No description provided.

@PerthCharern
Copy link
Contributor

@VitaliyKurokhtin

Any chance you have an example handy to illustrate what exactly is turning out incorrectly?

I believe @darrelmiller added this change to allow reading produces if it comes after responses, but seems like it's causing some kind of regression. (#267)

@VitaliyKurokhtin
Copy link
Contributor Author

VitaliyKurokhtin commented Dec 13, 2018

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.

@VitaliyKurokhtin
Copy link
Contributor Author

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.

@darrelmiller
Copy link
Member

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.

@darrelmiller
Copy link
Member

I tested this before and after the fix and was able to repro the problem and confirm the fix solves it. Much appreciated @VitaliyKurokhtin !

@darrelmiller darrelmiller mentioned this pull request Dec 23, 2018
@PerthCharern
Copy link
Contributor

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 :)

@VitaliyKurokhtin
Copy link
Contributor Author

Sure, done!

@PerthCharern PerthCharern merged commit 3cdbb17 into microsoft:master Dec 28, 2018
@VitaliyKurokhtin VitaliyKurokhtin deleted the vvk/response-schema-fix branch December 28, 2018 22:09
@tobindh
Copy link

tobindh commented Mar 11, 2019

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.

@darrelmiller
Copy link
Member

@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.

@darrelmiller darrelmiller added this to the 1.1.3 milestone Apr 10, 2019
@VitaliyKurokhtin
Copy link
Contributor Author

@tobindh fixed by #398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants