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

Not getting defined properties when using additional properties

Open shankar96 opened this issue 7 years ago • 0 comments

Hi I have created apis using swagger openapi: 3.0.0 inside the response of one api i have object like this

      title: meta
      type: object
      required: 
        - sessionId
      properties:
        partialMessage:
          type: string
          example: Change operator to
        sessionId:
          $ref: '#/components/schemas/sesssionId'
      additionalProperties:
        type: string

Now when generating code it is Just creating MetaObject class extending HashMap like this

package code.niki.HelperLibs.actiontemplate.model;

import java.util.HashMap;
import java.util.Objects;

/**
 * MetaObject
 */
public class MetaObject extends HashMap<String, String> {

  @Override
  public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    return Objects.hash(super.hashCode());
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class MetaObject {\n");
    sb.append("    ").append(toIndentedString(super.toString())).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }

  public MetaObject setSessionId(String sessionId){
    this.put("sessionId", sessionId);
    return this;
  }
  public MetaObject setPartialMessage(String partialMessage){
    this.put("partialMessage", partialMessage);
    return this;
  }
  public MetaObject setPromocode(String promocode){
    this.put("promocode", promocode);
    return this;
  }
  public MetaObject setContent(String content){
    this.put("content", content);
    return this;
  }
  public MetaObject setGetUrl(String getUrl){
    this.put("getUrl", getUrl);
    return this;
  }
  public MetaObject setOrderDetail(String orderDetail){
    this.put("orderDetail", orderDetail);
    return this;
  }
}

instead i am expecting something like setter and getter like below getting for existing properties which is defined

public MetaObject setSessionId(String sessionId){
    this.put("sessionId", sessionId);
    return this;
  }

shankar96 avatar Aug 23 '19 12:08 shankar96