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

Temporary fix for swagger-ui executing query too fast #2374

Merged

Conversation

patrick-mota
Copy link

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

When you access your resource in swagger with an id the execute action is triggered too fast.
We get an error because the input value isn't already updated.

For example, if you try a query like this one:
http://localhost/{entityName}/{id}

You will get an error in your input.

This fix is only intended to be a workaround.
To fix this we should maybe have a better way to handle with the onComplete in swagger ui which should be fired up when all the ajax calls are done.

We could use MutationObservers too but we don't know when we should fire up the execute click.

Feel free to reply if you have another idea.
Thank you

#SymfonyConHackday2018

@dunglas
Copy link
Member

dunglas commented Dec 8, 2018

Hi @patrick-mota, and thanks for working on this fix, it's very appreciated!

Actually, it looks like Swagger UI now has an oncomplete event (it wasn't the case when I created this hack): swagger-api/swagger-ui#4322

Do you think we can use it?

@patrick-mota
Copy link
Author

Hi @dunglas I'll try to go deeper but after my first tests it doesn't seems working well with the oncomplete because oncomplete is called right after swaggerui is initialized but the input is populated after so it doesn't come already with the value that's why it seems not working.

I'll take a look tonight and keep you informed about the results.

@dunglas dunglas merged commit 875805f into api-platform:master Dec 20, 2018
@dunglas
Copy link
Member

dunglas commented Dec 20, 2018

Thanks @patrick-mota

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.

2 participants