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

it should not unnecessarily stringify string values for text/plain content type #6431

Merged
merged 7 commits into from Sep 29, 2020

Conversation

mathis-m
Copy link
Contributor

Description

Sample for text/plain should not be stringified. Introduced with #6412 the json sample for type string will be stringified. This should only be the case if the content type is not text/plain.

Motivation and Context

Fixes #6430

How Has This Been Tested?

in browser
by new tests

Screenshots (if appropriate):

see #6430

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@hkosova
Copy link
Contributor

hkosova commented Sep 23, 2020

The logic should probably be changed to apply JSON.stringify specifically to JSON media types (application/json, application/vnd.api+json, etc.) and ignore all other media types.

@mathis-m
Copy link
Contributor Author

The json sample generation is the default case.
I have refactored the code to clarify the different cases.

@mathis-m
Copy link
Contributor Author

@hkosova do you think it is better to use the old behavior(only stringify object values) before #6412 was merged as default sample case and introduce case for json content type where sting values will be stringified as well?
text/plain content type sample generation would then implicitly match the default case where only object values will be stringified.

@mathis-m mathis-m marked this pull request as draft September 23, 2020 23:15
@mathis-m mathis-m marked this pull request as ready for review September 24, 2020 13:17
@tim-lai
Copy link
Contributor

tim-lai commented Sep 25, 2020

@hkosova do you think it is better to use the old behavior(only stringify object values) before #6412 was merged as default sample case and introduce case for json content type where sting values will be stringified as well?
text/plain content type sample generation would then implicitly match the default case where only object values will be stringified.

@mathis-m I this suggestion is better. Revert to original behavior to only stringify object values, but add a function for an allowList for non-object values. e.g if (object || allowList) { stringify }

@mathis-m
Copy link
Contributor Author

@tim-lai thanks for your input. Will implement this in the next days.

…gified for default content type.

introduced json case where string is stringified too
@mathis-m
Copy link
Contributor Author

@tim-lai could you review the changes made.

@tim-lai tim-lai merged commit ad630cc into swagger-api:master Sep 29, 2020
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.

Content Type text/plain should not be stringified
3 participants