cancel
Showing results for 
Search instead for 
Did you mean: 

Not getting defined properties when using additional properties #9665

New Contributor

Not getting defined properties when using additional properties #9665

Hi
I have created apis using swagger openapi: 3.0.0

inside the response of one api i have object like this

metaObject:
  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;
}
1 REPLY 1
Moderator

Re: Not getting defined properties when using additional properties #9665

Please file a ticket directly with the Swagger Codegen project.

New Here?
Join us and watch the welcome video:
SeptemberNews
Join our online event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win