swagger-api / swagger-api/swagger-parser
swagger-parser-v3 Yaml implicit resolver distort property names
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
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")
);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in swagger-parser-v3 at DeserializationUtils.CustomResolver.addImplicitResolvers(), then run the reproducing test from the issue through OpenAPIV3Parser.readContents(). Verify that a schema property named "on" remains accessible as "on" while boolean values still use the intended YAML resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100