Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Generate samples
  • Loading branch information
Artem Shubovych committed Jan 5, 2020
commit e41bf0d82cd81bae0103184559c3fff5a1c6eda6
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.nio.file.Path;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.stream.Collectors;

public class DefaultGenerator extends AbstractGenerator implements Generator {
protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0-SNAPSHOT
4.3.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ public interface AnotherFakeApi {
@ApiOperation(value = "To test special tags", notes = "To test special tags and operation ID starting with number", tags={ "$another-fake?" })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
Response call123testSpecialTags(@Valid Client client);
Response call123testSpecialTags(@Valid Client body);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.openapitools.model.ModelApiResponse;
import org.openapitools.model.OuterComposite;
import org.openapitools.model.User;
import org.openapitools.model.XmlItem;

import javax.ws.rs.*;
import javax.ws.rs.core.Response;
Expand All @@ -26,6 +27,14 @@
@Api(description = "the fake API")
public interface FakeApi {

@POST
@Path("/create_xml_item")
@Consumes({ "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" })
@ApiOperation(value = "creates an XmlItem", notes = "this route creates an XmlItem", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
Response createXmlItem(@Valid XmlItem xmlItem);

@POST
@Path("/outer/boolean")
@Produces({ "*/*" })
Expand All @@ -40,7 +49,7 @@ public interface FakeApi {
@ApiOperation(value = "", notes = "Test serialization of object with outer number type", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) })
Response fakeOuterCompositeSerialize(@Valid OuterComposite outerComposite);
Response fakeOuterCompositeSerialize(@Valid OuterComposite body);

@POST
@Path("/outer/number")
Expand All @@ -64,23 +73,23 @@ public interface FakeApi {
@ApiOperation(value = "", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = Void.class) })
Response testBodyWithFileSchema(@Valid FileSchemaTestClass fileSchemaTestClass);
Response testBodyWithFileSchema(@Valid FileSchemaTestClass body);

@PUT
@Path("/body-with-query-params")
@Consumes({ "application/json" })
@ApiOperation(value = "", notes = "", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = Void.class) })
Response testBodyWithQueryParams(@QueryParam("query") @NotNull String query,@Valid User user);
Response testBodyWithQueryParams(@QueryParam("query") @NotNull String query,@Valid User body);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the body parameter name changes from user to body. Likely you're not using the latest (or recent) master when creating this PR.

Please merge the latest master of the official repo into your branch and regenerate the sample again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used 4.3.x as the origin of my branch, are you sure I should merge master in?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Please put it on hold. I'll take another look over the weekend or next week.


@PATCH
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "To test \"client\" model", notes = "To test \"client\" model", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
Response testClientModel(@Valid Client client);
Response testClientModel(@Valid Client body);

@POST
@Consumes({ "application/x-www-form-urlencoded" })
Expand All @@ -98,15 +107,21 @@ public interface FakeApi {
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid request", response = Void.class),
@ApiResponse(code = 404, message = "Not found", response = Void.class) })
Response testEnumParameters(@HeaderParam("enum_header_string_array") @DefaultValue("new ArrayList<String>()") @ApiParam("Header parameter enum test (string array)") List<String> enumHeaderStringArray,@HeaderParam("enum_header_string") @DefaultValue("-efg") @ApiParam("Header parameter enum test (string)") String enumHeaderString,@QueryParam("enum_query_string_array") @DefaultValue("new ArrayList<String>()") @ApiParam("Query parameter enum test (string array)") List<String> enumQueryStringArray,@QueryParam("enum_query_string") @DefaultValue("-efg") @ApiParam("Query parameter enum test (string)") String enumQueryString,@QueryParam("enum_query_integer") @ApiParam("Query parameter enum test (double)") Integer enumQueryInteger,@QueryParam("enum_query_double") @ApiParam("Query parameter enum test (double)") Double enumQueryDouble,@FormParam(value = "enum_form_string_array") List<String> enumFormStringArray,@FormParam(value = "enum_form_string") String enumFormString);
Response testEnumParameters(@HeaderParam("enum_header_string_array") @DefaultValue("new ArrayList<String>()") @ApiParam("Header parameter enum test (string array)") List<String> enumHeaderStringArray,@HeaderParam("enum_header_string") @DefaultValue("-efg") @ApiParam("Header parameter enum test (string)") String enumHeaderString,@QueryParam("enum_query_string_array") @ApiParam("Query parameter enum test (string array)") List<String> enumQueryStringArray,@QueryParam("enum_query_string") @DefaultValue("-efg") @ApiParam("Query parameter enum test (string)") String enumQueryString,@QueryParam("enum_query_integer") @ApiParam("Query parameter enum test (double)") Integer enumQueryInteger,@QueryParam("enum_query_double") @ApiParam("Query parameter enum test (double)") Double enumQueryDouble,@FormParam(value = "enum_form_string_array") List<String> enumFormStringArray,@FormParam(value = "enum_form_string") String enumFormString);

@DELETE
@ApiOperation(value = "Fake endpoint to test group parameters (optional)", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Someting wrong", response = Void.class) })
Response testGroupParameters(@QueryParam("required_string_group") @NotNull @ApiParam("Required String in group parameters") Integer requiredStringGroup,@HeaderParam("required_boolean_group") @NotNull @ApiParam("Required Boolean in group parameters") Boolean requiredBooleanGroup,@QueryParam("required_int64_group") @NotNull @ApiParam("Required Integer in group parameters") Long requiredInt64Group,@QueryParam("string_group") @ApiParam("String in group parameters") Integer stringGroup,@HeaderParam("boolean_group") @ApiParam("Boolean in group parameters") Boolean booleanGroup,@QueryParam("int64_group") @ApiParam("Integer in group parameters") Long int64Group);

@POST
@Path("/inline-additionalProperties")
@Consumes({ "application/json" })
@ApiOperation(value = "test inline additionalProperties", notes = "", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
Response testInlineAdditionalProperties(@Valid Map<String, String> requestBody);
Response testInlineAdditionalProperties(@Valid Map<String, String> param);

@GET
@Path("/jsonFormData")
Expand All @@ -116,6 +131,13 @@ public interface FakeApi {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
Response testJsonFormData(@FormParam(value = "param") String param,@FormParam(value = "param2") String param2);

@PUT
@Path("/test-query-paramters")
@ApiOperation(value = "", notes = "To test the collection format in query parameters", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = Void.class) })
Response testQueryParameterCollectionFormat(@QueryParam("pipe") @NotNull List<String> pipe,@QueryParam("ioutil") @NotNull List<String> ioutil,@QueryParam("http") @NotNull List<String> http,@QueryParam("url") @NotNull List<String> url,@QueryParam("context") @NotNull List<String> context);

@POST
@Path("/{petId}/uploadImageWithRequiredFile")
@Consumes({ "multipart/form-data" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ public interface FakeClassnameTestApi {
}, tags={ "fake_classname_tags 123#$%^" })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
Response testClassname(@Valid Client client);
Response testClassname(@Valid Client body);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ public interface PetApi {
})
}, tags={ "pet", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class),
@ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
Response addPet(@Valid Pet pet);
Response addPet(@Valid Pet body);

@DELETE
@Path("/{petId}")
Expand All @@ -40,8 +41,9 @@ public interface PetApi {
})
}, tags={ "pet", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class),
@ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) })
Response deletePet(@PathParam("petId") @ApiParam("Pet id to delete") Long petId,@HeaderParam("api_key") String apiKey);
Response deletePet(@PathParam("petId") @ApiParam("Pet id to delete") Long petId,@HeaderParam("api_key") String apiKey);

@GET
@Path("/findByStatus")
Expand All @@ -55,7 +57,7 @@ public interface PetApi {
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid status value", response = Void.class, responseContainer = "List") })
Response findPetsByStatus(@QueryParam("status") @NotNull @DefaultValue("new ArrayList<String>()") @ApiParam("Status values that need to be considered for filter") List<String> status);
Response findPetsByStatus(@QueryParam("status") @NotNull @ApiParam("Status values that need to be considered for filter") List<String> status);

@GET
@Path("/findByTags")
Expand All @@ -69,7 +71,7 @@ public interface PetApi {
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid tag value", response = Void.class, responseContainer = "List") })
Response findPetsByTags(@QueryParam("tags") @NotNull @DefaultValue("new ArrayList<String>()") @ApiParam("Tags to filter by") List<String> tags);
Response findPetsByTags(@QueryParam("tags") @NotNull @ApiParam("Tags to filter by") List<String> tags);

@GET
@Path("/{petId}")
Expand All @@ -92,10 +94,11 @@ public interface PetApi {
})
}, tags={ "pet", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class),
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@ApiResponse(code = 404, message = "Pet not found", response = Void.class),
@ApiResponse(code = 405, message = "Validation exception", response = Void.class) })
Response updatePet(@Valid Pet pet);
Response updatePet(@Valid Pet body);

@POST
@Path("/{petId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ public interface StoreApi {
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid Order", response = Void.class) })
Response placeOrder(@Valid Order order);
Response placeOrder(@Valid Order body);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ public interface UserApi {
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
Response createUser(@Valid User user);
Response createUser(@Valid User body);

@POST
@Path("/createWithArray")
@ApiOperation(value = "Creates list of users with given input array", notes = "", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
Response createUsersWithArrayInput(@Valid List<User> user);
Response createUsersWithArrayInput(@Valid List<User> body);

@POST
@Path("/createWithList")
@ApiOperation(value = "Creates list of users with given input array", notes = "", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
Response createUsersWithListInput(@Valid List<User> user);
Response createUsersWithListInput(@Valid List<User> body);

@DELETE
@Path("/{username}")
Expand Down Expand Up @@ -78,5 +78,5 @@ public interface UserApi {
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class),
@ApiResponse(code = 404, message = "User not found", response = Void.class) })
Response updateUser(@PathParam("username") @ApiParam("name that need to be deleted") String username,@Valid User user);
Response updateUser(@PathParam("username") @ApiParam("name that need to be deleted") String username,@Valid User body);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package org.openapitools.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.HashMap;
import java.util.Map;
import java.io.Serializable;
import javax.validation.constraints.*;
import javax.validation.Valid;

import io.swagger.annotations.*;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;



public class AdditionalPropertiesAnyType extends HashMap<String, Object> implements Serializable {

private @Valid String name;

public AdditionalPropertiesAnyType(String name) {
this.name = name;
}


@ApiModelProperty(value = "")
@JsonProperty("name")
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o;
return Objects.equals(this.name, additionalPropertiesAnyType.name) &&
super.equals(o);
}

@Override
public int hashCode() {
return Objects.hash(name, super.hashCode());
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class AdditionalPropertiesAnyType {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" name: ").append(toIndentedString(name)).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 static Builder builder() {
return new Builder();
}

public static class Builder {
private String name;

/**
**/
public Builder name(String name) {
this.name = name;
return this;
}

public AdditionalPropertiesAnyType build() {
return new AdditionalPropertiesAnyType(name);
}
}
}

Loading