openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [Java] [Spring] Property "on" regression in 6.x

Open MZinchenko opened this issue 3 years ago • 1 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

With any generator settings and model (yaml format) contains property "on" (any type) generated model contains 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". openapi-generator can't change this behavior :(

openapi-generator version

It's a regression introduced with openapi-generator 6.x. With the 5.x version the generated code behaves as expected.

swagger-parser-v3: 2.0.31

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  version: "1.0.0"
  title: Test on-property

paths: {}

components:
  schemas:
    SchemaWithOn:
      properties:
        on:
          type: string
Generation Details

Actual output

  @JsonProperty("true")
  private String true;

Expected output

  @JsonProperty("on")
  private String on;
Suggest a fix

New parser version with fixed https://github.com/swagger-api/swagger-parser/issues/1798

MZinchenko avatar Sep 14 '22 15:09 MZinchenko

@MZinchenko meanwhile you can use this workaround - https://github.com/OpenAPITools/openapi-generator/issues/12710#issuecomment-1173569037

borsch avatar Sep 18 '22 07:09 borsch