use model class for request body with additionalProperties (#16613)

* try out simple fix

* add test case

* generate samples
This commit is contained in:
martin-mfg
2023-09-23 07:07:53 +02:00
committed by GitHub
parent f99002a974
commit 2ca99bdf8e
415 changed files with 20517 additions and 1 deletions

View File

@@ -87,4 +87,5 @@ src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
src/main/java/org/openapitools/client/model/SingleRefType.java
src/main/java/org/openapitools/client/model/SpecialModelName.java
src/main/java/org/openapitools/client/model/Tag.java
src/main/java/org/openapitools/client/model/TestInlineFreeformAdditionalPropertiesRequest.java
src/main/java/org/openapitools/client/model/User.java

View File

@@ -1031,6 +1031,25 @@ paths:
- fake
x-content-type: application/json
x-accepts: application/json
/fake/inline-freeform-additionalProperties:
post:
description: ""
operationId: testInlineFreeformAdditionalProperties
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/testInlineFreeformAdditionalProperties_request'
description: request body
required: true
responses:
"200":
description: successful operation
summary: test inline free-form additionalProperties
tags:
- fake
x-content-type: application/json
x-accepts: application/json
/fake/nullable:
post:
description: ""
@@ -2191,6 +2210,12 @@ components:
- param
- param2
type: object
testInlineFreeformAdditionalProperties_request:
additionalProperties: true
properties:
someProperty:
type: string
type: object
uploadFileWithRequiredFile_request:
properties:
additionalMetadata:

View File

@@ -17,6 +17,7 @@ import java.time.OffsetDateTime;
import org.openapitools.client.model.OuterComposite;
import org.openapitools.client.model.OuterObjectWithEnumProperty;
import org.openapitools.client.model.Pet;
import org.openapitools.client.model.TestInlineFreeformAdditionalPropertiesRequest;
import org.openapitools.client.model.User;
import java.util.ArrayList;
@@ -811,6 +812,33 @@ public interface FakeApi extends ApiClient.Api {
/**
* test inline free-form additionalProperties
*
* @param testInlineFreeformAdditionalPropertiesRequest request body (required)
*/
@RequestLine("POST /fake/inline-freeform-additionalProperties")
@Headers({
"Content-Type: application/json",
"Accept: application/json",
})
void testInlineFreeformAdditionalProperties(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest);
/**
* test inline free-form additionalProperties
* Similar to <code>testInlineFreeformAdditionalProperties</code> but it also returns the http response headers .
*
* @param testInlineFreeformAdditionalPropertiesRequest request body (required)
*/
@RequestLine("POST /fake/inline-freeform-additionalProperties")
@Headers({
"Content-Type: application/json",
"Accept: application/json",
})
ApiResponse<Void> testInlineFreeformAdditionalPropertiesWithHttpInfo(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest);
/**
* test json serialization of form data
*

View File

@@ -0,0 +1,157 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* 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.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
/**
* TestInlineFreeformAdditionalPropertiesRequest
*/
@JsonPropertyOrder({
TestInlineFreeformAdditionalPropertiesRequest.JSON_PROPERTY_SOME_PROPERTY
})
@JsonTypeName("testInlineFreeformAdditionalProperties_request")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class TestInlineFreeformAdditionalPropertiesRequest extends HashMap<String, Object> {
public static final String JSON_PROPERTY_SOME_PROPERTY = "someProperty";
private String someProperty;
public TestInlineFreeformAdditionalPropertiesRequest() {
}
public TestInlineFreeformAdditionalPropertiesRequest someProperty(String someProperty) {
this.someProperty = someProperty;
return this;
}
/**
* Get someProperty
* @return someProperty
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SOME_PROPERTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getSomeProperty() {
return someProperty;
}
@JsonProperty(JSON_PROPERTY_SOME_PROPERTY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSomeProperty(String someProperty) {
this.someProperty = someProperty;
}
/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
private Map<String, Object> additionalProperties;
/**
* Set the additional (undeclared) property with the specified name and value.
* If the property does not already exist, create it otherwise replace it.
* @param key the name of the property
* @param value the value of the property
* @return self reference
*/
@JsonAnySetter
public TestInlineFreeformAdditionalPropertiesRequest putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap<String, Object>();
}
this.additionalProperties.put(key, value);
return this;
}
/**
* Return the additional (undeclared) properties.
* @return the additional (undeclared) properties
*/
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}
/**
* Return the additional (undeclared) property with the specified name.
* @param key the name of the property
* @return the additional (undeclared) property with the specified name
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
return null;
}
return this.additionalProperties.get(key);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest = (TestInlineFreeformAdditionalPropertiesRequest) o;
return Objects.equals(this.someProperty, testInlineFreeformAdditionalPropertiesRequest.someProperty) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(someProperty, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TestInlineFreeformAdditionalPropertiesRequest {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" someProperty: ").append(toIndentedString(someProperty)).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,47 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* 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.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
/**
* Model tests for TestInlineFreeformAdditionalPropertiesRequest
*/
class TestInlineFreeformAdditionalPropertiesRequestTest {
private final TestInlineFreeformAdditionalPropertiesRequest model = new TestInlineFreeformAdditionalPropertiesRequest();
/**
* Model tests for TestInlineFreeformAdditionalPropertiesRequest
*/
@Test
void testTestInlineFreeformAdditionalPropertiesRequest() {
// TODO: test TestInlineFreeformAdditionalPropertiesRequest
}
/**
* Test the property 'someProperty'
*/
@Test
void somePropertyTest() {
// TODO: test someProperty
}
}