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

tryItOutEnabled #300

Closed
physikerwelt opened this issue Apr 16, 2021 · 7 comments · Fixed by #316
Closed

tryItOutEnabled #300

physikerwelt opened this issue Apr 16, 2021 · 7 comments · Fixed by #316
Labels
enhancement New feature or request

Comments

@physikerwelt
Copy link
Contributor

Is your feature request related to a problem? Please describe.
To explore my API I always have to click try it out. This consumes quite some time

Describe the solution you'd like
Add an option to enable the try it out feature by default. This seems already possible in swagger via the tryItOutEnabled setting.
https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md

Describe alternatives you've considered
Hack the library similar to kristleifur/flask-restplus@7896401

Additional context
To avoid additional feature requests of this kind in the future, one might establish a way to pass everything that is listed in
https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md

@physikerwelt physikerwelt added the enhancement New feature or request label Apr 16, 2021
@j5awry
Copy link
Contributor

j5awry commented Apr 26, 2021

I'm a little confused by this request. I believe that the Try It Out plugin is enabled by default. I also believe that the two click operation, click "Try It Out!" then click to send, is how the plugin operates. I may be mistaken on this though. Is there something upstream in the Swagger UI code or in the plugin we could take in our vendoring to fix this? Or is there a specific patch of the HTML page you have in mind?

Otherwise, the only option is to setup something custom as in the linked, but it'd be better if we didn't have to write another JS func and wrap things.

@physikerwelt
Copy link
Contributor Author

To be sure, I tested this via a clean stock swagger UI from dockerhub.
Run docker pull swaggerapi/swagger-ui which pulled Digest: sha256:b95896f3ab22d7e7585bbcce8eed91e887d7fb60ca695582126007e92becda37.
Then I ran docker run -p 80:8080 swaggerapi/swagger-ui and docker run -e TRY_IT_OUT_ENABLED=true -p 80:8080 swaggerapi/swagger-ui. From that I obtained the following screenshots:

  • Screenshot 1 (default config)
    Screenshot_2021-04-26 Swagger UI
  • Screenshot 2 (TRY_IT_OUT_ENABLED=true)
    Screenshot_2021-04-26 Swagger UI(1)

@j5awry
Copy link
Contributor

j5awry commented Apr 27, 2021

thanks for checking and providing screenshots! I'm not working in the web world day to day, so I'm thankful for all reminders and help on that end!

Reading the docs, I'm interested in this:

The swagger-config.yaml in the project root directory, if it exists, is baked into the application

That actually seems like the fastest, and best root. Meaning, providing a way for flask-restx documentation to read the configuration file. Things I'd want to try/test

I have a preference here that we should investigate the swagger-config.yaml file location in relation to the Swagger app generated by flask-restx, then move down on how we can configure. As a former ops person, it makes a lot of sense to me to use the swagger-config.yaml file if possible, and have configuration be part of deployment. I'd prefer that to adding more variables into the template

That being said, it's easier to add to the template than I had first thought, so I don't find it as onerous.

@physikerwelt
Copy link
Contributor Author

* if one drops a swagger-config.yaml in the proper place (in relation to the swagger UI code), will it get read?

Do you know where this location could be? It seems webpack integrates one version of swagger-config.yaml already today:
Screenshot from 2021-04-27 20-45-50

@xuhdev
Copy link
Contributor

xuhdev commented May 10, 2021

It looks like this feature was enabled since swagger UI v 3.41.0, but restx is still using v2: swagger-api/swagger-ui#7252 (comment)

Perhaps this is the reason?

xuhdev added a commit to xuhdev/flask-restx that referenced this issue May 18, 2021
xuhdev added a commit to xuhdev/flask-restx that referenced this issue May 18, 2021
@physikerwelt
Copy link
Contributor Author

I did the following

  501  cd /tmp/
  502  git clone https://github.com/xuhdev/flask-restx.git
  503  cd flask-restx/
  504  pip install -e .
  505  inv -l
  506  sudo apt install python3-invoke
  507  inv -l
  512  sudo apt-get install python-is-python3
  513  inv demo

and now I am seeing a blank page and the log says

127.0.0.1 - - [25/May/2021 13:47:53] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [25/May/2021 13:47:53] "GET /swaggerui/droid-sans.css HTTP/1.1" 404 -
127.0.0.1 - - [25/May/2021 13:47:53] "GET /swaggerui/swagger-ui.css HTTP/1.1" 404 -
127.0.0.1 - - [25/May/2021 13:47:53] "GET /swaggerui/swagger-ui-bundle.js HTTP/1.1" 404 -
127.0.0.1 - - [25/May/2021 13:47:54] "GET /swaggerui/swagger-ui-standalone-preset.js HTTP/1.1" 404 -
127.0.0.1 - - [25/May/2021 13:47:54] "GET /swaggerui/swagger-ui-standalone-preset.js HTTP/1.1" 404 -
127.0.0.1 - - [25/May/2021 13:47:54] "GET /swaggerui/favicon-16x16.png HTTP/1.1" 404 -

Is there anything else to be done for testing?

@ziirish
Copy link
Contributor

ziirish commented May 25, 2021

Hello,

Yes, sorry, the assets are not part of the git repository, you have to run pip install -e .[dev]; inv assets as documented here in order to be able to run the development version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants