[Java][native][apache-httpclient] Update toUrlQueryString to support form style for object (#14478)

* update toUrlQueryString

* add new files

* minor bug fixes

* support object in query parameter - java apache httpclient

* rename variable - java native

* update samples

* fix try catch
This commit is contained in:
William Cheng
2023-01-19 16:13:51 +08:00
committed by GitHub
parent d1cde7febe
commit 6cd7989e9e
228 changed files with 8867 additions and 688 deletions

View File

@@ -28,7 +28,10 @@ src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
src/main/java/org/openapitools/client/model/ApiResponse.java
src/main/java/org/openapitools/client/model/Bird.java
src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/Tag.java
src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java

View File

@@ -124,6 +124,29 @@ paths:
tags:
- query
x-accepts: text/plain
/query/style_form/explode_true/object/allOf:
get:
description: Test query parameter(s)
operationId: test/query/style_form/explode_true/object/allOf
parameters:
- explode: true
in: query
name: query_object
required: false
schema:
$ref: '#/components/schemas/DataQuery'
style: form
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test query parameter(s)
tags:
- query
x-accepts: text/plain
/query/style_deepObject/explode_true/object:
get:
description: Test query parameter(s)
@@ -285,6 +308,29 @@ components:
color:
type: string
type: object
Query:
properties:
id:
description: Query
format: int64
type: integer
outcomes:
default:
- SUCCESS
- FAILURE
items:
enum:
- SUCCESS
- FAILURE
- SKIPPED
type: string
type: array
type: object
x-parent: true
DataQuery:
allOf:
- $ref: '#/components/schemas/DataQuery_allOf'
- $ref: '#/components/schemas/Query'
test_query_style_form_explode_true_array_string_query_object_parameter:
properties:
values:
@@ -296,4 +342,19 @@ components:
allOf:
- $ref: '#/components/schemas/Bird'
- $ref: '#/components/schemas/Category'
DataQuery_allOf:
properties:
suffix:
description: test suffix
type: string
text:
description: Some text containing white spaces
example: Some text
type: string
date:
description: A date
format: date-time
type: string
type: object
example: null

View File

@@ -4,6 +4,7 @@ import org.openapitools.client.ApiClient;
import org.openapitools.client.EncodingUtils;
import org.openapitools.client.model.ApiResponse;
import org.openapitools.client.model.DataQuery;
import org.openapitools.client.model.Pet;
import org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter;
import org.openapitools.client.model.TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter;
@@ -418,4 +419,81 @@ public interface QueryApi extends ApiClient.Api {
return this;
}
}
/**
* Test query parameter(s)
* Test query parameter(s)
* @param queryObject (optional)
* @return String
*/
@RequestLine("GET /query/style_form/explode_true/object/allOf?query_object={queryObject}")
@Headers({
"Accept: text/plain",
})
String testQueryStyleFormExplodeTrueObjectAllOf(@Param("queryObject") DataQuery queryObject);
/**
* Test query parameter(s)
* Similar to <code>testQueryStyleFormExplodeTrueObjectAllOf</code> but it also returns the http response headers .
* Test query parameter(s)
* @param queryObject (optional)
* @return A ApiResponse that wraps the response boyd and the http headers.
*/
@RequestLine("GET /query/style_form/explode_true/object/allOf?query_object={queryObject}")
@Headers({
"Accept: text/plain",
})
ApiResponse<String> testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(@Param("queryObject") DataQuery queryObject);
/**
* Test query parameter(s)
* Test query parameter(s)
* Note, this is equivalent to the other <code>testQueryStyleFormExplodeTrueObjectAllOf</code> method,
* but with the query parameters collected into a single Map parameter. This
* is convenient for services with optional query parameters, especially when
* used with the {@link TestQueryStyleFormExplodeTrueObjectAllOfQueryParams} class that allows for
* building up this map in a fluent style.
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p>
* <ul>
* <li>queryObject - (optional)</li>
* </ul>
* @return String
*/
@RequestLine("GET /query/style_form/explode_true/object/allOf?query_object={queryObject}")
@Headers({
"Accept: text/plain",
})
String testQueryStyleFormExplodeTrueObjectAllOf(@QueryMap(encoded=true) TestQueryStyleFormExplodeTrueObjectAllOfQueryParams queryParams);
/**
* Test query parameter(s)
* Test query parameter(s)
* Note, this is equivalent to the other <code>testQueryStyleFormExplodeTrueObjectAllOf</code> that receives the query parameters as a map,
* but this one also exposes the Http response headers
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p>
* <ul>
* <li>queryObject - (optional)</li>
* </ul>
* @return String
*/
@RequestLine("GET /query/style_form/explode_true/object/allOf?query_object={queryObject}")
@Headers({
"Accept: text/plain",
})
ApiResponse<String> testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(@QueryMap(encoded=true) TestQueryStyleFormExplodeTrueObjectAllOfQueryParams queryParams);
/**
* A convenience class for generating query parameters for the
* <code>testQueryStyleFormExplodeTrueObjectAllOf</code> method in a fluent style.
*/
public static class TestQueryStyleFormExplodeTrueObjectAllOfQueryParams extends HashMap<String, Object> {
public TestQueryStyleFormExplodeTrueObjectAllOfQueryParams queryObject(final DataQuery value) {
put("query_object", EncodingUtils.encode(value));
return this;
}
}
}

View File

@@ -0,0 +1,160 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
import org.openapitools.client.model.Query;
/**
* DataQuery
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class DataQuery extends Query {
public static final String SERIALIZED_NAME_SUFFIX = "suffix";
@SerializedName(SERIALIZED_NAME_SUFFIX)
private String suffix;
public static final String SERIALIZED_NAME_TEXT = "text";
@SerializedName(SERIALIZED_NAME_TEXT)
private String text;
public static final String SERIALIZED_NAME_DATE = "date";
@SerializedName(SERIALIZED_NAME_DATE)
private OffsetDateTime date;
public DataQuery() {
}
public DataQuery suffix(String suffix) {
this.suffix = suffix;
return this;
}
/**
* test suffix
* @return suffix
**/
@javax.annotation.Nullable
public String getSuffix() {
return suffix;
}
public void setSuffix(String suffix) {
this.suffix = suffix;
}
public DataQuery text(String text) {
this.text = text;
return this;
}
/**
* Some text containing white spaces
* @return text
**/
@javax.annotation.Nullable
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public DataQuery date(OffsetDateTime date) {
this.date = date;
return this;
}
/**
* A date
* @return date
**/
@javax.annotation.Nullable
public OffsetDateTime getDate() {
return date;
}
public void setDate(OffsetDateTime date) {
this.date = date;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DataQuery dataQuery = (DataQuery) o;
return Objects.equals(this.suffix, dataQuery.suffix) &&
Objects.equals(this.text, dataQuery.text) &&
Objects.equals(this.date, dataQuery.date) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(suffix, text, date, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DataQuery {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n");
sb.append(" text: ").append(toIndentedString(text)).append("\n");
sb.append(" date: ").append(toIndentedString(date)).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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@@ -0,0 +1,154 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
/**
* DataQueryAllOf
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class DataQueryAllOf {
public static final String SERIALIZED_NAME_SUFFIX = "suffix";
@SerializedName(SERIALIZED_NAME_SUFFIX)
private String suffix;
public static final String SERIALIZED_NAME_TEXT = "text";
@SerializedName(SERIALIZED_NAME_TEXT)
private String text;
public static final String SERIALIZED_NAME_DATE = "date";
@SerializedName(SERIALIZED_NAME_DATE)
private OffsetDateTime date;
public DataQueryAllOf() {
}
public DataQueryAllOf suffix(String suffix) {
this.suffix = suffix;
return this;
}
/**
* test suffix
* @return suffix
**/
@javax.annotation.Nullable
public String getSuffix() {
return suffix;
}
public void setSuffix(String suffix) {
this.suffix = suffix;
}
public DataQueryAllOf text(String text) {
this.text = text;
return this;
}
/**
* Some text containing white spaces
* @return text
**/
@javax.annotation.Nullable
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public DataQueryAllOf date(OffsetDateTime date) {
this.date = date;
return this;
}
/**
* A date
* @return date
**/
@javax.annotation.Nullable
public OffsetDateTime getDate() {
return date;
}
public void setDate(OffsetDateTime date) {
this.date = date;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DataQueryAllOf dataQueryAllOf = (DataQueryAllOf) o;
return Objects.equals(this.suffix, dataQueryAllOf.suffix) &&
Objects.equals(this.text, dataQueryAllOf.text) &&
Objects.equals(this.date, dataQueryAllOf.date);
}
@Override
public int hashCode() {
return Objects.hash(suffix, text, date);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DataQueryAllOf {\n");
sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n");
sb.append(" text: ").append(toIndentedString(text)).append("\n");
sb.append(" date: ").append(toIndentedString(date)).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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@@ -0,0 +1,184 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Query
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class Query {
public static final String SERIALIZED_NAME_ID = "id";
@SerializedName(SERIALIZED_NAME_ID)
private Long id;
/**
* Gets or Sets outcomes
*/
@JsonAdapter(OutcomesEnum.Adapter.class)
public enum OutcomesEnum {
SUCCESS("SUCCESS"),
FAILURE("FAILURE"),
SKIPPED("SKIPPED");
private String value;
OutcomesEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static OutcomesEnum fromValue(String value) {
for (OutcomesEnum b : OutcomesEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter<OutcomesEnum> {
@Override
public void write(final JsonWriter jsonWriter, final OutcomesEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public OutcomesEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return OutcomesEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_OUTCOMES = "outcomes";
@SerializedName(SERIALIZED_NAME_OUTCOMES)
private List<OutcomesEnum> outcomes = null;
public Query() {
}
public Query id(Long id) {
this.id = id;
return this;
}
/**
* Query
* @return id
**/
@javax.annotation.Nullable
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Query outcomes(List<OutcomesEnum> outcomes) {
this.outcomes = outcomes;
return this;
}
public Query addOutcomesItem(OutcomesEnum outcomesItem) {
if (this.outcomes == null) {
this.outcomes = new ArrayList<>();
}
this.outcomes.add(outcomesItem);
return this;
}
/**
* Get outcomes
* @return outcomes
**/
@javax.annotation.Nullable
public List<OutcomesEnum> getOutcomes() {
return outcomes;
}
public void setOutcomes(List<OutcomesEnum> outcomes) {
this.outcomes = outcomes;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Query query = (Query) o;
return Objects.equals(this.id, query.id) &&
Objects.equals(this.outcomes, query.outcomes);
}
@Override
public int hashCode() {
return Objects.hash(id, outcomes);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Query {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" outcomes: ").append(toIndentedString(outcomes)).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(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@@ -0,0 +1,56 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Test;
/**
* Model tests for DataQueryAllOf
*/
class DataQueryAllOfTest {
private final DataQueryAllOf model = new DataQueryAllOf();
/**
* Model tests for DataQueryAllOf
*/
@Test
void testDataQueryAllOf() {
// TODO: test DataQueryAllOf
}
/**
* Test the property 'text'
*/
@Test
void textTest() {
// TODO: test text
}
/**
* Test the property 'date'
*/
@Test
void dateTest() {
// TODO: test date
}
}

View File

@@ -0,0 +1,75 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
import org.openapitools.client.model.Query;
import org.junit.jupiter.api.Test;
/**
* Model tests for DataQuery
*/
class DataQueryTest {
private final DataQuery model = new DataQuery();
/**
* Model tests for DataQuery
*/
@Test
void testDataQuery() {
// TODO: test DataQuery
}
/**
* Test the property 'text'
*/
@Test
void textTest() {
// TODO: test text
}
/**
* Test the property 'date'
*/
@Test
void dateTest() {
// TODO: test date
}
/**
* Test the property 'id'
*/
@Test
void idTest() {
// TODO: test id
}
/**
* Test the property 'outcomes'
*/
@Test
void outcomesTest() {
// TODO: test outcomes
}
}

View File

@@ -0,0 +1,57 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;
/**
* Model tests for Query
*/
class QueryTest {
private final Query model = new Query();
/**
* Model tests for Query
*/
@Test
void testQuery() {
// TODO: test Query
}
/**
* Test the property 'id'
*/
@Test
void idTest() {
// TODO: test id
}
/**
* Test the property 'outcomes'
*/
@Test
void outcomesTest() {
// TODO: test outcomes
}
}