swagger-parser icon indicating copy to clipboard operation
swagger-parser copied to clipboard

swagger-parser-v3 Yaml implicit resolver distort property names

Open MZinchenko opened this issue 3 years ago • 0 comments

Description

With any parser settings and model in yaml format, when model contains property "on" parser read property name "true" instead of "on".

Problem caused by wrong DeserializationUtils.CustomResolver.addImplicitResolvers() in swagger-parser-v3. This implicit converter

            addImplicitResolver(Tag.BOOL, BOOL, "yYnNtTfFoO");

converts "on" into "true" (not only values but property names too).

I think nobody needs to change property names, only values by yamlImplicitResolvers.

Test to reproduce the issue

    @Test
    public void test() throws Exception{
        ParseOptions options = new ParseOptions();
        String issue = "openapi: 3.0.3\n" +
            "info:\n" +
            "  version: \"1.0.0\"\n" +
            "  title: Test on-property\n" +
            "paths: {}\n" +
            "components:\n" +
            "  schemas:\n" +
            "    SchemaWithOn:\n" +
            "      properties:\n" +
            "        on:\n" +
            "          type: string";
        SwaggerParseResult result = new OpenAPIV3Parser().readContents(issue, null, options);

        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getOpenAPI());
        Assert.assertNotNull(result.getOpenAPI().getComponents()
            .getSchemas().get("SchemaWithOn")
            .getProperties().get("on")
        );
    }

MZinchenko avatar Sep 14 '22 18:09 MZinchenko