I am supposed to pass student-list in a rest operation. The student-list is defined as follow:
- name: student-list
in: query
description: Id of the Student of the target NF
content:
application/json:
schema:
type: array
items:
$ref: 'TS29571_CommonData.yaml#/components/schemas/StudentId'
minItems: 1
Where each item is defined as follow:
StudentId:
type: object
properties:
class:
type: string
rollno:
type: integer
As per above representation, I am supposed to pass array of StudentId json ( with style = form and explode = true ).
As per code generated by OpenAPI Generator, The operation requiring Student list, iterates over each StudentId in the list. For each StudentId, it calls toString method to generate json representation StudentId Object
The StudentId Object have following toString method:
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class StudentId {\n");
sb.append(" class: ").append(toIndentedString(mcc)).append("\n");
sb.append(" rollno: ").append(toIndentedString(mnc)).append("\n");
sb.append("}");
return sb.toString();
}
And the toIndentedString method is defined as follows:
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
My question is: Why OpenAPI is not generating correct code. The toString method is not generating valid json ( as the jSON begins with "class StudentId" and it clutter with "\n" }.
This question is not duplicate of existing question Here, I am asking about sending array of json objects with style = form and explode = false. The existing question does not provide solution to my problem.