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

fix(try-it-out): Fix the width of image responses #7495

Merged
merged 4 commits into from Sep 15, 2021

Conversation

hkosova
Copy link
Contributor

@hkosova hkosova commented Sep 10, 2021

This PR fixes an issue where images responses were stretched to the parent container's width. The issue was originally reported on Stack Overflow: https://stackoverflow.com/questions/68512725/swagger-ui-openapi-rendering-image-with-full-width

To reproduce the issue, open
https://petstore.swagger.io/?url=https://httpbin.org/spec.json#/Images/get_image
and test GET /image.

Context

The issue appears to be a small regression introduced in PR #5578. That change replaced inline style <img style={{ maxWidth: "100%" }} with the CSS class img.full-width { width: 100%; }. That is, the new code applied width instead of max-width, most likely an oversight. The current PR changes width back to max-width.


Note: An alternative fix would be to remove the img.full-width class entirely because img elements get max-width: 100% from tachyons-sass image styles used by Swagger UI - as shown on the image below. Let me know if you prefer to have img.full-width style removed rather than updated.

image

How Has This Been Tested?

Manually.

Screenshots (if appropriate):

Before the fix:

image

After the fix:

image

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.

@char0n
Copy link
Member

char0n commented Sep 15, 2021

Hi @hkosova,

An alternative fix would be to remove the img.full-width class entirely because img elements get max-width: 100% from tachyons-sass image styles used by Swagger UI - as shown on the image below. Let me know if you prefer to have img.full-width style removed rather than updated.

Thanks for providing different alternative. IMHO removing the class makes more sense as the max-width is already applied by the tachions-sass and we don't need width rule applied.

Copy link
Member

@char0n char0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

@char0n
Copy link
Member

char0n commented Sep 15, 2021

@hkosova is there a tracking issue for this PR?

@hkosova
Copy link
Contributor Author

hkosova commented Sep 15, 2021

@char0n no - the info is in this PR's description only.

@char0n char0n merged commit cc700f0 into swagger-api:master Sep 15, 2021
@hkosova hkosova deleted the fix/response-image-width branch September 15, 2021 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants