forked from loafle/openapi-generator-original
Fix alias to map in the model's properties (#360)
* add test case for ref to map (boolean) in fake petstore spec * fix alias to map in model properties * remove logging from new method * update samples for the new map test case * fix javadoc string * skip testSanitizeNestedInvalidValue in php test * skip test in php oas3 client * add logic to handle outer enum * update samples * fix alias in model's allOf * generate models for map def * update petstore samples * update petstore samples
This commit is contained in:
@@ -72,7 +72,7 @@ public interface FakeApi {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||
ApiUtil.setExampleResponse(request, "*/*", "{ }");
|
||||
ApiUtil.setExampleResponse(request, "*/*", "{ \"my_string\" : \"my_string\", \"my_number\" : 0.80082819046101150206595775671303272247314453125, \"my_boolean\" : true}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openapitools.model.StringBooleanMap;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@@ -56,6 +57,13 @@ public class MapTest {
|
||||
@Valid
|
||||
private Map<String, InnerEnum> mapOfEnumString = null;
|
||||
|
||||
@JsonProperty("direct_map")
|
||||
@Valid
|
||||
private Map<String, Boolean> directMap = null;
|
||||
|
||||
@JsonProperty("indirect_map")
|
||||
private StringBooleanMap indirectMap = null;
|
||||
|
||||
public MapTest mapMapOfString(Map<String, Map<String, String>> mapMapOfString) {
|
||||
this.mapMapOfString = mapMapOfString;
|
||||
return this;
|
||||
@@ -113,6 +121,55 @@ public class MapTest {
|
||||
this.mapOfEnumString = mapOfEnumString;
|
||||
}
|
||||
|
||||
public MapTest directMap(Map<String, Boolean> directMap) {
|
||||
this.directMap = directMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MapTest putDirectMapItem(String key, Boolean directMapItem) {
|
||||
if (this.directMap == null) {
|
||||
this.directMap = new HashMap<>();
|
||||
}
|
||||
this.directMap.put(key, directMapItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directMap
|
||||
* @return directMap
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
|
||||
public Map<String, Boolean> getDirectMap() {
|
||||
return directMap;
|
||||
}
|
||||
|
||||
public void setDirectMap(Map<String, Boolean> directMap) {
|
||||
this.directMap = directMap;
|
||||
}
|
||||
|
||||
public MapTest indirectMap(StringBooleanMap indirectMap) {
|
||||
this.indirectMap = indirectMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indirectMap
|
||||
* @return indirectMap
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
@Valid
|
||||
|
||||
public StringBooleanMap getIndirectMap() {
|
||||
return indirectMap;
|
||||
}
|
||||
|
||||
public void setIndirectMap(StringBooleanMap indirectMap) {
|
||||
this.indirectMap = indirectMap;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
@@ -124,12 +181,14 @@ public class MapTest {
|
||||
}
|
||||
MapTest mapTest = (MapTest) o;
|
||||
return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) &&
|
||||
Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString);
|
||||
Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString) &&
|
||||
Objects.equals(this.directMap, mapTest.directMap) &&
|
||||
Objects.equals(this.indirectMap, mapTest.indirectMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mapMapOfString, mapOfEnumString);
|
||||
return Objects.hash(mapMapOfString, mapOfEnumString, directMap, indirectMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,6 +198,8 @@ public class MapTest {
|
||||
|
||||
sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n");
|
||||
sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n");
|
||||
sb.append(" directMap: ").append(toIndentedString(directMap)).append("\n");
|
||||
sb.append(" indirectMap: ").append(toIndentedString(indirectMap)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class OuterComposite {
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
|
||||
public Boolean getMyBoolean() {
|
||||
public Boolean isMyBoolean() {
|
||||
return myBoolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* StringBooleanMap
|
||||
*/
|
||||
|
||||
public class StringBooleanMap extends HashMap<String, Boolean> {
|
||||
|
||||
@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 StringBooleanMap {\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 ");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user