question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swagger UI docs 404

See original GitHub issue

API Platform version(s) affected: 2.6

Description
Some Swagger UI docs resources like javascript and css are not loaded from the correct path which you configured in “config/routes/api_platform.yaml” resulting in a 404.

How to reproduce

  1. Setup an ingress blocking everything that does not start with /api/users
  2. configure the api_platform prefix to /api/users
  3. Some resources for displaying the Swagger UI don’t pass the ingress as they are coming from host/bundles

Example: expected: https://localhost:8000/api/users/public/bundles/apiplatform/swagger-ui/swagger-ui.css actual: https://localhost:8000/bundles/apiplatform/swagger-ui/swagger-ui.css The ingress is blocking https://localhost:8000/bundles/

There should be a way to change the path from where these resources are served.

Possible Solution
I don’t know maybe serve the files for the UI from the same URL that is setup in config/routes/api_platform.yaml

This is how the swagger ui docs looks like Additional Context

most important settings of my app:

Dockerfile

FROM php:7.4-fpm

RUN apt-get update && apt-get install -y zlib1g-dev g++ git libicu-dev zip libzip-dev zip \
    && docker-php-ext-install intl opcache pdo pdo_mysql \
    && pecl install apcu \
    && docker-php-ext-enable apcu \
    && docker-php-ext-configure zip \
    && docker-php-ext-install zip

WORKDIR /app
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN curl -sS https://get.symfony.com/cli/installer | bash
RUN mv /root/.symfony/bin/symfony /usr/local/bin/symfony
#RUN symfony server:ca:install

ADD composer.json composer.lock ./
RUN composer install
ADD . .
RUN ./bin/console cache:clear

CMD ["symfony", "server:start", "--no-tls"]

k8s/ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
    #nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
  rules:
    - host: ticketing.dev
      http:
        paths:
          - path: /api/users
            backend:
              serviceName: user-srv
              servicePort: 8000

config/routes/api_platform.yaml

api_platform:
    resource: .
    type: api_platform
    prefix: /api/users

Screenshot from 2021-02-06 16-56-19

Screenshot from 2021-02-06 17-53-46

Screenshot from 2021-02-06 17-54-53

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

22reactions
numericks-yanncommented, Jun 18, 2021

Go to your docker and run -> bin/console asset:install 😃

0reactions
ramineifarcommented, Oct 4, 2022

I’m using Docker with PHP-8.1.9 and API Platform 3.0 and the same render on Front ! it is a new project API Platform. The symfony website work correctly but not API Platform !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger with Spring Boot 2.0 leads to 404 error page
By setting the logging level to "DEBUG", I was able to see endpoints for /v3/api-docs and they worked, but there was nothing about...
Read more >
Getting HTTP 404 error on /swagger-ui.html but other ... - GitHub
I am facing similar problem for integrate with swagger with spring boot. Using http://localhost:8080/v2/api-docs URL, JSON dump that Swagger 2 ...
Read more >
Getting error 404 in deployed swagger project - Google Groups
You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails...
Read more >
OpenApi 3 (Swagger UI), Spring Boot, Spring Security: 404 ...
antMatchers() rule to your SecurityConfig still has 404 error. According to the springdoc OpenAPI documentation, all…
Read more >
Installation - Swagger Documentation
SwaggerUIBundle is equivalent to SwaggerUI . Docker. You can pull a pre-built docker image of the swagger-ui directly from Docker Hub: docker pull ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found