Symfony Api Platform /api not showing the api page correctly

113
April 20, 2021, at 3:40 PM

I'm working on a Symfony Project. I had to install the API PLATFORM. So I did a

composer require api

Then when I want to access my /api with localhost:8000/api, it shows me this code

{"resourceNameCollection":["App\\Entity\\User"]}

with a white page, nothing more.

My question is why is it not showing this instead ?

My routes/api_platform.yaml

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

My packages/api_platform.yaml

api_platform:
title: 'Symfony REST API'
description: 'A Symfony API.'
version: '1.0.0'
mapping:
    paths: ['%kernel.project_dir%/src/Entity']
swagger:
    versions: [3]
patch_formats:
    json: ['application/json']
eager_loading:
    force_eager: false
formats:
    json:
        mime_types: ['application/json']
    multipart:
        mime_types: ['multipart/form-data']
collection:
    pagination:
        enabled: false

My security.yaml

security:
encoders:
    App\Entity\User:
        algorithm: bcrypt
providers:
    users_in_memory: { memory: null }
    users_in_database:
        entity:
            class: 'App\Entity\User'
            property: "username"
firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        anonymous: true
        provider: users_in_database
        form_login:
            login_path: security_login
            check_path: security_login
        logout:
            path: security_logout
            target: home
access_control:
Answer 1

I found the problem.

In my 'packages/api_platform.yaml', I added

html:
        mime_types: ['text/html']

In the formats like this

formats:
    json:
        mime_types: ['application/json']
    jsonld:
        mime_types: ['application/ld+json']
    html:
        mime_types: ['text/html']
    multipart:
        mime_types: ['multipart/form-data']

So basically it needed the html format to render the page, I guess.

READ ALSO
Displaying output from different function in one innerHTML

Displaying output from different function in one innerHTML

I am trying to display two outputs in different functions into single innerHTML when the button clickedHowever, I want it without using a global variable to store the output

20
2 col layout expanding past max width (TAILWIND CSS)

2 col layout expanding past max width (TAILWIND CSS)

Here's a quick rundown of the relevant code before I ask this question

108
InertiaJS with VueJS conflict with jQuery

InertiaJS with VueJS conflict with jQuery

So, I have this inertiaJS & VueJS app am creating, the backend is in LaravelAt the start, the app is working fine, but once you navigate to another page say log in, Jquery just fails without any error message and everything becomes deformed, even when I navigate...

128