OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

OpenApiStringReader bubbles parsing error for valid JSON document

Open scott-lin opened this issue 7 years ago • 2 comments

The following document produces a parsing error due to the backslash in the basePath property. It is valid JSON, however, so I feel like the library should handle this without error. I believe this is a limitation/bug in SharpYaml parser being used within OpenAPI.NET.

Document

{
	"swagger": "2.0",
	"info": {
		"title": "This is a simple example",
		"version": "1.0.0"
	},
	"host": "example.org",
	"basePath": "\/api",
	"schemes": [
		"http",
		"https"
	],
	"paths": {}
}

Repro Code

var openApiStringReader = new OpenApiStringReader();
OpenApiDocument openApiDocument = openApiStringReader.Read( serializedDocument, out OpenApiDiagnostic openApiDiagnostic );

Error from OpenApiDiagnostic (Lin: 7, Col: 13, Chr: 140) - (Lin: 7, Col: 14, Chr: 141): While parsing a quoted scalar, find unknown escape character.

scott-lin avatar May 31 '18 22:05 scott-lin

This is a new escape character in Yaml 1.2. I will create a PR in SharpYaml to add support for it.

darrelmiller avatar Jun 05 '18 16:06 darrelmiller

We should retest this bug to see if latest versions of YamlSharp address this. /cc @MaggieKimani1

darrelmiller avatar Apr 04 '23 12:04 darrelmiller