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

Can't get parameter validation error list in param-body #7451

Open
ghost opened this issue Aug 5, 2021 · 1 comment
Open

Can't get parameter validation error list in param-body #7451

ghost opened this issue Aug 5, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 5, 2021

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Version: latest
  • Method of installation: source code debug
  • Swagger-UI version: latest
  • Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.0

Content & configuration

The code to get the validation error list in src/core/components/param-body.jsx

// line 110 - 111
let parameter = specSelectors ? specSelectors.parameterWithMetaByIdentity(pathMethod, param) : param
let errors = parameter.get("errors", List())

seems can't get the error list set in the [VALIDATE_PARAMS] reducer. While I changed it to

// line 111
let errors = param.get("errors", List())

to get the error list directly from the param variable, and it worked.

I think this may be a defect and don't know why this specSelectors.parameterWithMetaByIdentity(pathMethod, param) is necessary. Please take a look.


Example Swagger/OpenAPI definition:

# your YAML here

Swagger-UI configuration options:

SwaggerUI({
  // your config options here
})
?yourQueryStringConfig

Describe the bug you're encountering

To reproduce...

Steps to reproduce the behavior:

  1. Go to 'petstore'
  2. Scroll down to 'any api with additional body parameter'
  3. Change it's json body to any invalid format
  4. Click on Execute

Expected behavior

There would be some feedback on the page

Screenshots

Additional context or thoughts

If the param-body gets the errors correctly, there would be a hint on the page indicating the param error for #6295.
And if the error messages can be displayed on the page, it would be even better.

@smellyfrogcom
Copy link

smellyfrogcom commented Jan 17, 2022

@char0n I have found where the problem comes from for this issue. The problem is caused by the hashCode function not returning the expected value.
I have some workaround code available there (Line 312-314):
https://github.com/smellyfrogcom/swagger-ui/blob/bug/7451-json-validation-error/src/core/plugins/spec/selectors.js

Would you mind taking a look and please advise me on what I should do with this?
Some people suggested dropping the parameterWithMetaByIdentity method completely and use the errors directly.

Thanks

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

No branches or pull requests

1 participant