Error while uploading the swagger file

8858-error-drupal-apigee-swagger.png

Hello Team,

I have installed Swagger UI Field Formatter module using composer. I am getting an error as soon as i open the file. Please find the attachment for error details. Could you please let me know what am i supposed to do and how? Do i need to make any changes in composer.json file?

Please help me find out the solution, at the earliest.

0 17 331
17 REPLIES 17

@Shweta V Revankar Have you installed swagger ui library? You may download this from Swagger UI and place it inside /webroot/libraries/swagger-ui/

or you can make some changes to your composer.json as described in the module page here. https://www.drupal.org/project/swagger_ui_formatter

Hope that helps!

Yes, I have installed.I have already tried both the approaches mentioned above @Jyothi K Reddy but I am still facing this issue.

Any more pointers that I can try to resolve.

Thanks in advance.

@Shweta V Revankar go to /vendor/symphony/ see if there is a directory called 'dom-crawler' here. If its not there, please reinstall. If it is present, let us know the version. Also could you let us know your D8 version, whether you are using kickstart or vanilla Drupal 8 ? Thanks

I was able to simulate the issue and doing a "composer require symfony/dom-crawler" fixed the issue. @Shweta V Revankar let us know if the above solution works for you.

@Jyothi K Reddy

I reinstalled the Kickstart module and now it is giving a new error saying the Swagger UI Library not found.

Can you please help me with the root structure? Attached is the error details.swagger-ui-error.png

@Shweta V Revankar The instructions provided at : https://www.drupal.org/project/swagger_ui_formatter worked for me. Can you give it a try ?

I installed Drupal once again and could install Swagger UI Library.

@Jyothi K Reddy I am using kickstart drupal 8. There is a directory called 'dom-crawler' inside /vendor/symphony/ and it's version is "^4.3".

@arungopal I tried doing "composer require symfony/dom-crawler" but it did not fix the issue for me.

Error: "The website encountered an unexpected error. Please try again later." is getting displayed now.

Anything else that i need to do?

Thanks

@Shweta V Revankar

can you check the recent logs and paste the error here ? That will tell us if the issue is with dom-crawler or some other dependency.

@arungopal I tried installing the Swagger UI module using the instructions provided in the link i.e.,

https://www.drupal.org/project/swagger_ui_formatter but it did not work for me. I had to download it manually and copy it in the root directory.

Please find the attachment for the error.recent-log.pngrecent-log-error-list.pngswagger-installation-error.png

Clearly the issue is that dom-crawler component is not installed correctly. I have tried downloading kickstart using composer and ran it locally, it worked as expected. A few more questions to try and debug this further.

1. I see you are downloading kickstart using composer. Are you using Acquia Dev desktop or something similar to run your local env. ?

2. Have you tried using quick-start ( go inside MY_PROJECT and run composer quick-start). This will spin up a local instance where you can quickly upload a swagger file and see if it works as expected.

3. If above works, try installing the library by running

composer require symfony/dom-crawler

as suggested by @arungopal.

Let us know how that goes.

@Jyothi K Reddy

1. I have used XAMPP for installation and it's in my Local. I found downloading through composer is better than doing it manually, because of version issue.

2. I tried running "Composer quick-start" it did not work for me. Attached is the error i am facing while running the command.

3. "composer require symphony/dom-crawler" command threw a new error. Please find the attachment.

I am not able to understand whether it is an folder error or installation mistake!! composer-quickstart-error.pngcomposer-require-symphony-error.png

I've made a mistake in spelling symfony. Now I've updated the command above. Try using this. And regarding quick-start seems there is a wrong line ending on composer.json.Please upload that file if possible.

Thanks

Even after changing the spelling, the command did not work.

I have uploaded both the composer.json file.

1. C:\xampp\htdocs\testsite - composer-1json.txt

2. C:\xampp\htdocs\testsite\MY_PROJECT - composer-2json.txt

NOTE: It do not allow an json file to upload so i have changed it to txt format. I have added "-1json" & "-2json" just to avoid confusion.

I think the directory structure looks suspicious. There need not be 2 different composer.json files unless its specifically intended to. I have created a docker file and docker-compose.yml for kickstart. Try this out and let us know if it helps. https://github.com/kiranjyoth/apigee_devportal_kickstart_docker

@Jyothi K Reddy Why is docker file required?? How will this file help me find out solution for swagger?

@Shweta V Revankar your directory structure kind of looked suspicious with 2 composer json files. I was hoping that this above code will help you setup your local instance.

1. Once your local instance is up, go to your docroot and update your composer.json to the file attached. (this composer is from my local - Please note that I have modified it to get required libraries for swagger UI).

2. Run composer require drupal/swagger_ui_formatter (Running this will download the dom-crawler as well)

3. Now run composer require oomphinc/composer-installers-extender bower-asset/swagger-ui ( This will download all libraries required for swagger UI)

4. Enable swagger UI formatter by going to /admin/modules/

5. Now go and change API doc settings as described here. https://www.drupal.org/docs/8/modules/apigee-api-catalog-0/render-openapi-specs

6. Clear your caches.

7. Check if all docs render using swagger ui. (screenshot attached)

Let us know how that goes. I tried this on a fresh install and the files added here are from my local.

composerjson.txt

8931-swagger-ui.png

I tried installing docker in my system but they needed Windows 10 for the installation and i was using Windows 8 hence couldn't meet the requirement.

So i reinstalled drupal and tried with the same command as per

https://www.drupal.org/project/apigee_devportal_kickstart

I could see all the dependencies created in a single composer.json file.

Then i ran "composer require symfony/dom-crawler" command and it started working as expected.

Thank you very much @Jyothi K Reddy for all your support and pointers. It helped me alot.

Thanks to @arungopal as well!!