Contributions
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; }988Views0likes1CommentRestricting Floating MetaObject in domainObject definition using OPen APi 3.0
Hi all, I am trying to create domain object with meta which can have different required params based on the actions for example { "action": "tap", "title":"choose option" "postback": "swagger" } { "action": "openPhonebook", "title":"choose contact" "meta":{ "sessionId":"ytyut" } { "action": "openKeyPad": "meta":{ "sessionId":"678768", "partialMessage":"type your input.." } } Inorder to make sure the params in meta is required as per action defined above i followed the this docshttps://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/and created domain as follows. is there any alternate way? meta: type: object properties: partialMessage: type: string example: Change operator to sessionId: type: string example: 6567678872937 actionType: type: string enum: ['tap', 'openPhonebook', 'openKeypad'] example: openPhonebook # base action object actionObject: type: object required: - action properties: action: $ref: '#/components/schemas/actionType' title: type: string postback: type: string meta: $ref: '#/components/schemas/meta' additionalProperties: false # action specific tap: allOf: - $ref: '#/components/schemas/actionObject' - type: object required: - postback - title properties: action: type: string enum: ['tap'] openPhonebook: allOf: - $ref: '#/components/schemas/actionObject' - type: object required: - title properties: action: type: string enum: ['openPhonebook'] meta: allOf: - $ref: '#/components/schemas/meta' - type: object required: - sessionId openKeypad: allOf: - $ref: '#/components/schemas/actionTemplate' - type: object required: - title properties: action: type: string enum: ['openKeypad'] meta: allOf: - $ref: '#/components/schemas/meta' - type: object required: - partialMessage Is it possible to define constant value which can be reference inside enum like instead of hardcoding single enum i want to make reference to a constant which may be changed but it will not affect schema like as follows enumTap: type: string value: tap tap: allOf: - $ref: '#/components/schemas/actionObject' - type: object required: - postback - title properties: action: type: string enum: - $ref: #/Component/enumTap789Views0likes0Comments