Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresolvable Json pointer generating standalone schema in Windows #21

Closed
poutysquire10 opened this issue Jan 13, 2019 · 2 comments
Closed

Comments

@poutysquire10
Copy link

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
Copy link

tewe commented Mar 27, 2019

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

@garethr
Copy link
Collaborator

garethr commented Apr 4, 2019

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

@garethr garethr closed this as completed Apr 4, 2019
poutysquire10 added a commit to poutysquire10/openapi2jsonschema that referenced this issue Feb 4, 2020
For windows local path the base_uri parameter of JsonRef.replace_refs(...) requires three slashes i.e. file:///d:\mydir\subdir...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants