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

Expose ApiPlatform Routes #380

Open
Muspi opened this issue Mar 4, 2020 · 3 comments
Open

Expose ApiPlatform Routes #380

Muspi opened this issue Mar 4, 2020 · 3 comments

Comments

@Muspi
Copy link

Muspi commented Mar 4, 2020

Hi,

I'm trying to expose my api_platform routes to FosJsRouting, but it does not work.

api:
    resource: '.'
    type: 'api_platform'
    prefix: '/api' # Optional
    options:
        expose: true

Does anyone have an idea to do this?
Or any other method without FosJsRouting?

@lambertbeekhuis
Copy link

You can use package/for_js_routing.yaml, list the routes you want to exposer:
fos_js_routing:
routes_to_expose: [
// put them here..
]

@Muspi
Copy link
Author

Muspi commented Jul 20, 2020

Thank you for your answer @lambertbeekhuis.

Can I expose all available routes with a regex, IE api_jobs_* ?

EDIT: Found answer in documentation, it works!!

@Cryde
Copy link

Cryde commented Jun 26, 2021

For the ones that will read this later :
Yes you can expose routes from API Plateform with FOSJsRoutingBundle.

It's easy : create (if you don't have one) config/packages/fos_js_routing.yaml
And then put this in it (depending on the route name you have of course !) :

fos_js_routing:
    routes_to_expose: [api_jobs_(.*), api_types_(.*), ...]

As the doc said :

You can use regular expression patterns if you don’t want to list all your routes name by name.

If you don't know the name of the routes : bin/console debug:router

Hope it will help futur reader !

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

No branches or pull requests

3 participants