Skip to content

Duplicate response processing causes schema corruption - #368

Merged
PerthCharern merged 5 commits into
microsoft:masterfrom
VitaliyKurokhtin:vvk/response-schema-fix
Dec 28, 2018
Merged

Duplicate response processing causes schema corruption#368
PerthCharern merged 5 commits into
microsoft:masterfrom
VitaliyKurokhtin:vvk/response-schema-fix

Conversation

@VitaliyKurokhtin

Copy link
Copy Markdown
Contributor

No description provided.

@PerthCharern

Copy link
Copy Markdown
Contributor

Vitaliy Kurokhtin (@VitaliyKurokhtin)

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

I believe Darrel (@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

Vitaliy Kurokhtin (VitaliyKurokhtin) commented Dec 13, 2018

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

Comment thread test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj Outdated
@PerthCharern

Copy link
Copy Markdown
Contributor

Thanks Darrel (@darrelmiller) & Vitaliy Kurokhtin (@VitaliyKurokhtin)

Vitaliy Kurokhtin (@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
Copy Markdown
Contributor Author

Sure, done!

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

Tobin den Harder (tobindh) commented Mar 11, 2019

Copy link
Copy Markdown

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
Copy Markdown
Member

Tobin den Harder (@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 Darrel (darrelmiller) added this to the 1.1.3 milestone Apr 10, 2019
@VitaliyKurokhtin

Copy link
Copy Markdown
Contributor Author

Tobin den Harder (@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