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

Decode model schema name on model component #8400

Conversation

souenzzo
Copy link
Contributor

@souenzzo souenzzo commented Feb 21, 2023

Description

Decodes the schema name on model

Motivation and Context

Fixes #5626 (for both OpenAPI v3 and Swagger V2)

How Has This Been Tested?

  • Go to localhost:3200
  • Paste this data-url in the url field
data:application/json;base64,eyJjb21wb25lbnRzIjp7InNjaGVtYXMiOnsiYVwvYitjIjp7InR5cGUiOiJudW1iZXIifX19LCJvcGVuYXBpIjoiMy4wLjMiLCJwYXRocyI6eyJcLyI6eyJnZXQiOnsicmVzcG9uc2VzIjp7ImRlZmF1bHQiOnsiY29udGVudCI6eyJhcHBsaWNhdGlvblwvanNvbiI6eyJzY2hlbWEiOnsiJHJlZiI6IiNcL2NvbXBvbmVudHNcL3NjaGVtYXNcL2F+MWIlMkJjIn19fX19fX19fQ==
  • Expand / route
  • Switch the default response from example value to model
  • You should see a/b+c, without any ~1 or %B2

An data-uri to test Swagger v2 spec

data:application/yaml;base64,c3dhZ2dlcjogJzIuMCcKaW5mbzoKICBkZXNjcmlwdGlvbjogJ1N3YWdnZXIgZG9jcycKICB0aXRsZTogQVBJIGV4YW1wbGUKICB2ZXJzaW9uOiAnMS4wJwpob3N0OiBzZXJ2ZXIKYmFzZVBhdGg6IC9kb2NzCnBhdGhzOgogICcvd3MvcGVyc29uJzoKICAgIGdldDoKICAgICAgZGVzY3JpcHRpb246IEdldCBwZXJzb24KICAgICAgb3BlcmF0aW9uSWQ6ICdnZXRfcGVyc29uJwogICAgICB0YWdzOgogICAgICAgIC0gUGVyc29uCiAgICAgIHJlc3BvbnNlczoKICAgICAgICAnMjAwJzoKICAgICAgICAgIGRlc2NyaXB0aW9uOiBPawogICAgICAgICAgc2NoZW1hOgogICAgICAgICAgICB0eXBlOiBvYmplY3QKICAgICAgICAgICAgcHJvcGVydGllczoKICAgICAgICAgICAgICByZXN1bHQ6CiAgICAgICAgICAgICAgICAkcmVmOiAnIy9kZWZpbml0aW9ucy9jdXN0b20lM0ElM0FuYW1lc3BhY2UlM0ElM0FQZXJzb24nCmRlZmluaXRpb25zOgogICdjdXN0b206Om5hbWVzcGFjZTo6UGVyc29uJzoKICAgIHByb3BlcnRpZXM6CiAgICAgIGlkOgogICAgICAgIHR5cGU6IG51bWJlcgogICAgICBGaXJzdE5hbWU6CiAgICAgICAgdHlwZTogc3RyaW5nCiAgICAgIExhc3ROYW1lOgogICAgICAgIHR5cGU6IHN0cmluZwogICAgICBBZGRyZXNzOgogICAgICAgIHR5cGU6IGFycmF5CiAgICAgICAgaXRlbXM6CiAgICAgICAgICAkcmVmOiAnIy9kZWZpbml0aW9ucy9jdXN0b20lM0ElM0FuYW1lc3BhY2UlM0ElM0FBZGRyZXNzJwogICdjdXN0b206Om5hbWVzcGFjZTo6QWRkcmVzcyc6CiAgICBwcm9wZXJ0aWVzOgogICAgICBpZDoKICAgICAgICB0eXBlOiBudW1iZXIKICAgICAgc3RyZWV0OgogICAgICAgIHR5cGU6IHN0cmluZwogICAgICBjaXR5OgogICAgICAgIHR5cGU6IHN0cmluZwogICAgICAgIA==

Screenshots (if appropriate):

Screenshot 2023-02-21 at 10 15 54

Before screenshot in #5626

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.

@souenzzo souenzzo marked this pull request as draft February 21, 2023 13:24
@souenzzo
Copy link
Contributor Author

souenzzo commented Mar 8, 2023

@ponelat

@ponelat
Copy link
Member

ponelat commented Mar 10, 2023

Thanks for the fix @souenzzo.
When you say the test won't run... does it run? I don't understand.
Happy to get this merged, as the model name is mostly visual. Not sure about all the edge-cases of JSON Pointer and URL encoding.

@souenzzo could you update the branch.
@char0n any reason the PR builders aren't running, is it to do with the Draft Status of this PR?

@souenzzo souenzzo marked this pull request as ready for review March 10, 2023 14:12
@souenzzo
Copy link
Contributor Author

@ponelat thank you for your attention

  • updated the branch
  • fixed the test
  • extended the solution to Swagger v2
  • updated the PR description ;)

I think that this branch now is good to go.

@char0n
Copy link
Member

char0n commented Mar 11, 2023

@char0n any reason the PR builders aren't running, is it to do with the Draft Status of this PR?

@ponelat, I need to approve the workflow before it can run. More info in https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks


@souenzzo thanks for contributing. Doing the code review now.

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.

Please have a look at my code review comments.

src/core/components/model.jsx Outdated Show resolved Hide resolved
@souenzzo
Copy link
Contributor Author

@char0n done

@souenzzo souenzzo requested a review from char0n March 13, 2023 08:07
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.

LGTM

@char0n
Copy link
Member

char0n commented Mar 13, 2023

Did some final style changes before the merge. We're good to go here!

@char0n char0n merged commit 44e2700 into swagger-api:master Mar 13, 2023
@souenzzo souenzzo deleted the bug/5626-decode-schema-name-on-model-component branch March 15, 2023 17:58
@souenzzo
Copy link
Contributor Author

@char0n tnks :)

Btw, a feedback from the contribution process:

would be nice if the linter warn us about const vs let usage.

@char0n
Copy link
Member

char0n commented Mar 16, 2023

Hi @souenzzo,

would be nice if the linter warn us about const vs let usage.

Yes, automated linting is the plan. Utilizing prettier + eslint + aribnb codestyle will be utilized (as it's already has been done for SwaggerEditor and SwaggerClient). That would require to convert entire codebase. Meanwhile we have to check that manually unfortunately which decrease dev experience. Thanks for the feedback!

ksibisamir added a commit to SaTT-Wallet/Backend that referenced this pull request May 31, 2023
<h3>Snyk has created this PR to upgrade swagger-ui-dist from 4.14.3 to
4.18.3.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.
<hr/>

- The recommended version is **13 versions** ahead of your current
version.
- The recommended version was released **24 days ago**, on 2023-04-26.


<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>swagger-ui-dist</b></summary>
    <ul>
      <li>
<b>4.18.3</b> - <a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/releases/tag/v4.18.3">2023-04-26</a></br><h2><a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/compare/v4.18.2...v4.18.3">4.18.3</a>
(2023-04-26)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>response-body:</strong> remove download button when content
is empty (<a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/issues/8579"
data-hovercard-type="pull_request"
data-hovercard-url="/swagger-api/swagger-ui/pull/8579/hovercard">#8579</a>)
(<a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/commit/cdfc4de43e486f592b9e471968c7a172d8d8072c">cdfc4de</a>)</li>
</ul>
      </li>
      <li>
<b>4.18.2</b> - <a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/releases/tag/v4.18.2">2023-03-30</a></br><h2><a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/compare/v4.18.1...v4.18.2">4.18.2</a>
(2023-03-30)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>decode model schema name on model component (<a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/issues/8400"
data-hovercard-type="pull_request"
data-hovercard-url="/swagger-api/swagger-ui/pull/8400/hovercard">#8400</a>)
(<a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/commit/44e2700c7400f872fd6b0b78d8aa2a0f73fb2807">44e2700</a>),
closes <a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/issues/5626"
data-hovercard-type="issue"
data-hovercard-url="/swagger-api/swagger-ui/issues/5626/hovercard">#5626</a></li>
<li><strong>oas3:</strong> expand Callback operation without browser
error (<a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/issues/8510"
data-hovercard-type="pull_request"
data-hovercard-url="/swagger-api/swagger-ui/pull/8510/hovercard">#8510</a>)
(<a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/commit/cb15dbb6e5544aa69a5ab04358f5fed46e253183">cb15dbb</a>),
closes <a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/issues/7465"
data-hovercard-type="issue"
data-hovercard-url="/swagger-api/swagger-ui/issues/7465/hovercard">#7465</a></li>
</ul>
      </li>
      <li>
        <b>4.18.1</b> - 2023-03-10
      </li>
      <li>
        <b>4.18.0</b> - 2023-03-08
      </li>
      <li>
        <b>4.17.1</b> - 2023-03-06
      </li>
      <li>
        <b>4.17.0</b> - 2023-03-01
      </li>
      <li>
        <b>4.16.1</b> - 2023-02-25
      </li>
      <li>
        <b>4.16.0</b> - 2023-02-24
      </li>
      <li>
        <b>4.15.5</b> - 2022-11-09
      </li>
      <li>
        <b>4.15.3</b> - 2022-11-08
      </li>
      <li>
        <b>4.15.2</b> - 2022-10-26
      </li>
      <li>
        <b>4.15.1</b> - 2022-10-25
      </li>
      <li>
        <b>4.15.0</b> - 2022-10-20
      </li>
      <li>
        <b>4.14.3</b> - 2022-10-11
      </li>
    </ul>
from <a
href="https://snyk.io/redirect/github/swagger-api/swagger-ui/releases">swagger-ui-dist
GitHub release notes</a>
  </details>
</details>
<hr/>

**Note:** *You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs.*

For more information: <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiI4MTkwMDhiMS0xNjhkLTQzZDItOGIxYS0zNzk0ODBlOTg0ODYiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjgxOTAwOGIxLTE2OGQtNDNkMi04YjFhLTM3OTQ4MGU5ODQ4NiJ9fQ=="
width="0" height="0"/>

🧐 [View latest project
report](https://app.snyk.io/org/satt/project/b89486be-ad07-4d6c-a51a-2fa8a25baa00?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/satt/project/b89486be-ad07-4d6c-a51a-2fa8a25baa00/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)

🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/satt/project/b89486be-ad07-4d6c-a51a-2fa8a25baa00/settings/integration?pkg&#x3D;swagger-ui-dist&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

<!---
(snyk:metadata:{"prId":"819008b1-168d-43d2-8b1a-379480e98486","prPublicId":"819008b1-168d-43d2-8b1a-379480e98486","dependencies":[{"name":"swagger-ui-dist","from":"4.14.3","to":"4.18.3"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/satt/project/b89486be-ad07-4d6c-a51a-2fa8a25baa00?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"b89486be-ad07-4d6c-a51a-2fa8a25baa00","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":13,"publishedDate":"2023-04-26T13:12:06.316Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]})
--->
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.

Path in $ref is partually percent-encoded
3 participants