OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Java] Escaped bean property name should be resumed

Open
#3,191 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

xref: https://github.com/kubernetes-client/java/pull/595

in the kubernetes openapi spec, there's some escaped property name in the schema:

    "io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1beta1.JSONSchemaProps": {
      "description": "JSONSchemaProps is a JSON-Schema following Specification Draft 4 (http://json-schema.org/).",
      "properties": {
        "$ref": {
          "type": "string"
        },
        "$schema": {
          "type": "string"
        }
....

the generator doesn't seem to properly handle the name and my java output is failing the compiliation:

@ApiModel(description = "JSONSchemaProps is a JSON-Schema following Specification Draft 4 (http://json-schema.org/).")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2019-06-20T12:55:05.588Z[Etc/UTC]")
public class V1beta1JSONSchemaProps {
  public static final String SERIALIZED_NAME_$_REF = "$ref";
  @SerializedName(SERIALIZED_NAME_$_REF)
  private String $ref;

  public static final String SERIALIZED_NAME_$_SCHEMA = "$schema";
  @SerializedName(SERIALIZED_NAME_$_SCHEMA)
  private String $schema;
openapi-generator version

v4.0.0

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix

it seems that in the swagger-codegen we won't have the issue.

https://github.com/kubernetes-client/java/blob/dc82549dde1eeea7593203dec788af0fe33685a7/kubernetes/src/main/java/io/kubernetes/client/models/V1beta1JSONSchemaProps.java#L38-L42

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Java generation from the Kubernetes OpenAPI schema containing the $ref and $schema properties, then compare the generated V1beta1JSONSchemaProps.java output with the linked swagger-codegen version. Done means the generated Java compiles and the escaped property names remain mapped to their schema names.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.