Skip to content

Commit

Permalink
#160 Fix Templates and white spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jemacineiras committed Jun 1, 2023
1 parent 206ea71 commit f04e272
Show file tree
Hide file tree
Showing 56 changed files with 335 additions and 400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,21 @@ public class ${className?cap_first}Api {
}

/**
* ${operation.operationType} ${path.pathName} <#if operation.summary?has_content>: ${operation.summary}</#if>
* ${operation.operationType} ${path.pathName}<#if operation.summary?has_content>: ${operation.summary}</#if>
<#if operation.responseObjects?has_content>
<#if operation.parameterObjects?has_content>
* @param<#list operation.parameterObjects as parameter> ${parameter.name} ${parameter.description} ${parameter.required?c}</#list>
* @param<#list operation.parameterObjects as parameter> ${parameter.name} ${parameter.description} ${parameter.required?c}</#list>
</#if>
<#if path.parameterObjects?has_content>
* <#list operation.parameterObjects as parameter>@param ${parameter.name} ${parameter.description} ${parameter.required?c}</#list>
* <#list operation.parameterObjects as parameter>@param ${parameter.name} ${parameter.description} ${parameter.required?c}</#list>
</#if>
<#if operation.requestObjects?has_content>
* <#list operation.requestObjects as request>@param <#list request.contentObjects as content>${content.dataType?api.getVariableNameString()} <#if content?has_next>, </#if></#list> ${request.description! ""}<#if request.required == true> (required)</#if></#list>
* <#list operation.requestObjects as request>@param <#list request.contentObjects as content>${content.dataType?api.getVariableNameString()} <#if content?has_next>, </#if></#list> ${request.description! ""}<#if request.required == true> (required)</#if></#list>
</#if>
* @return<#list operation.responseObjects as response><#if response.responseName != "default"> ${response.description}; (status code ${response.responseName})</#if></#list>
* @return<#list operation.responseObjects as response><#if response.responseName != "default"> ${response.description}; (status code ${response.responseName})</#if></#list>
</#if>
* @throws WebClientResponseException if an error occurs while attempting to invoke the API
*/
* @throws WebClientResponseException if an error occurs while attempting to invoke the API
*/
public <@compress single_line=true><#if operation.responseObjects[0].contentObjects[0]??>
<#if operation.responseObjects[0].contentObjects[0].dataType.baseType == "array" || operation.responseObjects[0].contentObjects[0].dataType.baseType == "map">
Flux<${operation.responseObjects[0].contentObjects[0].dataType.innerType}><#else>Mono<${operation.responseObjects[0].contentObjects[0].dataType}></#if>
Expand Down Expand Up @@ -273,5 +273,4 @@ public class ${className?cap_first}Api {

</#list>
</#list>

}
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ public class ${schema.className} {
public ${field.dataType} get${field.baseName?cap_first}() {
return ${field.baseName?uncap_first};
}

<#if field.required == false>
public void set${field.baseName?cap_first}(${field.dataType} ${field.baseName?uncap_first}) {
this.${field.baseName?uncap_first} = ${field.baseName?uncap_first};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;

import com.sngular.api.generator.plugin.exception.InvalidAPIException;
import com.sngular.api.generator.plugin.openapi.parameter.SpecFile;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class OpenApiGeneratorTest {

@TempDir
@TempDir(cleanup = CleanupMode.NEVER)
static Path baseDir;

private static OpenApiGenerator openApiGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public ApiTestAllOfDTO build() {
}
}


@Schema(name = "testers", required = false)
public List<String> getTesters() {
return testers;
Expand All @@ -72,7 +71,6 @@ public void setTesters(List<String> testers) {
this.testers = testers;
}


@Schema(name = "testName", required = false)
public String getTestName() {
return testName;
Expand Down Expand Up @@ -108,7 +106,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ public ApiTestDTO build() {
}
}


@Schema(name = "testers", required = true)
public List<String> getTesters() {
return testers;
}


@Schema(name = "testName", required = true)
public String getTestName() {
return testName;
Expand Down Expand Up @@ -108,7 +106,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public ApiTestInfoDTO build() {
}
}


@Schema(name = "testers", required = false)
public List<String> getTesters() {
return testers;
Expand All @@ -77,7 +76,6 @@ public void setTesters(List<String> testers) {
this.testers = testers;
}


@Schema(name = "testName", required = true)
public String getTestName() {
return testName;
Expand Down Expand Up @@ -110,7 +108,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,61 @@
import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.ArrayList;
import lombok.Builder;
import lombok.Data;
import lombok.NonNull;
import lombok.extern.jackson.Jacksonized;
import com.sngular.multifileplugin.testanyofinresponse.model.exception.ModelClassException;

@Data
public class InlineResponse200ListGamesAnyOfDTO {

@JsonProperty(value ="gameInfo")
private GameInfoDTO gameInfo;
@JsonProperty(value ="gameName")
@NonNull
private String gameName;

@JsonProperty(value ="game")
private GameDTO game;
@JsonProperty(value ="name")
@NonNull
private String name;

@JsonProperty(value ="id")
@NonNull
private Integer id;

@JsonProperty(value ="rooms")
@NonNull
private Integer rooms;

@JsonProperty(value ="players")
private List<String> players = new ArrayList<String>();


@Builder
@Jacksonized
private InlineResponse200ListGamesAnyOfDTO(GameInfoDTO gameInfo, GameDTO game) {
this.gameInfo = gameInfo;
this.game = game;
private InlineResponse200ListGamesAnyOfDTO(@NonNull String gameName, @NonNull String name, @NonNull Integer id, @NonNull Integer rooms, List<String> players) {
this.gameName = gameName;
this.name = name;
this.id = id;
this.rooms = rooms;
this.players = players;

validatePartialCombinations();
}

private void validatePartialCombinations() {
boolean satisfiedCondition = false;

if (Objects.nonNull(this.gameInfo)) {
if (Objects.nonNull(this.gameName)) {
satisfiedCondition = true;
} else if (Objects.nonNull(this.name)) {
satisfiedCondition = true;
} else if (Objects.nonNull(this.id)) {
satisfiedCondition = true;
} else if (Objects.nonNull(this.rooms)) {
satisfiedCondition = true;
} else if (Objects.nonNull(this.game)) {
} else if (Objects.nonNull(this.players)) {
satisfiedCondition = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ public ApiErrorDTO build() {
}
}


@Schema(name = "code", required = true)
public Integer getCode() {
return code;
}


@Schema(name = "message", required = true)
public String getMessage() {
return message;
Expand Down Expand Up @@ -98,7 +96,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,16 @@ public ApiTestDTO build() {
}
}


@Schema(name = "unionEnum", required = true)
public UnionEnum getUnionEnum() {
return unionEnum;
}


@Schema(name = "name", required = true)
public String getName() {
return name;
}


@Schema(name = "id", required = true)
public Integer getId() {
return id;
Expand All @@ -178,7 +175,6 @@ public void setUnionIntegerEnum(UnionIntegerEnum unionIntegerEnum) {
this.unionIntegerEnum = unionIntegerEnum;
}


@Schema(name = "unionNumberEnum", required = false)
public UnionNumberEnum getUnionNumberEnum() {
return unionNumberEnum;
Expand Down Expand Up @@ -217,7 +213,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public ApiTestInfoDTO build() {
}
}


@Schema(name = "testers", required = false)
public List<String> getTesters() {
return testers;
Expand All @@ -77,7 +76,6 @@ public void setTesters(List<String> testers) {
this.testers = testers;
}


@Schema(name = "testName", required = true)
public String getTestName() {
return testName;
Expand Down Expand Up @@ -110,7 +108,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public String toString() {
}
}


@Builder
@Jacksonized
private ApiTestDTO(UnionEnum unionEnum, @NonNull String name, @NonNull Integer id, UnionIntegerEnum unionIntegerEnum, UnionNumberEnum unionNumberEnum) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ public ApiErrorDTO build() {
}
}


@Schema(name = "code", required = true)
public Integer getCode() {
return code;
}


@Schema(name = "message", required = true)
public String getMessage() {
return message;
Expand Down Expand Up @@ -98,7 +96,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public ApiInlineParameterTestIdDTO build() {
}
}


@Schema(name = "email", required = false)
public String getEmail() {
return email;
Expand Down Expand Up @@ -78,7 +77,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ public ApiTestDTO build() {
}
}


@Schema(name = "name", required = true)
public String getName() {
return name;
}


@Schema(name = "id", required = true)
public Integer getId() {
return id;
Expand Down Expand Up @@ -98,7 +96,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public ApiTestInfoDTO build() {
}
}


@Schema(name = "testers", required = false)
public List<String> getTesters() {
return testers;
Expand All @@ -77,7 +76,6 @@ public void setTesters(List<String> testers) {
this.testers = testers;
}


@Schema(name = "testName", required = true)
public String getTestName() {
return testName;
Expand Down Expand Up @@ -110,7 +108,6 @@ public String toString() {
return sb.toString();
}


private String toIndentedString(Object o) {
if (o == null) {
return "null";
Expand Down
Loading

0 comments on commit f04e272

Please sign in to comment.