-
-
Notifications
You must be signed in to change notification settings - Fork 130
Closed
Description
Hi, I am trying to generate a react client from a swagger API.
npx @api-platform/client-generator http:/myapi/swagger/docs/v1 src/ --resource Item --format swagger
I get the error
TypeError: Cannot read property 'properties' of undefined
I stepped through this a little and this error occurs here:
exports.default = function (response, entrypointUrl) {
var paths = (0, _lodash.uniq)((0, _keys2.default)(response.paths).map(function (item) {
return item.replace("/{id}", "");
}));
var resources = paths.map(function (item) {
var name = item.replace("/", "");
var url = removeTrailingSlash(entrypointUrl) + item;
var firstMethod = (0, _keys2.default)(response.paths[item])[0];
var title = response.paths[item][firstMethod]["tags"][0];
/*
* ERROR OCCURS HERE:
*/
var fieldNames = (0, _keys2.default)(response.definitions[title].properties);
What happens, is it attempts to get fieldNames from
var title = response.paths[item][firstMethod]["tags"][0]; // tags[0] = "Item"
response.definitions["Item"].properties.
However, the Item endpoint does not return an Item object, it returns "ApiResponse[ItemDto]".
"paths": {
"/api/v1/Item": {
"get": {
"tags": [
"Item"
],
....
"parameters": [
....
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/ApiResponse[ItemDto]"
}
}
}
},
},
"definitions": {
"ApiResponse[ItemDto]": {
"type": "object",
"properties": {
"Pagination": {
"$ref": "#/definitions/ApiPagination"
},
"Data": {
"type": "array",
"items": {
"$ref": "#/definitions/ItemDto"
}
}
}
},
So I can see that to find the properties it needs to traverse the "$ref's".
Any advice would be appreciated.
gusarov112 and Ilingu
Metadata
Metadata
Assignees
Labels
No labels