instrumenta / openapi2jsonschema

Convert OpenAPI definitions into JSON schemas for all types in the API
Other
226 stars 87 forks source link

Unresolvable Json pointer generating standalone schema in Windows #21

Closed poutysquire10 closed 5 years ago

poutysquire10 commented 5 years ago

I use this command to generate standalone json schema in Windows: openapi2jsonschema -o schema_KO --stand-alone file:///c:/sample/sample_KO.json
and i get this message:

Downloading schema Parsing schema Generating shared definitions Generating individual schemas Processing sampleresponsetype Generating sampleresponsetype.json An error occured processing sampleresponsetype: Unresolvable JSON pointer: '/definitions/innerDefini tion' Processing innerdefinition Generating innerdefinition.json Generating schema for all types

I have the error only in Windows, no.t in Linux. And only with --stand-alone option I'm using Windows 7, python 3.7.2, openapi2jsonschema v. 0.8.0

The json file is:

{ "swagger": "2.0", "info": { "version": "2.0", "title": "sampleServices", "description": "Sample for error" }, "paths": { "/sample": { "get": { "responses": { "200": { "description": "execution ok", "schema": { "$ref": "#/definitions/sampleResponseType" } } }, "operationId": "getSample" } } }, "host": "myhost", "basePath": "/samples", "definitions": { "sampleResponseType": { "description": "", "properties": { "inner": { "$ref": "#/definitions/innerDefinition" }, "message": { "description": "message echo", "type": "string" } } }, "innerDefinition": { "description": "inner definitions", "properties": { "myparam": { "description": "param", "type": "string" } } } } }

The utility does not recognize the reference to innerDefinition within the definition of sampleResponseType.

If I remove it, the schema generation complete successfully.

This is the new sampleResponseType definition: "definitions": { "sampleResponseType": { "description": "", "properties": { "message": { "description": "message echo", "type": "string" } } }, "innerDefinition": { "description": "inner definitions", "properties": { "myparam": { "description": "param", "type": "string" } } } }

tewe commented 5 years ago

Until garethr/openapi2jsonschema#17 is merged switching to legacy Python (2) fixes this.

garethr commented 5 years ago

17 is merged and I think this should work now. Thanks, and apologies for the wait.