api-platform/api-doc-parser

Bug parsing OpenAPI https://netcoreblockly.herokuapp.com/swagger/v1/swagger.json

ignatandrei opened this issue · 0 comments

API Platform version(s) affected: "0.12.0",

Description
When parsing https://netcoreblockly.herokuapp.com/swagger/v1/swagger.json it gives error when reading "properties" in

\node_modules@api-platform\api-doc-parser\lib\openapi3\handleJson.js

var properties = schema.properties;

The tags does not show always the schema.

var title = responsePathItem.tags[0];

If you look at the json https://netcoreblockly.herokuapp.com/swagger/v1/swagger.json the tags[0] is DB_Departments
"/api/DB_Departments": {
"get": {
"tags": [
"DB_Departments"
],

This is not in the "components": {
"schemas": {

Rather, the program should be reading from responses:
"items": {
"$ref": "#/components/schemas/Department"
}

How to reproduce

    const SwaggerParser = require("@api-platform/api-doc-parser/lib/openapi3/parseOpenApi3Documentation");
    var q = await SwaggerParser.default('https://netcoreblockly.herokuapp.com/swagger/v1/swagger.json');

Possible Solution

As an workaround, until a real solve, we can try to alleviate by parsing what we can

var schema = response.components.schemas[title];
//added code
		if(schema == undefined){
			console.error ('cannot find schema for ' + title)
			return null;
		}
//more code
return resources.filter(it=>it != null);

Additional Context