Add group parameter support to PHP client (#1337)

* add group parameter support to php template

* more update for group parameter

* fix call to protect function

* fix missing $

* update based on feedback

* create fake endpoint to test group parameters

* sync fake petstore spec v2, v3

* fix php doc for group parameters

* update petstore samples

* update fake petstore spec v2

* update petstore samples

* fix spec and update samples
This commit is contained in:
William Cheng
2018-10-29 15:42:32 +08:00
committed by GitHub
parent d80f3a6197
commit aced89ff8b
121 changed files with 3963 additions and 36 deletions

View File

@@ -149,6 +149,16 @@ public class FakeApi {
return new TestEnumParametersOper(reqSpec);
}
@ApiOperation(value = "Fake endpoint to test group parameters (optional)",
notes = "Fake endpoint to test group parameters (optional)",
nickname = "testGroupParameters",
tags = { "fake" })
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Someting wrong") })
public TestGroupParametersOper testGroupParameters() {
return new TestGroupParametersOper(reqSpec);
}
@ApiOperation(value = "test inline additionalProperties",
notes = "",
nickname = "testInlineAdditionalProperties",
@@ -1030,6 +1040,91 @@ public class FakeApi {
return this;
}
}
/**
* Fake endpoint to test group parameters (optional)
* Fake endpoint to test group parameters (optional)
*
* @see #stringGroupQuery String in group parameters (optional)
* @see #booleanGroupHeader Boolean in group parameters (optional)
* @see #int64GroupQuery Integer in group parameters (optional)
*/
public static class TestGroupParametersOper {
public static final Method REQ_METHOD = DELETE;
public static final String REQ_URI = "/fake";
private RequestSpecBuilder reqSpec;
private ResponseSpecBuilder respSpec;
public TestGroupParametersOper(RequestSpecBuilder reqSpec) {
this.reqSpec = reqSpec;
reqSpec.setAccept("application/json");
this.respSpec = new ResponseSpecBuilder();
}
/**
* DELETE /fake
* @param handler handler
* @param <T> type
* @return type
*/
public <T> T execute(Function<Response, T> handler) {
return handler.apply(RestAssured.given().spec(reqSpec.build()).expect().spec(respSpec.build()).when().request(REQ_METHOD, REQ_URI));
}
public static final String BOOLEAN_GROUP_HEADER = "boolean_group";
/**
* @param booleanGroup (Boolean) Boolean in group parameters (optional)
* @return operation
*/
public TestGroupParametersOper booleanGroupHeader(String booleanGroup) {
reqSpec.addHeader(BOOLEAN_GROUP_HEADER, booleanGroup);
return this;
}
public static final String STRING_GROUP_QUERY = "string_group";
/**
* @param stringGroup (Integer) String in group parameters (optional)
* @return operation
*/
public TestGroupParametersOper stringGroupQuery(Object... stringGroup) {
reqSpec.addQueryParam(STRING_GROUP_QUERY, stringGroup);
return this;
}
public static final String INT64_GROUP_QUERY = "int64_group";
/**
* @param int64Group (Long) Integer in group parameters (optional)
* @return operation
*/
public TestGroupParametersOper int64GroupQuery(Object... int64Group) {
reqSpec.addQueryParam(INT64_GROUP_QUERY, int64Group);
return this;
}
/**
* Customise request specification
* @param consumer consumer
* @return operation
*/
public TestGroupParametersOper reqSpec(Consumer<RequestSpecBuilder> consumer) {
consumer.accept(reqSpec);
return this;
}
/**
* Customise response specification
* @param consumer consumer
* @return operation
*/
public TestGroupParametersOper respSpec(Consumer<ResponseSpecBuilder> consumer) {
consumer.accept(respSpec);
return this;
}
}
/**
* test inline additionalProperties
*

View File

@@ -16,6 +16,7 @@ package org.openapitools.client.api;
import java.math.BigDecimal;
import org.openapitools.client.model.Client;
import java.io.File;
import org.openapitools.client.model.FileSchemaTestClass;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.openapitools.client.model.OuterComposite;
@@ -96,6 +97,18 @@ public class FakeApiTest {
}
/**
* Success
*/
@Test
public void shouldSee200AfterTestBodyWithFileSchema() {
FileSchemaTestClass fileSchemaTestClass = null;
api.testBodyWithFileSchema()
.body(fileSchemaTestClass).execute(r -> r.prettyPeek());
// TODO: test validations
}
/**
* Success
*/
@@ -212,6 +225,19 @@ public class FakeApiTest {
}
/**
* Someting wrong
*/
@Test
public void shouldSee400AfterTestGroupParameters() {
Integer stringGroup = null;
String booleanGroup = null;
Long int64Group = null;
api.testGroupParameters().execute(r -> r.prettyPeek());
// TODO: test validations
}
/**
* successful operation
*/