Skip to content

Commit

Permalink
262 asyncapi print a class as json (#263)
Browse files Browse the repository at this point in the history
- Change toString implementation in models to make it easier to understand it
  • Loading branch information
AdrianLagartera authored Jul 14, 2023
1 parent e9257c5 commit 6ce3fdd
Show file tree
Hide file tree
Showing 142 changed files with 589 additions and 1,742 deletions.
2 changes: 1 addition & 1 deletion multiapi-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.sngular</groupId>
<artifactId>multiapi-engine</artifactId>
<version>4.9.4</version>
<version>4.9.5</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,24 +345,14 @@ public class ${schema.className} {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ${schema.className} {\n");
sb.append("${schema.className}{");
<#list schema.fieldObjectList as field>
sb.append(" ${field.baseName?uncap_first}: ").append(toIndentedString(${field.baseName?uncap_first})).append("\n");
sb.append(" ${field.baseName?uncap_first}:").append(${field.baseName?uncap_first}).append(",");
</#list>
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

<#if schema.schemaCombinator == "anyOf" || schema.schemaCombinator == "oneOf">
private void validatePartialCombinations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,21 +346,14 @@ public class ${schema.className} {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ${schema.className} {\n");
sb.append("${schema.className}{");
<#list schema.fieldObjectList as field>
sb.append(" ${field.baseName?uncap_first}: ").append(toIndentedString(${field.baseName?uncap_first})).append("\n");
sb.append(" ${field.baseName?uncap_first}:").append(${field.baseName?uncap_first}).append(",");
</#list>
sb.append("}");
return sb.toString();
}

private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

<#if schema.schemaCombinator == "anyOf" || schema.schemaCombinator == "oneOf">
private void validatePartialCombinations() {
boolean satisfiedCondition = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,12 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DataClientDTO {\n");
sb.append(" payload: ").append(toIndentedString(payload)).append("\n");
sb.append("DataClientDTO{");
sb.append(" payload:").append(payload).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,15 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DataDTO {\n");
sb.append(" clientId: ").append(toIndentedString(clientId)).append("\n");
sb.append(" clientName: ").append(toIndentedString(clientName)).append("\n");
sb.append(" flightNumber: ").append(toIndentedString(flightNumber)).append("\n");
sb.append(" test: ").append(toIndentedString(test)).append("\n");
sb.append("DataDTO{");
sb.append(" clientId:").append(clientId).append(",");
sb.append(" clientName:").append(clientName).append(",");
sb.append(" flightNumber:").append(flightNumber).append(",");
sb.append(" test:").append(test).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}


private void validateRequiredAttributes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,12 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class StatusDTO {\n");
sb.append(" payload: ").append(toIndentedString(payload)).append("\n");
sb.append("StatusDTO{");
sb.append(" payload:").append(payload).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,13 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class StatusMsgDTO {\n");
sb.append(" clientId: ").append(toIndentedString(clientId)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append("StatusMsgDTO{");
sb.append(" clientId:").append(clientId).append(",");
sb.append(" status:").append(status).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,13 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateOrderMapper {\n");
sb.append(" order: ").append(toIndentedString(order)).append("\n");
sb.append(" waiter: ").append(toIndentedString(waiter)).append("\n");
sb.append("CreateOrderMapper{");
sb.append(" order:").append(order).append(",");
sb.append(" waiter:").append(waiter).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,12 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OrderCreatedDTO {\n");
sb.append(" payload: ").append(toIndentedString(payload)).append("\n");
sb.append("OrderCreatedDTO{");
sb.append(" payload:").append(payload).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,15 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OrderDTO {\n");
sb.append(" ref: ").append(toIndentedString(ref)).append("\n");
sb.append(" clientRef: ").append(toIndentedString(clientRef)).append("\n");
sb.append(" amount: ").append(toIndentedString(amount)).append("\n");
sb.append(" lines: ").append(toIndentedString(lines)).append("\n");
sb.append("OrderDTO{");
sb.append(" ref:").append(ref).append(",");
sb.append(" clientRef:").append(clientRef).append(",");
sb.append(" amount:").append(amount).append(",");
sb.append(" lines:").append(lines).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,13 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OrderLineDTO {\n");
sb.append(" ref: ").append(toIndentedString(ref)).append("\n");
sb.append(" products: ").append(toIndentedString(products)).append("\n");
sb.append("OrderLineDTO{");
sb.append(" ref:").append(ref).append(",");
sb.append(" products:").append(products).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}


private void validateRequiredAttributes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,13 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OrderLineMapper {\n");
sb.append(" ref: ").append(toIndentedString(ref)).append("\n");
sb.append(" products: ").append(toIndentedString(products)).append("\n");
sb.append("OrderLineMapper{");
sb.append(" ref:").append(ref).append(",");
sb.append(" products:").append(products).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}


private void validateRequiredAttributes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,15 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OrderMapper {\n");
sb.append(" ref: ").append(toIndentedString(ref)).append("\n");
sb.append(" clientRef: ").append(toIndentedString(clientRef)).append("\n");
sb.append(" amount: ").append(toIndentedString(amount)).append("\n");
sb.append(" lines: ").append(toIndentedString(lines)).append("\n");
sb.append("OrderMapper{");
sb.append(" ref:").append(ref).append(",");
sb.append(" clientRef:").append(clientRef).append(",");
sb.append(" amount:").append(amount).append(",");
sb.append(" lines:").append(lines).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,15 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OrderProductDTO {\n");
sb.append(" ref: ").append(toIndentedString(ref)).append("\n");
sb.append(" productRef: ").append(toIndentedString(productRef)).append("\n");
sb.append(" price: ").append(toIndentedString(price)).append("\n");
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
sb.append("OrderProductDTO{");
sb.append(" ref:").append(ref).append(",");
sb.append(" productRef:").append(productRef).append(",");
sb.append(" price:").append(price).append(",");
sb.append(" quantity:").append(quantity).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}


private void validateRequiredAttributes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,15 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OrderProductMapper {\n");
sb.append(" ref: ").append(toIndentedString(ref)).append("\n");
sb.append(" productRef: ").append(toIndentedString(productRef)).append("\n");
sb.append(" price: ").append(toIndentedString(price)).append("\n");
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
sb.append("OrderProductMapper{");
sb.append(" ref:").append(ref).append(",");
sb.append(" productRef:").append(productRef).append(",");
sb.append(" price:").append(price).append(",");
sb.append(" quantity:").append(quantity).append(",");
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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}


private void validateRequiredAttributes() {
Expand Down
Loading

0 comments on commit 6ce3fdd

Please sign in to comment.