create-client icon indicating copy to clipboard operation
create-client copied to clipboard

React Swagger

Open noud opened this issue 5 years ago • 0 comments

hi, i have a React Swagger question

I use Laravel w/ a generated API conform Swagger 2.0 "appointer/swaggervel": "dev-master", "doctrine/dbal": "^2.10", "fruitcake/laravel-cors": "^2.0", "infyomlabs/laravel-generator": "^7.0", "infyomlabs/swagger-generator": "dev-master", on my server, /api/docs works and i am able to get data.

node_modules/.bin/generate-api-platform-client http://politie.localhost/docs src/ --format swagger gives:

Code for the "Locaty" resource type has been generated! Paste the following definitions in your application configuration (client/src/index.js by default):

// import reducers import locaty from './reducers/locaty/';

//import routes import locatyRoutes from './routes/locaty';

// Add the reducer combineReducers({ locaty,/* ... */ }),

// Add routes to <Switch> { locatyRoutes }

So i conclude, @api-platform/api-doc-parser does work. (right conclusion?)

I paste the above into src/index.js. yarn start and browse to /locaties/ I do see all data being transferred in the browser network inspector.

The client errors out: TypeError: Cannot read property 'map' of undefined src/components/locaty/List.js:72 i presume at "this.props.retrieved['hydra:member']..map(item => (" where retrieved is null in my case.

I did read remarks about this all did start w/ Hydra and not all being generic yet. Like mentioned in issue #90 . (so my guess is the error is not on me, nor the swagger api end-point)

So it's a bug-report in that React Swagger just still does not work.

But there is also my question: would templates/react/components/foo/List.js:72 together with utils/dataAccess.js be an actual start (for me or someone) to get this client working w/ actual swagger data?

thanks, Noud

noud avatar Aug 11 '20 20:08 noud