Hi. I tried using the client-generator repository to use hydra api in a react native project. I followed the steps in the docs and changed the demo api to our own api which uses Symfony 4 with @api-platform/admin. This is the error that I get after running the command.
npx @api-platform/client-generator {{api docs url}} output/ --resource User --generator react-native
This is the result:
Error: The class "http://www.w3.org/ns/hydra/core#ApiDocumentation" is not defined in the API documentation.
at findSupportedClass (/Users/jandrell/.npm/_npx/49065/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/hydra/parseH
ydraDocumentation.js:80:9)
at /Users/jandrell/.npm/_npx/49065/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/hydra/parseHydraDocumentation.js
:255:27
at process._tickCallback (internal/process/next_tick.js:68:7)
I suspect you're using the wrong URL for the entrypoint.
You should not use /docs but /
@teohhanhui I see. I tried removing the /docs part but I'm getting a 401 error. Do this have an ability to include a token somewhere before generating the code?
@jandrell-formoso not yet, you have to edit the code generated in dataAccess.js to put your authentication logic. Adding an option to the client generator to support authentification would be nice btw. See https://github.com/api-platform/client-generator/issues/172.
Hello, I have the same problem with the api-doc-parser client. The problem is that route / is handled by a DefaultController that returns basically nothing… What other route is available to be used by the parser?
Edit: Nevermind, the project I have inherited has the api-platform mounted on an url prefix.
Thank you