diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/typescript/templates/client/models/models.ejs b/packages/type-safe-api/scripts/type-safe-api/generators/typescript/templates/client/models/models.ejs index 78d5c434e..a28a68295 100644 --- a/packages/type-safe-api/scripts/type-safe-api/generators/typescript/templates/client/models/models.ejs +++ b/packages/type-safe-api/scripts/type-safe-api/generators/typescript/templates/client/models/models.ejs @@ -62,8 +62,8 @@ export type <%- model.name %> =<% model.properties.forEach((composedType, i) => <%_ } _%> */ export interface <%= model.name %> { -<%_ if (model.additionalProperties) { _%> - [key: string]: <%- model.additionalProperties.typescriptType %>; +<%_ if (model.export === "dictionary" && model.link) { _%> + [key: string]: <%- model.link.typescriptType %>; <%_ } _%> <%_ model.properties.forEach((property) => { _%> /** @@ -126,7 +126,7 @@ export function <%= model.name %>FromJSONTyped(json: any, ignoreDiscriminator: b <%_ } else { _%> return { -<%_ if (model.additionalProperties) { _%> +<%_ if (model.export === "dictionary") { _%> ...json, <%_ } _%> <%_ model.properties.forEach((property) => { _%> @@ -173,7 +173,7 @@ export function <%= model.name %>ToJSON(value?: <%= model.name %> | null): any { <%_ } else { _%> return { -<%_ if (model.additionalProperties) { _%> +<%_ if (model.export === "dictionary") { _%> ...value, <%_ } _%> <%_ model.properties.forEach((property) => { _%> diff --git a/packages/type-safe-api/test/resources/specs/edge-cases.yaml b/packages/type-safe-api/test/resources/specs/edge-cases.yaml index 31aa20015..cf100a7a6 100644 --- a/packages/type-safe-api/test/resources/specs/edge-cases.yaml +++ b/packages/type-safe-api/test/resources/specs/edge-cases.yaml @@ -138,6 +138,16 @@ paths: application/json: schema: $ref: "#/components/schemas/ArrayOfOneOfs" + /additional-properties: + post: + operationId: dictionary + responses: + 200: + description: ok + content: + application/json: + schema: + $ref: "#/components/schemas/AdditionalPropertiesResponse" components: schemas: MyEnum: @@ -165,3 +175,23 @@ components: type: array items: $ref: "#/components/schemas/NamedOneOfUnion" + AdditionalPropertiesResponse: + type: object + properties: + dictionaryOfObjects: + $ref: "#/components/schemas/Dictionary" + dictionaryOfPrimitives: + type: object + additionalProperties: + type: string + Dictionary: + type: object + additionalProperties: + type: array + items: + $ref: "#/components/schemas/SomeObject" + SomeObject: + type: object + properties: + a: + type: string diff --git a/packages/type-safe-api/test/scripts/generators/__snapshots__/java.test.ts.snap b/packages/type-safe-api/test/scripts/generators/__snapshots__/java.test.ts.snap index 9b11037d2..9cdcbc318 100644 --- a/packages/type-safe-api/test/scripts/generators/__snapshots__/java.test.ts.snap +++ b/packages/type-safe-api/test/scripts/generators/__snapshots__/java.test.ts.snap @@ -30335,36 +30335,42 @@ src/main/java/test/test/runtime/api/handlers/InterceptorWarmupChainedRequestInpu src/main/java/test/test/runtime/api/handlers/InterceptorWithWarmup.java src/main/java/test/test/runtime/api/handlers/array_of_one_ofs/ArrayOfOneOfsResponse.java src/main/java/test/test/runtime/api/handlers/array_request_parameters/ArrayRequestParametersResponse.java +src/main/java/test/test/runtime/api/handlers/dictionary/DictionaryResponse.java src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumResponse.java src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyResponse.java src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfResponse.java src/main/java/test/test/runtime/api/handlers/reserved_keywords/ReservedKeywordsResponse.java src/main/java/test/test/runtime/api/handlers/array_of_one_ofs/ArrayOfOneOfs200Response.java src/main/java/test/test/runtime/api/handlers/array_request_parameters/ArrayRequestParameters200Response.java +src/main/java/test/test/runtime/api/handlers/dictionary/Dictionary200Response.java src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnum200Response.java src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBody204Response.java src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOf200Response.java src/main/java/test/test/runtime/api/handlers/reserved_keywords/ReservedKeywords200Response.java src/main/java/test/test/runtime/api/handlers/array_of_one_ofs/ArrayOfOneOfsRequestParameters.java src/main/java/test/test/runtime/api/handlers/array_request_parameters/ArrayRequestParametersRequestParameters.java +src/main/java/test/test/runtime/api/handlers/dictionary/DictionaryRequestParameters.java src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumRequestParameters.java src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyRequestParameters.java src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfRequestParameters.java src/main/java/test/test/runtime/api/handlers/reserved_keywords/ReservedKeywordsRequestParameters.java src/main/java/test/test/runtime/api/handlers/array_of_one_ofs/ArrayOfOneOfsInput.java src/main/java/test/test/runtime/api/handlers/array_request_parameters/ArrayRequestParametersInput.java +src/main/java/test/test/runtime/api/handlers/dictionary/DictionaryInput.java src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumInput.java src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyInput.java src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfInput.java src/main/java/test/test/runtime/api/handlers/reserved_keywords/ReservedKeywordsInput.java src/main/java/test/test/runtime/api/handlers/array_of_one_ofs/ArrayOfOneOfsRequestInput.java src/main/java/test/test/runtime/api/handlers/array_request_parameters/ArrayRequestParametersRequestInput.java +src/main/java/test/test/runtime/api/handlers/dictionary/DictionaryRequestInput.java src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumRequestInput.java src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyRequestInput.java src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfRequestInput.java src/main/java/test/test/runtime/api/handlers/reserved_keywords/ReservedKeywordsRequestInput.java src/main/java/test/test/runtime/api/handlers/array_of_one_ofs/ArrayOfOneOfs.java src/main/java/test/test/runtime/api/handlers/array_request_parameters/ArrayRequestParameters.java +src/main/java/test/test/runtime/api/handlers/dictionary/Dictionary.java src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnum.java src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBody.java src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOf.java @@ -30398,14 +30404,17 @@ src/main/java/test/test/runtime/ServerConfiguration.java src/main/java/test/test/runtime/ServerVariable.java src/main/java/test/test/runtime/StringUtil.java src/main/java/test/test/runtime/model/AbstractOpenApiSchema.java +src/main/java/test/test/runtime/model/AdditionalPropertiesResponse.java src/main/java/test/test/runtime/model/AnotherNamedOneOf.java src/main/java/test/test/runtime/model/ArrayOfOneOfs.java +src/main/java/test/test/runtime/model/Dictionary.java src/main/java/test/test/runtime/model/InlineEnum200Response.java src/main/java/test/test/runtime/model/InlineEnum200ResponseCategoryEnum.java src/main/java/test/test/runtime/model/InlineRequestBodyRequestContent.java src/main/java/test/test/runtime/model/MyEnum.java src/main/java/test/test/runtime/model/NamedOneOf.java -src/main/java/test/test/runtime/model/NamedOneOfUnion.java", +src/main/java/test/test/runtime/model/NamedOneOfUnion.java +src/main/java/test/test/runtime/model/SomeObject.java", "src/main/java/test/test/runtime/ApiCallback.java": "/* * Edge Cases * @@ -32472,12 +32481,15 @@ public class JSON { gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.AdditionalPropertiesResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.AnotherNamedOneOf.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.ArrayOfOneOfs.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.Dictionary.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.InlineEnum200Response.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.InlineRequestBodyRequestContent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.NamedOneOf.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.NamedOneOfUnion.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new test.test.runtime.model.SomeObject.CustomTypeAdapterFactory()); gson = gsonBuilder.create(); } @@ -33178,6 +33190,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.io.File; +import test.test.runtime.model.AdditionalPropertiesResponse; import test.test.runtime.model.ArrayOfOneOfs; import test.test.runtime.model.InlineEnum200Response; import test.test.runtime.model.InlineRequestBodyRequestContent; @@ -33648,6 +33661,151 @@ public class DefaultApi { public APIarrayRequestParametersRequest arrayRequestParameters() { return new APIarrayRequestParametersRequest(); } + private okhttp3.Call dictionaryCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/additional-properties"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + + @SuppressWarnings("rawtypes") + private okhttp3.Call dictionaryValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return dictionaryCall(_callback); + + } + + private ApiResponse dictionaryWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = dictionaryValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + + private okhttp3.Call dictionaryAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = dictionaryValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIdictionaryRequest { + + private APIdictionaryRequest() { + } + + /** + * Build call for dictionary + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 ok -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return dictionaryCall(_callback); + } + + /** + * Execute dictionary request + * @return AdditionalPropertiesResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 ok -
+ */ + public AdditionalPropertiesResponse execute() throws ApiException { + ApiResponse localVarResp = dictionaryWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * Execute dictionary request with HTTP info returned + * @return ApiResponse<AdditionalPropertiesResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 ok -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return dictionaryWithHttpInfo(); + } + + /** + * Execute dictionary request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 ok -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return dictionaryAsync(_callback); + } + } + + /** + * + * + * @return APIdictionaryRequest + * @http.response.details + + + +
Status Code Description Response Headers
200 ok -
+ */ + + public APIdictionaryRequest dictionary() { + return new APIdictionaryRequest(); + } private okhttp3.Call inlineEnumCall(final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers @@ -34325,6 +34483,7 @@ package test.test.runtime.api.handlers; import test.test.runtime.api.handlers.array_of_one_ofs.*; import test.test.runtime.api.handlers.array_request_parameters.*; +import test.test.runtime.api.handlers.dictionary.*; import test.test.runtime.api.handlers.inline_enum.*; import test.test.runtime.api.handlers.inline_request_body.*; import test.test.runtime.api.handlers.named_one_of.*; @@ -34348,6 +34507,7 @@ import java.util.Collections; public abstract class HandlerRouter implements RequestHandler { private static final String arrayOfOneOfsMethodAndPath = Handlers.concatMethodAndPath("POST", "/array-of-one-ofs"); private static final String arrayRequestParametersMethodAndPath = Handlers.concatMethodAndPath("GET", "/array-request-parameters"); + private static final String dictionaryMethodAndPath = Handlers.concatMethodAndPath("POST", "/additional-properties"); private static final String inlineEnumMethodAndPath = Handlers.concatMethodAndPath("GET", "/inline-enum"); private static final String inlineRequestBodyMethodAndPath = Handlers.concatMethodAndPath("POST", "/inline-request-body"); private static final String namedOneOfMethodAndPath = Handlers.concatMethodAndPath("POST", "/named-one-of"); @@ -34355,6 +34515,7 @@ public abstract class HandlerRouter implements RequestHandler> arrayRequestParametersInterceptors = Handlers.getAnnotationInterceptors(this.getClass()); arrayRequestParametersInterceptors.addAll(this.getInterceptors()); return this.constructedArrayRequestParameters.handleRequestWithAdditionalInterceptors(event, context, arrayRequestParametersInterceptors); + case dictionaryRoute: + List> dictionaryInterceptors = Handlers.getAnnotationInterceptors(this.getClass()); + dictionaryInterceptors.addAll(this.getInterceptors()); + return this.constructedDictionary.handleRequestWithAdditionalInterceptors(event, context, dictionaryInterceptors); case inlineEnumRoute: List> inlineEnumInterceptors = Handlers.getAnnotationInterceptors(this.getClass()); inlineEnumInterceptors.addAll(this.getInterceptors()); @@ -35976,8 +36148,8 @@ import test.test.runtime.api.handlers.Response; */ public interface ArrayRequestParametersResponse extends Response {} ", - "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnum.java": " -package test.test.runtime.api.handlers.inline_enum; + "src/main/java/test/test/runtime/api/handlers/dictionary/Dictionary.java": " +package test.test.runtime.api.handlers.dictionary; import test.test.runtime.model.*; import test.test.runtime.JSON; @@ -36001,50 +36173,50 @@ import org.crac.Resource; /** - * Lambda handler wrapper for the inlineEnum operation + * Lambda handler wrapper for the dictionary operation */ -public abstract class InlineEnum implements RequestHandler, Resource { +public abstract class Dictionary implements RequestHandler, Resource { { Core.getGlobalContext().register(this); } /** - * Handle the request for the inlineEnum operation + * Handle the request for the dictionary operation */ - public abstract InlineEnumResponse handle(final InlineEnumRequestInput request); + public abstract DictionaryResponse handle(final DictionaryRequestInput request); /** * Interceptors that the handler class has been decorated with */ - private List> annotationInterceptors = Handlers.getAnnotationInterceptors(InlineEnum.class); + private List> annotationInterceptors = Handlers.getAnnotationInterceptors(Dictionary.class); /** * For more complex interceptors that require instantiation with parameters, you may override this method to * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, * prefer the @Interceptors annotation. */ - public List> getInterceptors() { + public List> getInterceptors() { return Collections.emptyList(); } - private List> getHandlerInterceptors() { - List> interceptors = new ArrayList<>(); + private List> getHandlerInterceptors() { + List> interceptors = new ArrayList<>(); interceptors.addAll(annotationInterceptors); interceptors.addAll(this.getInterceptors()); return interceptors; } - private HandlerChain buildChain(List> interceptors) { - return Handlers.buildHandlerChain(interceptors, new HandlerChain() { + private HandlerChain buildChain(List> interceptors) { + return Handlers.buildHandlerChain(interceptors, new HandlerChain() { @Override - public Response next(ChainedRequestInput input) { - return handle(new InlineEnumRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + public Response next(ChainedRequestInput input) { + return handle(new DictionaryRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); } }); } - private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final InlineEnumInput input, final Map interceptorContext) { - return new ChainedRequestInput() { + private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final DictionaryInput input, final Map interceptorContext) { + return new ChainedRequestInput() { @Override public HandlerChain getChain() { // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining @@ -36063,7 +36235,7 @@ public abstract class InlineEnum implements RequestHandler()) .withQueryStringParameters(new HashMap<>()) @@ -36124,20 +36296,20 @@ public abstract class InlineEnum implements RequestHandler> additionalInterceptors) { + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { final Map interceptorContext = new HashMap<>(); - interceptorContext.put("operationId", "inlineEnum"); + interceptorContext.put("operationId", "dictionary"); - List> interceptors = new ArrayList<>(); + List> interceptors = new ArrayList<>(); interceptors.addAll(additionalInterceptors); interceptors.addAll(this.getHandlerInterceptors()); final HandlerChain chain = this.buildChain(interceptors); - InlineEnumInput input; + DictionaryInput input; try { - input = new InlineEnumInput(event); + input = new DictionaryInput(event); } catch (RuntimeException e) { Map headers = new HashMap<>(); headers.putAll(Handlers.extractResponseHeadersFromInterceptors(interceptors)); @@ -36162,8 +36334,8 @@ public abstract class InlineEnum implements RequestHandler headers; private final Map> multiValueHeaders; - private InlineEnum200Response(final InlineEnum200Response body, final Map headers, final Map> multiValueHeaders) { + private Dictionary200Response(final AdditionalPropertiesResponse body, final Map headers, final Map> multiValueHeaders) { this.typedBody = body; this.body = body.toJson(); this.headers = headers; @@ -36205,7 +36377,7 @@ public class InlineEnum200Response extends RuntimeException implements InlineEnu return this.body; } - public InlineEnum200Response getTypedBody() { + public AdditionalPropertiesResponse getTypedBody() { return this.typedBody; } @@ -36220,29 +36392,29 @@ public class InlineEnum200Response extends RuntimeException implements InlineEnu } /** - * Create a InlineEnum200Response with a body + * Create a Dictionary200Response with a body */ - public static InlineEnum200Response of(final InlineEnum200Response body) { - return new InlineEnum200Response(body, new HashMap<>(), new HashMap<>()); + public static Dictionary200Response of(final AdditionalPropertiesResponse body) { + return new Dictionary200Response(body, new HashMap<>(), new HashMap<>()); } /** - * Create a InlineEnum200Response with a body and headers + * Create a Dictionary200Response with a body and headers */ - public static InlineEnum200Response of(final InlineEnum200Response body, final Map headers) { - return new InlineEnum200Response(body, headers, new HashMap<>()); + public static Dictionary200Response of(final AdditionalPropertiesResponse body, final Map headers) { + return new Dictionary200Response(body, headers, new HashMap<>()); } /** - * Create a InlineEnum200Response with a body, headers and multi-value headers + * Create a Dictionary200Response with a body, headers and multi-value headers */ - public static InlineEnum200Response of(final InlineEnum200Response body, final Map headers, final Map> multiValueHeaders) { - return new InlineEnum200Response(body, headers, multiValueHeaders); + public static Dictionary200Response of(final AdditionalPropertiesResponse body, final Map headers, final Map> multiValueHeaders) { + return new Dictionary200Response(body, headers, multiValueHeaders); } } ", - "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumInput.java": " -package test.test.runtime.api.handlers.inline_enum; + "src/main/java/test/test/runtime/api/handlers/dictionary/DictionaryInput.java": " +package test.test.runtime.api.handlers.dictionary; import test.test.runtime.model.*; import test.test.runtime.JSON; @@ -36255,11 +36427,11 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import java.io.IOException; /** - * Input for the inlineEnum operation + * Input for the dictionary operation */ @lombok.Builder @lombok.AllArgsConstructor -public class InlineEnumInput { +public class DictionaryInput { static { // JSON has a static instance of Gson which is instantiated lazily the first time it is initialised. // Create an instance here if required to ensure that the static Gson instance is always available. @@ -36268,20 +36440,20 @@ public class InlineEnumInput { } } - private final InlineEnumRequestParameters requestParameters; + private final DictionaryRequestParameters requestParameters; - public InlineEnumInput(final APIGatewayProxyRequestEvent event) { - this.requestParameters = new InlineEnumRequestParameters(event); + public DictionaryInput(final APIGatewayProxyRequestEvent event) { + this.requestParameters = new DictionaryRequestParameters(event); } - public InlineEnumRequestParameters getRequestParameters() { + public DictionaryRequestParameters getRequestParameters() { return this.requestParameters; } } ", - "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumRequestInput.java": " -package test.test.runtime.api.handlers.inline_enum; + "src/main/java/test/test/runtime/api/handlers/dictionary/DictionaryRequestInput.java": " +package test.test.runtime.api.handlers.dictionary; import test.test.runtime.model.*; import test.test.runtime.api.handlers.RequestInput; @@ -36294,20 +36466,20 @@ import java.io.IOException; import com.amazonaws.services.lambda.runtime.Context; /** - * Full request input for the inlineEnum operation, including the raw API Gateway event + * Full request input for the dictionary operation, including the raw API Gateway event */ @lombok.Builder @lombok.AllArgsConstructor -public class InlineEnumRequestInput implements RequestInput { +public class DictionaryRequestInput implements RequestInput { private final APIGatewayProxyRequestEvent event; private final Context context; private final Map interceptorContext; - private final InlineEnumInput input; + private final DictionaryInput input; /** * Returns the typed request input, with path, query and body parameters */ - public InlineEnumInput getInput() { + public DictionaryInput getInput() { return this.input; } @@ -36333,8 +36505,8 @@ public class InlineEnumRequestInput implements RequestInput { } } ", - "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumRequestParameters.java": " -package test.test.runtime.api.handlers.inline_enum; + "src/main/java/test/test/runtime/api/handlers/dictionary/DictionaryRequestParameters.java": " +package test.test.runtime.api.handlers.dictionary; import test.test.runtime.api.handlers.Handlers; import java.util.Optional; @@ -36351,13 +36523,13 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import test.test.runtime.model.*; /** - * Query, path and header parameters for the InlineEnum operation + * Query, path and header parameters for the Dictionary operation */ @lombok.Builder @lombok.AllArgsConstructor -public class InlineEnumRequestParameters { +public class DictionaryRequestParameters { - public InlineEnumRequestParameters(final APIGatewayProxyRequestEvent event) { + public DictionaryRequestParameters(final APIGatewayProxyRequestEvent event) { Map rawStringParameters = new HashMap<>(); Handlers.putAllFromNullableMap(event.getPathParameters(), rawStringParameters); Handlers.putAllFromNullableMap(event.getQueryStringParameters(), rawStringParameters); @@ -36373,18 +36545,18 @@ public class InlineEnumRequestParameters { } ", - "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumResponse.java": " -package test.test.runtime.api.handlers.inline_enum; + "src/main/java/test/test/runtime/api/handlers/dictionary/DictionaryResponse.java": " +package test.test.runtime.api.handlers.dictionary; import test.test.runtime.api.handlers.Response; /** - * Response for the inlineEnum operation + * Response for the dictionary operation */ -public interface InlineEnumResponse extends Response {} +public interface DictionaryResponse extends Response {} ", - "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBody.java": " -package test.test.runtime.api.handlers.inline_request_body; + "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnum.java": " +package test.test.runtime.api.handlers.inline_enum; import test.test.runtime.model.*; import test.test.runtime.JSON; @@ -36408,50 +36580,50 @@ import org.crac.Resource; /** - * Lambda handler wrapper for the inlineRequestBody operation + * Lambda handler wrapper for the inlineEnum operation */ -public abstract class InlineRequestBody implements RequestHandler, Resource { +public abstract class InlineEnum implements RequestHandler, Resource { { Core.getGlobalContext().register(this); } /** - * Handle the request for the inlineRequestBody operation + * Handle the request for the inlineEnum operation */ - public abstract InlineRequestBodyResponse handle(final InlineRequestBodyRequestInput request); + public abstract InlineEnumResponse handle(final InlineEnumRequestInput request); /** * Interceptors that the handler class has been decorated with */ - private List> annotationInterceptors = Handlers.getAnnotationInterceptors(InlineRequestBody.class); + private List> annotationInterceptors = Handlers.getAnnotationInterceptors(InlineEnum.class); /** * For more complex interceptors that require instantiation with parameters, you may override this method to * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, * prefer the @Interceptors annotation. */ - public List> getInterceptors() { + public List> getInterceptors() { return Collections.emptyList(); } - private List> getHandlerInterceptors() { - List> interceptors = new ArrayList<>(); + private List> getHandlerInterceptors() { + List> interceptors = new ArrayList<>(); interceptors.addAll(annotationInterceptors); interceptors.addAll(this.getInterceptors()); return interceptors; } - private HandlerChain buildChain(List> interceptors) { - return Handlers.buildHandlerChain(interceptors, new HandlerChain() { + private HandlerChain buildChain(List> interceptors) { + return Handlers.buildHandlerChain(interceptors, new HandlerChain() { @Override - public Response next(ChainedRequestInput input) { - return handle(new InlineRequestBodyRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + public Response next(ChainedRequestInput input) { + return handle(new InlineEnumRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); } }); } - private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final InlineRequestBodyInput input, final Map interceptorContext) { - return new ChainedRequestInput() { + private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final InlineEnumInput input, final Map interceptorContext) { + return new ChainedRequestInput() { @Override public HandlerChain getChain() { // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining @@ -36470,7 +36642,7 @@ public abstract class InlineRequestBody implements RequestHandler()) .withQueryStringParameters(new HashMap<>()) @@ -36531,20 +36703,20 @@ public abstract class InlineRequestBody implements RequestHandler> additionalInterceptors) { + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { final Map interceptorContext = new HashMap<>(); - interceptorContext.put("operationId", "inlineRequestBody"); + interceptorContext.put("operationId", "inlineEnum"); - List> interceptors = new ArrayList<>(); + List> interceptors = new ArrayList<>(); interceptors.addAll(additionalInterceptors); interceptors.addAll(this.getHandlerInterceptors()); final HandlerChain chain = this.buildChain(interceptors); - InlineRequestBodyInput input; + InlineEnumInput input; try { - input = new InlineRequestBodyInput(event); + input = new InlineEnumInput(event); } catch (RuntimeException e) { Map headers = new HashMap<>(); headers.putAll(Handlers.extractResponseHeadersFromInterceptors(interceptors)); @@ -36569,8 +36741,8 @@ public abstract class InlineRequestBody implements RequestHandler headers; private final Map> multiValueHeaders; - private InlineRequestBody204Response(final Map headers, final Map> multiValueHeaders) { - - this.body = ""; + private InlineEnum200Response(final InlineEnum200Response body, final Map headers, final Map> multiValueHeaders) { + this.typedBody = body; + this.body = body.toJson(); this.headers = headers; this.multiValueHeaders = multiValueHeaders; } @Override public int getStatusCode() { - return 204; + return 200; } @Override @@ -36612,6 +36784,9 @@ public class InlineRequestBody204Response extends RuntimeException implements In return this.body; } + public InlineEnum200Response getTypedBody() { + return this.typedBody; + } @Override public Map getHeaders() { @@ -36624,29 +36799,29 @@ public class InlineRequestBody204Response extends RuntimeException implements In } /** - * Create a InlineRequestBody204Response without a body + * Create a InlineEnum200Response with a body */ - public static InlineRequestBody204Response of() { - return new InlineRequestBody204Response(new HashMap<>(), new HashMap<>()); + public static InlineEnum200Response of(final InlineEnum200Response body) { + return new InlineEnum200Response(body, new HashMap<>(), new HashMap<>()); } /** - * Create a InlineRequestBody204Response without a body and headers + * Create a InlineEnum200Response with a body and headers */ - public static InlineRequestBody204Response of(final Map headers) { - return new InlineRequestBody204Response(headers, new HashMap<>()); + public static InlineEnum200Response of(final InlineEnum200Response body, final Map headers) { + return new InlineEnum200Response(body, headers, new HashMap<>()); } /** - * Create a InlineRequestBody204Response without a body, headers and multi-value headers + * Create a InlineEnum200Response with a body, headers and multi-value headers */ - public static InlineRequestBody204Response of(final Map headers, final Map> multiValueHeaders) { - return new InlineRequestBody204Response(headers, multiValueHeaders); + public static InlineEnum200Response of(final InlineEnum200Response body, final Map headers, final Map> multiValueHeaders) { + return new InlineEnum200Response(body, headers, multiValueHeaders); } } ", - "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyInput.java": " -package test.test.runtime.api.handlers.inline_request_body; + "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumInput.java": " +package test.test.runtime.api.handlers.inline_enum; import test.test.runtime.model.*; import test.test.runtime.JSON; @@ -36659,11 +36834,11 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import java.io.IOException; /** - * Input for the inlineRequestBody operation + * Input for the inlineEnum operation */ @lombok.Builder @lombok.AllArgsConstructor -public class InlineRequestBodyInput { +public class InlineEnumInput { static { // JSON has a static instance of Gson which is instantiated lazily the first time it is initialised. // Create an instance here if required to ensure that the static Gson instance is always available. @@ -36672,29 +36847,20 @@ public class InlineRequestBodyInput { } } - private final InlineRequestBodyRequestParameters requestParameters; - private final InlineRequestBodyRequestContent body; + private final InlineEnumRequestParameters requestParameters; - public InlineRequestBodyInput(final APIGatewayProxyRequestEvent event) { - this.requestParameters = new InlineRequestBodyRequestParameters(event); - try { - this.body = InlineRequestBodyRequestContent.fromJson(event.getBody()); - } catch (IOException e) { - throw new RuntimeException(e); - }; + public InlineEnumInput(final APIGatewayProxyRequestEvent event) { + this.requestParameters = new InlineEnumRequestParameters(event); } - public InlineRequestBodyRequestParameters getRequestParameters() { + public InlineEnumRequestParameters getRequestParameters() { return this.requestParameters; } - public InlineRequestBodyRequestContent getBody() { - return this.body; - } } ", - "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyRequestInput.java": " -package test.test.runtime.api.handlers.inline_request_body; + "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumRequestInput.java": " +package test.test.runtime.api.handlers.inline_enum; import test.test.runtime.model.*; import test.test.runtime.api.handlers.RequestInput; @@ -36707,20 +36873,20 @@ import java.io.IOException; import com.amazonaws.services.lambda.runtime.Context; /** - * Full request input for the inlineRequestBody operation, including the raw API Gateway event + * Full request input for the inlineEnum operation, including the raw API Gateway event */ @lombok.Builder @lombok.AllArgsConstructor -public class InlineRequestBodyRequestInput implements RequestInput { +public class InlineEnumRequestInput implements RequestInput { private final APIGatewayProxyRequestEvent event; private final Context context; private final Map interceptorContext; - private final InlineRequestBodyInput input; + private final InlineEnumInput input; /** * Returns the typed request input, with path, query and body parameters */ - public InlineRequestBodyInput getInput() { + public InlineEnumInput getInput() { return this.input; } @@ -36746,8 +36912,8 @@ public class InlineRequestBodyRequestInput implements RequestInput rawStringParameters = new HashMap<>(); Handlers.putAllFromNullableMap(event.getPathParameters(), rawStringParameters); Handlers.putAllFromNullableMap(event.getQueryStringParameters(), rawStringParameters); @@ -36786,18 +36952,18 @@ public class InlineRequestBodyRequestParameters { } ", - "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyResponse.java": " -package test.test.runtime.api.handlers.inline_request_body; + "src/main/java/test/test/runtime/api/handlers/inline_enum/InlineEnumResponse.java": " +package test.test.runtime.api.handlers.inline_enum; import test.test.runtime.api.handlers.Response; /** - * Response for the inlineRequestBody operation + * Response for the inlineEnum operation */ -public interface InlineRequestBodyResponse extends Response {} +public interface InlineEnumResponse extends Response {} ", - "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOf.java": " -package test.test.runtime.api.handlers.named_one_of; + "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBody.java": " +package test.test.runtime.api.handlers.inline_request_body; import test.test.runtime.model.*; import test.test.runtime.JSON; @@ -36821,50 +36987,50 @@ import org.crac.Resource; /** - * Lambda handler wrapper for the namedOneOf operation + * Lambda handler wrapper for the inlineRequestBody operation */ -public abstract class NamedOneOf implements RequestHandler, Resource { +public abstract class InlineRequestBody implements RequestHandler, Resource { { Core.getGlobalContext().register(this); } /** - * Handle the request for the namedOneOf operation + * Handle the request for the inlineRequestBody operation */ - public abstract NamedOneOfResponse handle(final NamedOneOfRequestInput request); + public abstract InlineRequestBodyResponse handle(final InlineRequestBodyRequestInput request); /** * Interceptors that the handler class has been decorated with */ - private List> annotationInterceptors = Handlers.getAnnotationInterceptors(NamedOneOf.class); + private List> annotationInterceptors = Handlers.getAnnotationInterceptors(InlineRequestBody.class); /** * For more complex interceptors that require instantiation with parameters, you may override this method to * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, * prefer the @Interceptors annotation. */ - public List> getInterceptors() { + public List> getInterceptors() { return Collections.emptyList(); } - private List> getHandlerInterceptors() { - List> interceptors = new ArrayList<>(); + private List> getHandlerInterceptors() { + List> interceptors = new ArrayList<>(); interceptors.addAll(annotationInterceptors); interceptors.addAll(this.getInterceptors()); return interceptors; } - private HandlerChain buildChain(List> interceptors) { - return Handlers.buildHandlerChain(interceptors, new HandlerChain() { + private HandlerChain buildChain(List> interceptors) { + return Handlers.buildHandlerChain(interceptors, new HandlerChain() { @Override - public Response next(ChainedRequestInput input) { - return handle(new NamedOneOfRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + public Response next(ChainedRequestInput input) { + return handle(new InlineRequestBodyRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); } }); } - private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final NamedOneOfInput input, final Map interceptorContext) { - return new ChainedRequestInput() { + private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final InlineRequestBodyInput input, final Map interceptorContext) { + return new ChainedRequestInput() { @Override public HandlerChain getChain() { // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining @@ -36883,7 +37049,7 @@ public abstract class NamedOneOf implements RequestHandler()) .withQueryStringParameters(new HashMap<>()) @@ -36944,20 +37110,20 @@ public abstract class NamedOneOf implements RequestHandler> additionalInterceptors) { + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { final Map interceptorContext = new HashMap<>(); - interceptorContext.put("operationId", "namedOneOf"); + interceptorContext.put("operationId", "inlineRequestBody"); - List> interceptors = new ArrayList<>(); + List> interceptors = new ArrayList<>(); interceptors.addAll(additionalInterceptors); interceptors.addAll(this.getHandlerInterceptors()); final HandlerChain chain = this.buildChain(interceptors); - NamedOneOfInput input; + InlineRequestBodyInput input; try { - input = new NamedOneOfInput(event); + input = new InlineRequestBodyInput(event); } catch (RuntimeException e) { Map headers = new HashMap<>(); headers.putAll(Handlers.extractResponseHeadersFromInterceptors(interceptors)); @@ -36982,8 +37148,8 @@ public abstract class NamedOneOf implements RequestHandler headers; private final Map> multiValueHeaders; - private NamedOneOf200Response(final NamedOneOfUnion body, final Map headers, final Map> multiValueHeaders) { - this.typedBody = body; - this.body = body.toJson(); + private InlineRequestBody204Response(final Map headers, final Map> multiValueHeaders) { + + this.body = ""; this.headers = headers; this.multiValueHeaders = multiValueHeaders; } @Override public int getStatusCode() { - return 200; + return 204; } @Override @@ -37025,9 +37191,6 @@ public class NamedOneOf200Response extends RuntimeException implements NamedOneO return this.body; } - public NamedOneOfUnion getTypedBody() { - return this.typedBody; - } @Override public Map getHeaders() { @@ -37040,29 +37203,29 @@ public class NamedOneOf200Response extends RuntimeException implements NamedOneO } /** - * Create a NamedOneOf200Response with a body + * Create a InlineRequestBody204Response without a body */ - public static NamedOneOf200Response of(final NamedOneOfUnion body) { - return new NamedOneOf200Response(body, new HashMap<>(), new HashMap<>()); + public static InlineRequestBody204Response of() { + return new InlineRequestBody204Response(new HashMap<>(), new HashMap<>()); } /** - * Create a NamedOneOf200Response with a body and headers + * Create a InlineRequestBody204Response without a body and headers */ - public static NamedOneOf200Response of(final NamedOneOfUnion body, final Map headers) { - return new NamedOneOf200Response(body, headers, new HashMap<>()); + public static InlineRequestBody204Response of(final Map headers) { + return new InlineRequestBody204Response(headers, new HashMap<>()); } /** - * Create a NamedOneOf200Response with a body, headers and multi-value headers + * Create a InlineRequestBody204Response without a body, headers and multi-value headers */ - public static NamedOneOf200Response of(final NamedOneOfUnion body, final Map headers, final Map> multiValueHeaders) { - return new NamedOneOf200Response(body, headers, multiValueHeaders); + public static InlineRequestBody204Response of(final Map headers, final Map> multiValueHeaders) { + return new InlineRequestBody204Response(headers, multiValueHeaders); } } ", - "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfInput.java": " -package test.test.runtime.api.handlers.named_one_of; + "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyInput.java": " +package test.test.runtime.api.handlers.inline_request_body; import test.test.runtime.model.*; import test.test.runtime.JSON; @@ -37075,11 +37238,11 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import java.io.IOException; /** - * Input for the namedOneOf operation + * Input for the inlineRequestBody operation */ @lombok.Builder @lombok.AllArgsConstructor -public class NamedOneOfInput { +public class InlineRequestBodyInput { static { // JSON has a static instance of Gson which is instantiated lazily the first time it is initialised. // Create an instance here if required to ensure that the static Gson instance is always available. @@ -37088,20 +37251,29 @@ public class NamedOneOfInput { } } - private final NamedOneOfRequestParameters requestParameters; + private final InlineRequestBodyRequestParameters requestParameters; + private final InlineRequestBodyRequestContent body; - public NamedOneOfInput(final APIGatewayProxyRequestEvent event) { - this.requestParameters = new NamedOneOfRequestParameters(event); + public InlineRequestBodyInput(final APIGatewayProxyRequestEvent event) { + this.requestParameters = new InlineRequestBodyRequestParameters(event); + try { + this.body = InlineRequestBodyRequestContent.fromJson(event.getBody()); + } catch (IOException e) { + throw new RuntimeException(e); + }; } - public NamedOneOfRequestParameters getRequestParameters() { + public InlineRequestBodyRequestParameters getRequestParameters() { return this.requestParameters; } + public InlineRequestBodyRequestContent getBody() { + return this.body; + } } ", - "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfRequestInput.java": " -package test.test.runtime.api.handlers.named_one_of; + "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyRequestInput.java": " +package test.test.runtime.api.handlers.inline_request_body; import test.test.runtime.model.*; import test.test.runtime.api.handlers.RequestInput; @@ -37114,20 +37286,20 @@ import java.io.IOException; import com.amazonaws.services.lambda.runtime.Context; /** - * Full request input for the namedOneOf operation, including the raw API Gateway event + * Full request input for the inlineRequestBody operation, including the raw API Gateway event */ @lombok.Builder @lombok.AllArgsConstructor -public class NamedOneOfRequestInput implements RequestInput { +public class InlineRequestBodyRequestInput implements RequestInput { private final APIGatewayProxyRequestEvent event; private final Context context; private final Map interceptorContext; - private final NamedOneOfInput input; + private final InlineRequestBodyInput input; /** * Returns the typed request input, with path, query and body parameters */ - public NamedOneOfInput getInput() { + public InlineRequestBodyInput getInput() { return this.input; } @@ -37153,8 +37325,8 @@ public class NamedOneOfRequestInput implements RequestInput { } } ", - "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfRequestParameters.java": " -package test.test.runtime.api.handlers.named_one_of; + "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyRequestParameters.java": " +package test.test.runtime.api.handlers.inline_request_body; import test.test.runtime.api.handlers.Handlers; import java.util.Optional; @@ -37171,13 +37343,13 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import test.test.runtime.model.*; /** - * Query, path and header parameters for the NamedOneOf operation + * Query, path and header parameters for the InlineRequestBody operation */ @lombok.Builder @lombok.AllArgsConstructor -public class NamedOneOfRequestParameters { +public class InlineRequestBodyRequestParameters { - public NamedOneOfRequestParameters(final APIGatewayProxyRequestEvent event) { + public InlineRequestBodyRequestParameters(final APIGatewayProxyRequestEvent event) { Map rawStringParameters = new HashMap<>(); Handlers.putAllFromNullableMap(event.getPathParameters(), rawStringParameters); Handlers.putAllFromNullableMap(event.getQueryStringParameters(), rawStringParameters); @@ -37193,18 +37365,18 @@ public class NamedOneOfRequestParameters { } ", - "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfResponse.java": " -package test.test.runtime.api.handlers.named_one_of; + "src/main/java/test/test/runtime/api/handlers/inline_request_body/InlineRequestBodyResponse.java": " +package test.test.runtime.api.handlers.inline_request_body; import test.test.runtime.api.handlers.Response; /** - * Response for the namedOneOf operation + * Response for the inlineRequestBody operation */ -public interface NamedOneOfResponse extends Response {} +public interface InlineRequestBodyResponse extends Response {} ", - "src/main/java/test/test/runtime/api/handlers/reserved_keywords/ReservedKeywords.java": " -package test.test.runtime.api.handlers.reserved_keywords; + "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOf.java": " +package test.test.runtime.api.handlers.named_one_of; import test.test.runtime.model.*; import test.test.runtime.JSON; @@ -37228,50 +37400,50 @@ import org.crac.Resource; /** - * Lambda handler wrapper for the reservedKeywords operation + * Lambda handler wrapper for the namedOneOf operation */ -public abstract class ReservedKeywords implements RequestHandler, Resource { +public abstract class NamedOneOf implements RequestHandler, Resource { { Core.getGlobalContext().register(this); } /** - * Handle the request for the reservedKeywords operation + * Handle the request for the namedOneOf operation */ - public abstract ReservedKeywordsResponse handle(final ReservedKeywordsRequestInput request); + public abstract NamedOneOfResponse handle(final NamedOneOfRequestInput request); /** * Interceptors that the handler class has been decorated with */ - private List> annotationInterceptors = Handlers.getAnnotationInterceptors(ReservedKeywords.class); + private List> annotationInterceptors = Handlers.getAnnotationInterceptors(NamedOneOf.class); /** * For more complex interceptors that require instantiation with parameters, you may override this method to * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, * prefer the @Interceptors annotation. */ - public List> getInterceptors() { + public List> getInterceptors() { return Collections.emptyList(); } - private List> getHandlerInterceptors() { - List> interceptors = new ArrayList<>(); + private List> getHandlerInterceptors() { + List> interceptors = new ArrayList<>(); interceptors.addAll(annotationInterceptors); interceptors.addAll(this.getInterceptors()); return interceptors; } - private HandlerChain buildChain(List> interceptors) { - return Handlers.buildHandlerChain(interceptors, new HandlerChain() { + private HandlerChain buildChain(List> interceptors) { + return Handlers.buildHandlerChain(interceptors, new HandlerChain() { @Override - public Response next(ChainedRequestInput input) { - return handle(new ReservedKeywordsRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + public Response next(ChainedRequestInput input) { + return handle(new NamedOneOfRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); } }); } - private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final ReservedKeywordsInput input, final Map interceptorContext) { - return new ChainedRequestInput() { + private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final NamedOneOfInput input, final Map interceptorContext) { + return new ChainedRequestInput() { @Override public HandlerChain getChain() { // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining @@ -37290,7 +37462,7 @@ public abstract class ReservedKeywords implements RequestHandler()) .withQueryStringParameters(new HashMap<>()) @@ -37351,20 +37523,20 @@ public abstract class ReservedKeywords implements RequestHandler> additionalInterceptors) { + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { final Map interceptorContext = new HashMap<>(); - interceptorContext.put("operationId", "reservedKeywords"); + interceptorContext.put("operationId", "namedOneOf"); - List> interceptors = new ArrayList<>(); + List> interceptors = new ArrayList<>(); interceptors.addAll(additionalInterceptors); interceptors.addAll(this.getHandlerInterceptors()); final HandlerChain chain = this.buildChain(interceptors); - ReservedKeywordsInput input; + NamedOneOfInput input; try { - input = new ReservedKeywordsInput(event); + input = new NamedOneOfInput(event); } catch (RuntimeException e) { Map headers = new HashMap<>(); headers.putAll(Handlers.extractResponseHeadersFromInterceptors(interceptors)); @@ -37389,8 +37561,8 @@ public abstract class ReservedKeywords implements RequestHandler headers; + private final Map> multiValueHeaders; + + private NamedOneOf200Response(final NamedOneOfUnion body, final Map headers, final Map> multiValueHeaders) { + this.typedBody = body; + this.body = body.toJson(); + this.headers = headers; + this.multiValueHeaders = multiValueHeaders; + } + + @Override + public int getStatusCode() { + return 200; + } + + @Override + public String getBody() { + return this.body; + } + + public NamedOneOfUnion getTypedBody() { + return this.typedBody; + } + + @Override + public Map getHeaders() { + return this.headers; + } + + @Override + public Map> getMultiValueHeaders() { + return this.multiValueHeaders; + } + + /** + * Create a NamedOneOf200Response with a body + */ + public static NamedOneOf200Response of(final NamedOneOfUnion body) { + return new NamedOneOf200Response(body, new HashMap<>(), new HashMap<>()); + } + + /** + * Create a NamedOneOf200Response with a body and headers + */ + public static NamedOneOf200Response of(final NamedOneOfUnion body, final Map headers) { + return new NamedOneOf200Response(body, headers, new HashMap<>()); + } + + /** + * Create a NamedOneOf200Response with a body, headers and multi-value headers + */ + public static NamedOneOf200Response of(final NamedOneOfUnion body, final Map headers, final Map> multiValueHeaders) { + return new NamedOneOf200Response(body, headers, multiValueHeaders); + } +} +", + "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfInput.java": " +package test.test.runtime.api.handlers.named_one_of; + +import test.test.runtime.model.*; +import test.test.runtime.JSON; +import java.util.List; +import java.util.ArrayList; +import java.util.Optional; +import java.util.Map; +import java.util.HashMap; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; +import java.io.IOException; + +/** + * Input for the namedOneOf operation + */ +@lombok.Builder +@lombok.AllArgsConstructor +public class NamedOneOfInput { + static { + // JSON has a static instance of Gson which is instantiated lazily the first time it is initialised. + // Create an instance here if required to ensure that the static Gson instance is always available. + if (JSON.getGson() == null) { + new JSON(); + } + } + + private final NamedOneOfRequestParameters requestParameters; + + public NamedOneOfInput(final APIGatewayProxyRequestEvent event) { + this.requestParameters = new NamedOneOfRequestParameters(event); + } + + public NamedOneOfRequestParameters getRequestParameters() { + return this.requestParameters; + } + +} +", + "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfRequestInput.java": " +package test.test.runtime.api.handlers.named_one_of; + +import test.test.runtime.model.*; +import test.test.runtime.api.handlers.RequestInput; +import java.util.List; +import java.util.Optional; +import java.util.Map; +import java.util.HashMap; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; +import java.io.IOException; +import com.amazonaws.services.lambda.runtime.Context; + +/** + * Full request input for the namedOneOf operation, including the raw API Gateway event + */ +@lombok.Builder +@lombok.AllArgsConstructor +public class NamedOneOfRequestInput implements RequestInput { + private final APIGatewayProxyRequestEvent event; + private final Context context; + private final Map interceptorContext; + private final NamedOneOfInput input; + + /** + * Returns the typed request input, with path, query and body parameters + */ + public NamedOneOfInput getInput() { + return this.input; + } + + /** + * Returns the raw API Gateway event + */ + public APIGatewayProxyRequestEvent getEvent() { + return this.event; + } + + /** + * Returns the lambda context + */ + public Context getContext() { + return this.context; + } + + /** + * Returns the interceptor context, which may contain values set by request interceptors + */ + public Map getInterceptorContext() { + return this.interceptorContext; + } +} +", + "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfRequestParameters.java": " +package test.test.runtime.api.handlers.named_one_of; + +import test.test.runtime.api.handlers.Handlers; +import java.util.Optional; +import java.util.Map; +import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; +import java.time.OffsetDateTime; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.stream.Collectors; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; + +import test.test.runtime.model.*; + +/** + * Query, path and header parameters for the NamedOneOf operation + */ +@lombok.Builder +@lombok.AllArgsConstructor +public class NamedOneOfRequestParameters { + + public NamedOneOfRequestParameters(final APIGatewayProxyRequestEvent event) { + Map rawStringParameters = new HashMap<>(); + Handlers.putAllFromNullableMap(event.getPathParameters(), rawStringParameters); + Handlers.putAllFromNullableMap(event.getQueryStringParameters(), rawStringParameters); + Handlers.putAllFromNullableMap(event.getHeaders(), rawStringParameters); + Map decodedStringParameters = Handlers.decodeRequestParameters(rawStringParameters); + + Map> rawStringArrayParameters = new HashMap<>(); + Handlers.putAllFromNullableMap(event.getMultiValueQueryStringParameters(), rawStringArrayParameters); + Handlers.putAllFromNullableMap(event.getMultiValueHeaders(), rawStringArrayParameters); + Map> decodedStringArrayParameters = Handlers.decodeRequestArrayParameters(rawStringArrayParameters); + + } + +} +", + "src/main/java/test/test/runtime/api/handlers/named_one_of/NamedOneOfResponse.java": " +package test.test.runtime.api.handlers.named_one_of; + +import test.test.runtime.api.handlers.Response; + +/** + * Response for the namedOneOf operation + */ +public interface NamedOneOfResponse extends Response {} +", + "src/main/java/test/test/runtime/api/handlers/reserved_keywords/ReservedKeywords.java": " +package test.test.runtime.api.handlers.reserved_keywords; + +import test.test.runtime.model.*; +import test.test.runtime.JSON; +import test.test.runtime.api.handlers.Interceptor; +import test.test.runtime.api.handlers.Handlers; +import test.test.runtime.api.handlers.*; + +import java.util.List; +import java.util.ArrayList; +import java.util.Optional; +import java.util.Map; +import java.util.HashMap; +import java.util.Collections; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; +import java.io.IOException; +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import org.crac.Core; +import org.crac.Resource; + + +/** + * Lambda handler wrapper for the reservedKeywords operation + */ +public abstract class ReservedKeywords implements RequestHandler, Resource { + { + Core.getGlobalContext().register(this); + } + + /** + * Handle the request for the reservedKeywords operation + */ + public abstract ReservedKeywordsResponse handle(final ReservedKeywordsRequestInput request); + + /** + * Interceptors that the handler class has been decorated with + */ + private List> annotationInterceptors = Handlers.getAnnotationInterceptors(ReservedKeywords.class); + + /** + * For more complex interceptors that require instantiation with parameters, you may override this method to + * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, + * prefer the @Interceptors annotation. + */ + public List> getInterceptors() { + return Collections.emptyList(); + } + + private List> getHandlerInterceptors() { + List> interceptors = new ArrayList<>(); + interceptors.addAll(annotationInterceptors); + interceptors.addAll(this.getInterceptors()); + return interceptors; + } + + private HandlerChain buildChain(List> interceptors) { + return Handlers.buildHandlerChain(interceptors, new HandlerChain() { + @Override + public Response next(ChainedRequestInput input) { + return handle(new ReservedKeywordsRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + } + }); + } + + private ChainedRequestInput buildChainedRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final ReservedKeywordsInput input, final Map interceptorContext) { + return new ChainedRequestInput() { + @Override + public HandlerChain getChain() { + // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining + // chain. + return null; + } + + @Override + public APIGatewayProxyRequestEvent getEvent() { + return event; + } + + @Override + public Context getContext() { + return context; + } + + @Override + public ReservedKeywordsInput getInput() { + return input; + } + + @Override + public Map getInterceptorContext() { + return interceptorContext; + } + }; + } + + @Override + public void beforeCheckpoint(org.crac.Context context) { + // Prime building the handler chain which can take a few 100ms to JIT. + this.buildChain(this.getHandlerInterceptors()); + this.buildChainedRequestInput(null, null, null, null); + + // Initialise instance of Gson and prime serialisation and deserialisation + new JSON(); + JSON.getGson().fromJson(JSON.getGson().toJson(new ApiResponse("", 0, new HashMap<>(), new HashMap<>())), ApiResponse.class); + + try { + // Prime input validation - this will likely fail for the fake event but ensures the code path is optimised + // ready for a real invocation + new ReservedKeywordsInput(new APIGatewayProxyRequestEvent() + .withBody("{}") + .withPathParameters(new HashMap<>()) + .withQueryStringParameters(new HashMap<>()) + .withMultiValueQueryStringParameters(new HashMap<>()) + .withHeaders(new HashMap<>()) + .withMultiValueHeaders(new HashMap<>()) + ); + } catch (Exception e) { + + } + + this.warmUp(); + } + + @Override + public void afterRestore(org.crac.Context context) { + + } + + /** + * Override this method to perform any warmup activities which will be executed prior to the snap-start snapshot. + */ + public void warmUp() { + + } + + @Override + public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent event, final Context context) { + return this.handleRequestWithAdditionalInterceptors(event, context, new ArrayList<>()); + } + + private Map getErrorResponseHeaders(final int statusCode) { + Map headers = new HashMap<>(); + return headers; + } + + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { + final Map interceptorContext = new HashMap<>(); + interceptorContext.put("operationId", "reservedKeywords"); + + List> interceptors = new ArrayList<>(); + interceptors.addAll(additionalInterceptors); + interceptors.addAll(this.getHandlerInterceptors()); + + final HandlerChain chain = this.buildChain(interceptors); + + ReservedKeywordsInput input; + + try { + input = new ReservedKeywordsInput(event); + } catch (RuntimeException e) { + Map headers = new HashMap<>(); + headers.putAll(Handlers.extractResponseHeadersFromInterceptors(interceptors)); + headers.putAll(this.getErrorResponseHeaders(400)); + return new APIGatewayProxyResponseEvent() + .withStatusCode(400) + .withHeaders(headers) + .withBody("{\\"message\\": \\"" + e.getMessage() + "\\"}"); + } + + final Response response = chain.next(this.buildChainedRequestInput(event, context, input, interceptorContext)); + + Map responseHeaders = new HashMap<>(); + responseHeaders.putAll(this.getErrorResponseHeaders(response.getStatusCode())); + responseHeaders.putAll(response.getHeaders()); + + return new APIGatewayProxyResponseEvent() + .withStatusCode(response.getStatusCode()) + .withHeaders(responseHeaders) + .withMultiValueHeaders(response.getMultiValueHeaders()) + .withBody(response.getBody()); + } +} +", + "src/main/java/test/test/runtime/api/handlers/reserved_keywords/ReservedKeywords200Response.java": " +package test.test.runtime.api.handlers.reserved_keywords; + +import test.test.runtime.model.*; +import test.test.runtime.JSON; +import java.util.Map; +import java.util.HashMap; +import java.util.List; + +/** + * Response with status code 200 for the reservedKeywords operation */ public class ReservedKeywords200Response extends RuntimeException implements ReservedKeywordsResponse { static { @@ -37975,6 +38554,7 @@ import java.util.Map; public class OperationConfig { private T arrayOfOneOfs; private T arrayRequestParameters; + private T dictionary; private T inlineEnum; private T inlineRequestBody; private T namedOneOf; @@ -37984,6 +38564,7 @@ public class OperationConfig { Map map = new HashMap<>(); map.put("arrayOfOneOfs", this.arrayOfOneOfs); map.put("arrayRequestParameters", this.arrayRequestParameters); + map.put("dictionary", this.dictionary); map.put("inlineEnum", this.inlineEnum); map.put("inlineRequestBody", this.inlineRequestBody); map.put("namedOneOf", this.namedOneOf); @@ -38027,6 +38608,11 @@ public class OperationLookup { .method("GET") .contentTypes(Arrays.asList("application/json")) .build()); + config.put("dictionary", OperationLookupEntry.builder() + .path("/additional-properties") + .method("POST") + .contentTypes(Arrays.asList("application/json")) + .build()); config.put("inlineEnum", OperationLookupEntry.builder() .path("/inline-enum") .method("GET") @@ -38064,6 +38650,7 @@ public class Operations { return OperationConfig.builder() .arrayOfOneOfs(value) .arrayRequestParameters(value) + .dictionary(value) .inlineEnum(value) .inlineRequestBody(value) .namedOneOf(value) @@ -38409,50 +38996,315 @@ public abstract class AbstractOpenApiSchema { 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"; + /** + * 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 "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} +", + "src/main/java/test/test/runtime/model/AdditionalPropertiesResponse.java": "/* + * Edge Cases + * + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + + +package test.test.runtime.model; + +import java.util.Objects; +import java.util.Arrays; +import test.test.runtime.model.Dictionary; +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 javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.io.File; +import java.math.BigDecimal; +import java.net.URI; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.UUID; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.List; +import java.util.Set; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +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 com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import test.test.runtime.JSON; + +/** + * AdditionalPropertiesResponse + */ +@lombok.AllArgsConstructor @lombok.experimental.SuperBuilder +public class AdditionalPropertiesResponse { + public static final String SERIALIZED_NAME_DICTIONARY_OF_OBJECTS = "dictionaryOfObjects"; + @SerializedName(SERIALIZED_NAME_DICTIONARY_OF_OBJECTS) + private Dictionary dictionaryOfObjects; + + public static final String SERIALIZED_NAME_DICTIONARY_OF_PRIMITIVES = "dictionaryOfPrimitives"; + @SerializedName(SERIALIZED_NAME_DICTIONARY_OF_PRIMITIVES) + private Map dictionaryOfPrimitives = null; + + public AdditionalPropertiesResponse() { + } + + public AdditionalPropertiesResponse dictionaryOfObjects(Dictionary dictionaryOfObjects) { + + this.dictionaryOfObjects = dictionaryOfObjects; + return this; + } + + /** + * Get dictionaryOfObjects + * @return dictionaryOfObjects + **/ + @javax.annotation.Nullable + public Dictionary getDictionaryOfObjects() { + return dictionaryOfObjects; + } + + + public void setDictionaryOfObjects(Dictionary dictionaryOfObjects) { + this.dictionaryOfObjects = dictionaryOfObjects; + } + + public AdditionalPropertiesResponse dictionaryOfPrimitives(Map dictionaryOfPrimitives) { + + this.dictionaryOfPrimitives = dictionaryOfPrimitives; + return this; + } + + public AdditionalPropertiesResponse putDictionaryOfPrimitivesItem(String key, String dictionaryOfPrimitivesItem) { + if (this.dictionaryOfPrimitives == null) { + this.dictionaryOfPrimitives = new HashMap<>(); + } + this.dictionaryOfPrimitives.put(key, dictionaryOfPrimitivesItem); + return this; + } + + /** + * Get dictionaryOfPrimitives + * @return dictionaryOfPrimitives + **/ + @javax.annotation.Nullable + public Map getDictionaryOfPrimitives() { + return dictionaryOfPrimitives; + } + + + public void setDictionaryOfPrimitives(Map dictionaryOfPrimitives) { + this.dictionaryOfPrimitives = dictionaryOfPrimitives; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesResponse additionalPropertiesResponse = (AdditionalPropertiesResponse) o; + return Objects.equals(this.dictionaryOfObjects, additionalPropertiesResponse.dictionaryOfObjects) && + Objects.equals(this.dictionaryOfPrimitives, additionalPropertiesResponse.dictionaryOfPrimitives); + + } + + @Override + public int hashCode() { + return Objects.hash(dictionaryOfObjects, dictionaryOfPrimitives); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesResponse {\\n"); + sb.append(" dictionaryOfObjects: ").append(toIndentedString(dictionaryOfObjects)).append("\\n"); + sb.append(" dictionaryOfPrimitives: ").append(toIndentedString(dictionaryOfPrimitives)).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 "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("dictionaryOfObjects"); + openapiFields.add("dictionaryOfPrimitives"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesResponse + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!AdditionalPropertiesResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesResponse is not found in the empty JSON string", AdditionalPropertiesResponse.openapiRequiredFields.toString())); } - return o.toString().replace("\\n", "\\n "); - } + } - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!AdditionalPropertiesResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field \`%s\` in the JSON string is not defined in the \`AdditionalPropertiesResponse\` properties. JSON: %s", entry.getKey(), jsonObj.toString())); } - AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; - return Objects.equals(this.instance, a.instance) && - Objects.equals(this.isNullable, a.isNullable) && - Objects.equals(this.schemaType, a.schemaType); - } + } + // validate the optional field \`dictionaryOfObjects\` + if (jsonObj.get("dictionaryOfObjects") != null && !jsonObj.get("dictionaryOfObjects").isJsonNull()) { + Dictionary.validateJsonObject(jsonObj.getAsJsonObject("dictionaryOfObjects")); + } + if ((jsonObj.get("dictionaryOfPrimitives") != null && !jsonObj.get("dictionaryOfPrimitives").isJsonNull()) && !jsonObj.get("dictionaryOfPrimitives").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field \`dictionaryOfPrimitives\` to be a primitive type in the JSON string but got \`%s\`", jsonObj.get("dictionaryOfPrimitives").toString())); + } + } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") @Override - public int hashCode() { - return Objects.hash(instance, isNullable, schemaType); - } + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AdditionalPropertiesResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AdditionalPropertiesResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesResponse.class)); - /** - * Is nullable - * - * @return true if it's nullable - */ - public Boolean isNullable() { - if (Boolean.TRUE.equals(isNullable)) { - return Boolean.TRUE; - } else { - return Boolean.FALSE; - } - } + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, AdditionalPropertiesResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public AdditionalPropertiesResponse read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + }.nullSafe(); + } + } + /** + * Create an instance of AdditionalPropertiesResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdditionalPropertiesResponse + * @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesResponse + */ + public static AdditionalPropertiesResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AdditionalPropertiesResponse.class); + } + /** + * Convert an instance of AdditionalPropertiesResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } ", "src/main/java/test/test/runtime/model/AnotherNamedOneOf.java": "/* @@ -38783,8 +39635,210 @@ public class ArrayOfOneOfs { } - public void setOneOfs(List oneOfs) { - this.oneOfs = oneOfs; + public void setOneOfs(List oneOfs) { + this.oneOfs = oneOfs; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfOneOfs arrayOfOneOfs = (ArrayOfOneOfs) o; + return Objects.equals(this.oneOfs, arrayOfOneOfs.oneOfs); + + } + + @Override + public int hashCode() { + return Objects.hash(oneOfs); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfOneOfs {\\n"); + sb.append(" oneOfs: ").append(toIndentedString(oneOfs)).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 "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("oneOfs"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ArrayOfOneOfs + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ArrayOfOneOfs.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfOneOfs is not found in the empty JSON string", ArrayOfOneOfs.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ArrayOfOneOfs.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field \`%s\` in the JSON string is not defined in the \`ArrayOfOneOfs\` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // ensure the optional json data is an array if present + if (jsonObj.get("oneOfs") != null && !jsonObj.get("oneOfs").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field \`oneOfs\` to be an array in the JSON string but got \`%s\`", jsonObj.get("oneOfs").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ArrayOfOneOfs.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ArrayOfOneOfs' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ArrayOfOneOfs.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ArrayOfOneOfs value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ArrayOfOneOfs read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ArrayOfOneOfs given an JSON string + * + * @param jsonString JSON string + * @return An instance of ArrayOfOneOfs + * @throws IOException if the JSON string is invalid with respect to ArrayOfOneOfs + */ + public static ArrayOfOneOfs fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ArrayOfOneOfs.class); + } + + /** + * Convert an instance of ArrayOfOneOfs to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +", + "src/main/java/test/test/runtime/model/Dictionary.java": "/* + * Edge Cases + * + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + + +package test.test.runtime.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 javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.io.File; +import java.math.BigDecimal; +import java.net.URI; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.UUID; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.List; +import java.util.Set; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +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 com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import test.test.runtime.JSON; + +/** + * Dictionary + */ +@lombok.AllArgsConstructor @lombok.experimental.SuperBuilder +public class Dictionary { + public Dictionary() { } @@ -38796,21 +39850,19 @@ public class ArrayOfOneOfs { if (o == null || getClass() != o.getClass()) { return false; } - ArrayOfOneOfs arrayOfOneOfs = (ArrayOfOneOfs) o; - return Objects.equals(this.oneOfs, arrayOfOneOfs.oneOfs); - + Dictionary dictionary = (Dictionary) o; + return } @Override public int hashCode() { - return Objects.hash(oneOfs); + return Objects.hash(); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ArrayOfOneOfs {\\n"); - sb.append(" oneOfs: ").append(toIndentedString(oneOfs)).append("\\n"); + sb.append("class Dictionary {\\n"); sb.append("}"); return sb.toString(); } @@ -38833,7 +39885,6 @@ public class ArrayOfOneOfs { static { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); - openapiFields.add("oneOfs"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -38843,48 +39894,44 @@ public class ArrayOfOneOfs { * Validates the JSON Object and throws an exception if issues found * * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to ArrayOfOneOfs + * @throws IOException if the JSON Object is invalid with respect to Dictionary */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (!ArrayOfOneOfs.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null - throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfOneOfs is not found in the empty JSON string", ArrayOfOneOfs.openapiRequiredFields.toString())); + if (!Dictionary.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Dictionary is not found in the empty JSON string", Dictionary.openapiRequiredFields.toString())); } } Set> entries = jsonObj.entrySet(); // check to see if the JSON string contains additional fields for (Entry entry : entries) { - if (!ArrayOfOneOfs.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field \`%s\` in the JSON string is not defined in the \`ArrayOfOneOfs\` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + if (!Dictionary.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field \`%s\` in the JSON string is not defined in the \`Dictionary\` properties. JSON: %s", entry.getKey(), jsonObj.toString())); } } - // ensure the optional json data is an array if present - if (jsonObj.get("oneOfs") != null && !jsonObj.get("oneOfs").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field \`oneOfs\` to be an array in the JSON string but got \`%s\`", jsonObj.get("oneOfs").toString())); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ArrayOfOneOfs.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ArrayOfOneOfs' and its subtypes + if (!Dictionary.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Dictionary' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ArrayOfOneOfs.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Dictionary.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, ArrayOfOneOfs value) throws IOException { + public void write(JsonWriter out, Dictionary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override - public ArrayOfOneOfs read(JsonReader in) throws IOException { + public Dictionary read(JsonReader in) throws IOException { JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); validateJsonObject(jsonObj); return thisAdapter.fromJsonTree(jsonObj); @@ -38895,18 +39942,18 @@ public class ArrayOfOneOfs { } /** - * Create an instance of ArrayOfOneOfs given an JSON string + * Create an instance of Dictionary given an JSON string * * @param jsonString JSON string - * @return An instance of ArrayOfOneOfs - * @throws IOException if the JSON string is invalid with respect to ArrayOfOneOfs + * @return An instance of Dictionary + * @throws IOException if the JSON string is invalid with respect to Dictionary */ - public static ArrayOfOneOfs fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ArrayOfOneOfs.class); + public static Dictionary fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Dictionary.class); } /** - * Convert an instance of ArrayOfOneOfs to an JSON string + * Convert an instance of Dictionary to an JSON string * * @return JSON string */ @@ -40123,6 +41170,231 @@ public class NamedOneOfUnion extends AbstractOpenApiSchema { } } +", + "src/main/java/test/test/runtime/model/SomeObject.java": "/* + * Edge Cases + * + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + + +package test.test.runtime.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 javax.ws.rs.core.GenericType; + +import java.io.IOException; +import java.io.File; +import java.math.BigDecimal; +import java.net.URI; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.UUID; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.List; +import java.util.Set; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.JsonPrimitive; +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 com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +import test.test.runtime.JSON; + +/** + * SomeObject + */ +@lombok.AllArgsConstructor @lombok.experimental.SuperBuilder +public class SomeObject { + public static final String SERIALIZED_NAME_A = "a"; + @SerializedName(SERIALIZED_NAME_A) + private String a; + + public SomeObject() { + } + + public SomeObject a(String a) { + + this.a = a; + return this; + } + + /** + * Get a + * @return a + **/ + @javax.annotation.Nullable + public String getA() { + return a; + } + + + public void setA(String a) { + this.a = a; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SomeObject someObject = (SomeObject) o; + return Objects.equals(this.a, someObject.a); + + } + + @Override + public int hashCode() { + return Objects.hash(a); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SomeObject {\\n"); + sb.append(" a: ").append(toIndentedString(a)).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 "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("a"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to SomeObject + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!SomeObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SomeObject is not found in the empty JSON string", SomeObject.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!SomeObject.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field \`%s\` in the JSON string is not defined in the \`SomeObject\` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("a") != null && !jsonObj.get("a").isJsonNull()) && !jsonObj.get("a").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field \`a\` to be a primitive type in the JSON string but got \`%s\`", jsonObj.get("a").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SomeObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SomeObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SomeObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SomeObject value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SomeObject read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SomeObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of SomeObject + * @throws IOException if the JSON string is invalid with respect to SomeObject + */ + public static SomeObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SomeObject.class); + } + + /** + * Convert an instance of SomeObject to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} ", } `; diff --git a/packages/type-safe-api/test/scripts/generators/__snapshots__/python.test.ts.snap b/packages/type-safe-api/test/scripts/generators/__snapshots__/python.test.ts.snap index 09861e8a1..09e6756cc 100644 --- a/packages/type-safe-api/test/scripts/generators/__snapshots__/python.test.ts.snap +++ b/packages/type-safe-api/test/scripts/generators/__snapshots__/python.test.ts.snap @@ -17428,14 +17428,17 @@ test_project/__init__.py test_project/py.typed test_project/rest.py docs/DefaultApi.md +docs/AdditionalPropertiesResponse.md docs/AnotherNamedOneOf.md docs/ArrayOfOneOfs.md +docs/Dictionary.md docs/InlineEnum200Response.md docs/InlineEnum200ResponseCategoryEnum.md docs/InlineRequestBodyRequestContent.md docs/MyEnum.md docs/NamedOneOf.md docs/NamedOneOfUnion.md +docs/SomeObject.md README.md test_project/interceptors/try_catch.py test_project/interceptors/response_headers.py @@ -17448,14 +17451,17 @@ test_project/response.py test_project/api/default_api.py test_project/api/__init__.py test_project/models/__init__.py +test_project/models/additional_properties_response.py test_project/models/another_named_one_of.py test_project/models/array_of_one_ofs.py +test_project/models/dictionary.py test_project/models/inline_enum200_response.py test_project/models/inline_enum200_response_category_enum.py test_project/models/inline_request_body_request_content.py test_project/models/my_enum.py test_project/models/named_one_of.py -test_project/models/named_one_of_union.py", +test_project/models/named_one_of_union.py +test_project/models/some_object.py", "README.md": "# Edge Cases @@ -17502,6 +17508,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *DefaultApi* | [**array_of_one_ofs**](docs/DefaultApi.md#array_of_one_ofs) | **POST** /array-of-one-ofs | *DefaultApi* | [**array_request_parameters**](docs/DefaultApi.md#array_request_parameters) | **GET** /array-request-parameters | +*DefaultApi* | [**dictionary**](docs/DefaultApi.md#dictionary) | **POST** /additional-properties | *DefaultApi* | [**inline_enum**](docs/DefaultApi.md#inline_enum) | **GET** /inline-enum | *DefaultApi* | [**inline_request_body**](docs/DefaultApi.md#inline_request_body) | **POST** /inline-request-body | *DefaultApi* | [**named_one_of**](docs/DefaultApi.md#named_one_of) | **POST** /named-one-of | @@ -17509,14 +17516,45 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AdditionalPropertiesResponse](docs/AdditionalPropertiesResponse.md) - [AnotherNamedOneOf](docs/AnotherNamedOneOf.md) - [ArrayOfOneOfs](docs/ArrayOfOneOfs.md) + - [Dictionary](docs/Dictionary.md) - [InlineEnum200Response](docs/InlineEnum200Response.md) - [InlineEnum200ResponseCategoryEnum](docs/InlineEnum200ResponseCategoryEnum.md) - [InlineRequestBodyRequestContent](docs/InlineRequestBodyRequestContent.md) - [MyEnum](docs/MyEnum.md) - [NamedOneOf](docs/NamedOneOf.md) - [NamedOneOfUnion](docs/NamedOneOfUnion.md) + - [SomeObject](docs/SomeObject.md) +", + "docs/AdditionalPropertiesResponse.md": "# AdditionalPropertiesResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dictionary_of_objects** | [**Dictionary**](Dictionary.md) | | [optional] +**dictionary_of_primitives** | **Dict[str, str]** | | [optional] + +## Example + +\`\`\`python +from test_project.models.additional_properties_response import AdditionalPropertiesResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesResponse from a JSON string +additional_properties_response_instance = AdditionalPropertiesResponse.from_json(json) +# print the JSON string representation of the object +print(AdditionalPropertiesResponse.to_json()) + +# convert the object into a dict +additional_properties_response_dict = additional_properties_response_instance.to_dict() +# create an instance of AdditionalPropertiesResponse from a dict +additional_properties_response_form_dict = additional_properties_response.from_dict(additional_properties_response_dict) +\`\`\` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + ", "docs/AnotherNamedOneOf.md": "# AnotherNamedOneOf @@ -17578,6 +17616,7 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**array_of_one_ofs**](DefaultApi.md#array_of_one_ofs) | **POST** /array-of-one-ofs | [**array_request_parameters**](DefaultApi.md#array_request_parameters) | **GET** /array-request-parameters | +[**dictionary**](DefaultApi.md#dictionary) | **POST** /additional-properties | [**inline_enum**](DefaultApi.md#inline_enum) | **GET** /inline-enum | [**inline_request_body**](DefaultApi.md#inline_request_body) | **POST** /inline-request-body | [**named_one_of**](DefaultApi.md#named_one_of) | **POST** /named-one-of | @@ -17700,6 +17739,56 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **dictionary** +> AdditionalPropertiesResponse dictionary() + + +### Example + +\`\`\`python +import time +import test_project +from test_project.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = test_project.Configuration( + host = "http://localhost" +) + +# Enter a context with an instance of the API client +with test_project.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = test_project.DefaultApi(api_client) + + try: + api_response = api_instance.dictionary() + print("The response of DefaultApi->dictionary:\\n") + pprint(api_response) + except ApiException as e: + print("Exception when calling DefaultApi->dictionary: %s\\n" % e) +\`\`\` + +### Parameters +This endpoint does not need any parameters. + +### Return type + +[**AdditionalPropertiesResponse**](AdditionalPropertiesResponse.md) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | ok | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **inline_enum** > InlineEnum200Response inline_enum() @@ -17906,6 +17995,32 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +", + "docs/Dictionary.md": "# Dictionary + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +\`\`\`python +from test_project.models.dictionary import Dictionary + +# TODO update the JSON string below +json = "{}" +# create an instance of Dictionary from a JSON string +dictionary_instance = Dictionary.from_json(json) +# print the JSON string representation of the object +print(Dictionary.to_json()) + +# convert the object into a dict +dictionary_dict = dictionary_instance.to_dict() +# create an instance of Dictionary from a dict +dictionary_form_dict = dictionary.from_dict(dictionary_dict) +\`\`\` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + ", "docs/InlineEnum200Response.md": "# InlineEnum200Response @@ -18036,6 +18151,33 @@ named_one_of_union_form_dict = named_one_of_union.from_dict(named_one_of_union_d \`\`\` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) +", + "docs/SomeObject.md": "# SomeObject + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**a** | **str** | | [optional] + +## Example + +\`\`\`python +from test_project.models.some_object import SomeObject + +# TODO update the JSON string below +json = "{}" +# create an instance of SomeObject from a JSON string +some_object_instance = SomeObject.from_json(json) +# print the JSON string representation of the object +print(SomeObject.to_json()) + +# convert the object into a dict +some_object_dict = some_object_instance.to_dict() +# create an instance of SomeObject from a dict +some_object_form_dict = some_object.from_dict(some_object_dict) +\`\`\` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + ", "poetry.toml": "# ~~ Generated by projen. To modify, edit .projenrc.py and run "npx projen". @@ -18105,14 +18247,17 @@ from test_project.exceptions import ApiAttributeError from test_project.exceptions import ApiException # import models into sdk package +from test_project.models.additional_properties_response import AdditionalPropertiesResponse from test_project.models.another_named_one_of import AnotherNamedOneOf from test_project.models.array_of_one_ofs import ArrayOfOneOfs +from test_project.models.dictionary import Dictionary from test_project.models.inline_enum200_response import InlineEnum200Response from test_project.models.inline_enum200_response_category_enum import InlineEnum200ResponseCategoryEnum from test_project.models.inline_request_body_request_content import InlineRequestBodyRequestContent from test_project.models.my_enum import MyEnum from test_project.models.named_one_of import NamedOneOf from test_project.models.named_one_of_union import NamedOneOfUnion +from test_project.models.some_object import SomeObject ", "test_project/api/__init__.py": "# flake8: noqa @@ -18143,6 +18288,7 @@ try: except ImportError: from typing_extensions import Annotated +from test_project.models.additional_properties_response import AdditionalPropertiesResponse from test_project.models.array_of_one_ofs import ArrayOfOneOfs from test_project.models.inline_enum200_response import InlineEnum200Response from test_project.models.inline_request_body_request_content import InlineRequestBodyRequestContent @@ -18769,6 +18915,241 @@ class DefaultApi: + @validate_call + def dictionary( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AdditionalPropertiesResponse: + """dictionary + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._dictionary_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AdditionalPropertiesResponse" + } + + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def dictionary_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AdditionalPropertiesResponse]: + """dictionary + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._dictionary_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AdditionalPropertiesResponse" + } + + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def dictionary_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """dictionary + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._dictionary_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AdditionalPropertiesResponse" + } + + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _dictionary_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header \`Accept\` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/additional-properties', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + @validate_call def inline_enum( self, @@ -19783,6 +20164,7 @@ T = TypeVar('T') class OperationConfig(Generic[T]): array_of_one_ofs: T array_request_parameters: T + dictionary: T inline_enum: T inline_request_body: T named_one_of: T @@ -19801,6 +20183,11 @@ OperationLookup = { "method": "GET", "contentTypes": ["application/json"] }, + "dictionary": { + "path": "/additional-properties", + "method": "POST", + "contentTypes": ["application/json"] + }, "inline_enum": { "path": "/inline-enum", "method": "GET", @@ -20199,7 +20586,122 @@ def array_request_parameters_handler(_handler: ArrayRequestParametersHandlerFunc body = {} interceptor_context = { - "operationId": "array_request_parameters", + "operationId": "array_request_parameters", + } + + chain = _build_handler_chain(all_interceptors, handler) + response = chain.next(ApiRequest( + request_parameters, + body, + event, + context, + interceptor_context, + ), **kwargs) + + response_headers = {** (response.headers or {}), **response_headers_for_status_code(response.status_code)} + response_body = '' + if response.body is None: + pass + elif response.status_code == 200: + response_body = response.body + + return { + 'statusCode': response.status_code, + 'headers': response_headers, + 'multiValueHeaders': response.multi_value_headers or {}, + 'body': response_body, + } + return wrapper + + # Support use as a decorator with no arguments, or with interceptor arguments + if callable(_handler): + return _handler_wrapper(_handler) + elif _handler is None: + return _handler_wrapper + else: + raise Exception("Positional arguments are not supported by array_request_parameters_handler.") + +class DictionaryRequestParameters(BaseModel): + """ + Query, path and header parameters for the Dictionary operation + """ + + class Config: + """Pydantic configuration""" + populate_by_name = True + validate_assignment = True + + def to_json(self) -> str: + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> DictionaryRequestParameters: + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + return self.model_dump(exclude={}, exclude_none=True) + + @classmethod + def from_dict(cls, obj: dict) -> DictionaryRequestParameters: + if obj is None: + return None + return DictionaryRequestParameters.model_validate(obj) + + +# Request body type (default to Any when no body parameters exist, or leave unchanged as str if it's a primitive type) +DictionaryRequestBody = Any + +Dictionary200OperationResponse = ApiResponse[Literal[200], AdditionalPropertiesResponse] + +DictionaryOperationResponses = Union[Dictionary200OperationResponse, ] + +# Request type for dictionary +DictionaryRequest = ApiRequest[DictionaryRequestParameters, DictionaryRequestBody] +DictionaryChainedRequest = ChainedApiRequest[DictionaryRequestParameters, DictionaryRequestBody] + +class DictionaryHandlerFunction(Protocol): + def __call__(self, input: DictionaryRequest, **kwargs) -> DictionaryOperationResponses: + ... + +DictionaryInterceptor = Callable[[DictionaryChainedRequest], DictionaryOperationResponses] + +def dictionary_handler(_handler: DictionaryHandlerFunction = None, interceptors: List[DictionaryInterceptor] = []): + """ + Decorator for an api handler for the dictionary operation, providing a typed interface for inputs and outputs + """ + def _handler_wrapper(handler: DictionaryHandlerFunction): + @wraps(handler) + def wrapper(event, context, additional_interceptors = [], **kwargs): + all_interceptors = additional_interceptors + interceptors + + raw_string_parameters = decode_request_parameters({ + **(event.get('pathParameters', {}) or {}), + **(event.get('queryStringParameters', {}) or {}), + **(event.get('headers', {}) or {}), + }) + raw_string_array_parameters = decode_request_parameters({ + **(event.get('multiValueQueryStringParameters', {}) or {}), + **(event.get('multiValueHeaders', {}) or {}), + }) + + def response_headers_for_status_code(status_code): + headers_for_status = {} + return headers_for_status + + request_parameters = None + try: + request_parameters = DictionaryRequestParameters.from_dict({ + }) + except Exception as e: + return { + 'statusCode': 400, + 'headers': {**response_headers_for_status_code(400), **extract_response_headers_from_interceptors(all_interceptors)}, + 'body': '{"message": "' + str(e) + '"}', + } + + body = {} + interceptor_context = { + "operationId": "dictionary", } chain = _build_handler_chain(all_interceptors, handler) @@ -20216,7 +20718,7 @@ def array_request_parameters_handler(_handler: ArrayRequestParametersHandlerFunc if response.body is None: pass elif response.status_code == 200: - response_body = response.body + response_body = response.body.to_json() return { 'statusCode': response.status_code, @@ -20232,7 +20734,7 @@ def array_request_parameters_handler(_handler: ArrayRequestParametersHandlerFunc elif _handler is None: return _handler_wrapper else: - raise Exception("Positional arguments are not supported by array_request_parameters_handler.") + raise Exception("Positional arguments are not supported by dictionary_handler.") class InlineEnumRequestParameters(BaseModel): """ @@ -20712,6 +21214,7 @@ OperationIdByMethodAndPath = { concat_method_and_path(method_and_path["method"], class HandlerRouterHandlers: array_of_one_ofs: Callable[[Dict, Any], Dict] array_request_parameters: Callable[[Dict, Any], Dict] + dictionary: Callable[[Dict, Any], Dict] inline_enum: Callable[[Dict, Any], Dict] inline_request_body: Callable[[Dict, Any], Dict] named_one_of: Callable[[Dict, Any], Dict] @@ -22284,14 +22787,112 @@ def try_catch_interceptor(request: ChainedApiRequest) -> ApiResponse: """ # noqa: E501 # import models into model package +from test_project.models.additional_properties_response import AdditionalPropertiesResponse from test_project.models.another_named_one_of import AnotherNamedOneOf from test_project.models.array_of_one_ofs import ArrayOfOneOfs +from test_project.models.dictionary import Dictionary from test_project.models.inline_enum200_response import InlineEnum200Response from test_project.models.inline_enum200_response_category_enum import InlineEnum200ResponseCategoryEnum from test_project.models.inline_request_body_request_content import InlineRequestBodyRequestContent from test_project.models.my_enum import MyEnum from test_project.models.named_one_of import NamedOneOf from test_project.models.named_one_of_union import NamedOneOfUnion +from test_project.models.some_object import SomeObject +", + "test_project/models/additional_properties_response.py": "# coding: utf-8 + +""" + Edge Cases + + No description provided + + The version of the OpenAPI document: 1.0.0 + + NOTE: This class is auto generated. + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json +from enum import Enum +from datetime import date, datetime +from typing import Any, List, Union, ClassVar, Dict, Optional, TYPE_CHECKING +from pydantic import Field, StrictStr, ValidationError, field_validator, BaseModel, SecretStr, StrictFloat, StrictInt, StrictBytes, StrictBool +from decimal import Decimal +from typing_extensions import Annotated, Literal +from test_project.models.dictionary import Dictionary +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class AdditionalPropertiesResponse(BaseModel): + """ + AdditionalPropertiesResponse + """ # noqa: E501 + dictionary_of_objects: Optional[Dictionary] = Field(default=None, alias="dictionaryOfObjects") + dictionary_of_primitives: Optional[Dict[str, StrictStr]] = Field(default=None, alias="dictionaryOfPrimitives") + __properties: ClassVar[List[str]] = ["dictionaryOfObjects", "dictionaryOfPrimitives"] + + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of AdditionalPropertiesResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + \`self.model_dump(by_alias=True)\`: + + * \`None\` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value \`None\` + are ignored. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + }, + exclude_none=True, + ) + # override the default output from pydantic by calling \`to_dict()\` of dictionary_of_objects + if self.dictionary_of_objects: + _dict['dictionaryOfObjects'] = self.dictionary_of_objects.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of AdditionalPropertiesResponse from a dict""" + + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "dictionaryOfObjects": Dictionary.from_dict(obj.get("dictionaryOfObjects")) if obj.get("dictionaryOfObjects") is not None else None, + "dictionaryOfPrimitives": obj.get("dictionaryOfPrimitives") + }) + return _obj + ", "test_project/models/another_named_one_of.py": "# coding: utf-8 @@ -22474,6 +23075,106 @@ class ArrayOfOneOfs(BaseModel): }) return _obj +", + "test_project/models/dictionary.py": "# coding: utf-8 + +""" + Edge Cases + + No description provided + + The version of the OpenAPI document: 1.0.0 + + NOTE: This class is auto generated. + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json +from enum import Enum +from datetime import date, datetime +from typing import Any, List, Union, ClassVar, Dict, Optional, TYPE_CHECKING +from pydantic import Field, StrictStr, ValidationError, field_validator, BaseModel, SecretStr, StrictFloat, StrictInt, StrictBytes, StrictBool +from decimal import Decimal +from typing_extensions import Annotated, Literal +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class Dictionary(BaseModel): + """ + Dictionary + """ # noqa: E501 + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = [] + + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of Dictionary from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + \`self.model_dump(by_alias=True)\`: + + * \`None\` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value \`None\` + are ignored. + * Fields in \`self.additional_properties\` are added to the output dict. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + "additional_properties", + }, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of Dictionary from a dict""" + + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + ", "test_project/models/inline_enum200_response.py": "# coding: utf-8 @@ -22982,6 +23683,95 @@ class NamedOneOfUnion(BaseModel): """Returns the string representation of the actual instance""" return pprint.pformat(self.model_dump()) +", + "test_project/models/some_object.py": "# coding: utf-8 + +""" + Edge Cases + + No description provided + + The version of the OpenAPI document: 1.0.0 + + NOTE: This class is auto generated. + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json +from enum import Enum +from datetime import date, datetime +from typing import Any, List, Union, ClassVar, Dict, Optional, TYPE_CHECKING +from pydantic import Field, StrictStr, ValidationError, field_validator, BaseModel, SecretStr, StrictFloat, StrictInt, StrictBytes, StrictBool +from decimal import Decimal +from typing_extensions import Annotated, Literal +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class SomeObject(BaseModel): + """ + SomeObject + """ # noqa: E501 + a: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["a"] + + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of SomeObject from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + \`self.model_dump(by_alias=True)\`: + + * \`None\` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value \`None\` + are ignored. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + }, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of SomeObject from a dict""" + + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "a": obj.get("a") + }) + return _obj + ", "test_project/py.typed": "", "test_project/response.py": "from typing import TypeVar, Generic, Dict, List diff --git a/packages/type-safe-api/test/scripts/generators/__snapshots__/typescript.test.ts.snap b/packages/type-safe-api/test/scripts/generators/__snapshots__/typescript.test.ts.snap index d08e86eb8..a9e4306ae 100644 --- a/packages/type-safe-api/test/scripts/generators/__snapshots__/typescript.test.ts.snap +++ b/packages/type-safe-api/test/scripts/generators/__snapshots__/typescript.test.ts.snap @@ -8237,14 +8237,17 @@ src/apis/DefaultApi.ts src/apis/index.ts src/models/index.ts src/models/model-utils.ts +src/models/AdditionalPropertiesResponse.ts src/models/AnotherNamedOneOf.ts src/models/ArrayOfOneOfs.ts +src/models/Dictionary.ts src/models/InlineEnum200Response.ts src/models/InlineEnum200ResponseCategoryEnum.ts src/models/InlineRequestBodyRequestContent.ts src/models/MyEnum.ts src/models/NamedOneOf.ts -src/models/NamedOneOfUnion.ts", +src/models/NamedOneOfUnion.ts +src/models/SomeObject.ts", "src/apis/DefaultApi.ts": "/* tslint:disable */ /* eslint-disable */ /** @@ -8260,6 +8263,7 @@ src/models/NamedOneOfUnion.ts", import * as runtime from '../runtime'; import type { + AdditionalPropertiesResponse, ArrayOfOneOfs, InlineEnum200Response, InlineRequestBodyRequestContent, @@ -8267,6 +8271,8 @@ import type { NamedOneOfUnion, } from '../models'; import { + AdditionalPropertiesResponseFromJSON, + AdditionalPropertiesResponseToJSON, ArrayOfOneOfsFromJSON, ArrayOfOneOfsToJSON, InlineEnum200ResponseFromJSON, @@ -8293,6 +8299,7 @@ export interface ArrayRequestParametersRequest { } + export interface InlineRequestBodyRequest { inlineRequestBodyRequestContent?: InlineRequestBodyRequestContent; } @@ -8401,6 +8408,35 @@ export class DefaultApi extends runtime.BaseAPI { await this.arrayRequestParametersRaw(requestParameters, initOverrides); } + /** + * + */ + async dictionaryRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + + const headerParameters: runtime.HTTPHeaders = {}; + + + + const response = await this.request({ + path: \`/additional-properties\`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => AdditionalPropertiesResponseFromJSON(jsonValue)); + } + + /** + * + */ + async dictionary(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.dictionaryRaw(initOverrides); + return await response.value(); + } + /** * */ @@ -8534,12 +8570,18 @@ export class DefaultApi extends runtime.BaseAPI { ", "src/apis/DefaultApi/OperationConfig.ts": "// Import models import { + AdditionalPropertiesResponse, + AdditionalPropertiesResponseFromJSON, + AdditionalPropertiesResponseToJSON, AnotherNamedOneOf, AnotherNamedOneOfFromJSON, AnotherNamedOneOfToJSON, ArrayOfOneOfs, ArrayOfOneOfsFromJSON, ArrayOfOneOfsToJSON, + Dictionary, + DictionaryFromJSON, + DictionaryToJSON, InlineEnum200Response, InlineEnum200ResponseFromJSON, InlineEnum200ResponseToJSON, @@ -8558,6 +8600,9 @@ import { NamedOneOfUnion, NamedOneOfUnionFromJSON, NamedOneOfUnionToJSON, + SomeObject, + SomeObjectFromJSON, + SomeObjectToJSON, } from '../../models'; // Import request parameter interfaces import { @@ -8573,6 +8618,7 @@ import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from "aws-lambda export interface OperationConfig { arrayOfOneOfs: T; arrayRequestParameters: T; + dictionary: T; inlineEnum: T; inlineRequestBody: T; namedOneOf: T; @@ -8591,6 +8637,11 @@ export const OperationLookup = { method: 'GET', contentTypes: ['application/json'], }, + dictionary: { + path: '/additional-properties', + method: 'POST', + contentTypes: ['application/json'], + }, inlineEnum: { path: '/inline-enum', method: 'GET', @@ -8727,7 +8778,7 @@ const extractResponseHeadersFromInterceptors = (interceptors: any[]): { [key: st }), {} as { [key: string]: string }); }; -export type OperationIds = | 'arrayOfOneOfs' | 'arrayRequestParameters' | 'inlineEnum' | 'inlineRequestBody' | 'namedOneOf' | 'reservedKeywords'; +export type OperationIds = | 'arrayOfOneOfs' | 'arrayRequestParameters' | 'dictionary' | 'inlineEnum' | 'inlineRequestBody' | 'namedOneOf' | 'reservedKeywords'; export type OperationApiGatewayProxyResult = APIGatewayProxyResult & { __operationId?: T }; // Api gateway lambda handler type @@ -9038,6 +9089,115 @@ export const arrayRequestParametersHandler = ( body: response.body ? marshal(response.statusCode, response.body) : '', }; }; +/** + * Path, Query and Header parameters for Dictionary + */ +export interface DictionaryRequestParameters { +} + +/** + * Request body parameter for Dictionary + */ +export type DictionaryRequestBody = never; + +export type Dictionary200OperationResponse = OperationResponse<200, AdditionalPropertiesResponse>; + +export type DictionaryOperationResponses = | Dictionary200OperationResponse ; + +// Type that the handler function provided to the wrapper must conform to +export type DictionaryHandlerFunction = LambdaHandlerFunction; +export type DictionaryChainedHandlerFunction = ChainedLambdaHandlerFunction; +export type DictionaryChainedRequestInput = ChainedRequestInput; + +/** + * Lambda handler wrapper to provide typed interface for the implementation of dictionary + */ +export const dictionaryHandler = ( + ...handlers: [DictionaryChainedHandlerFunction, ...DictionaryChainedHandlerFunction[]] +): OperationApiGatewayLambdaHandler<'dictionary'> => async (event: any, context: any, _callback?: any, additionalInterceptors: DictionaryChainedHandlerFunction[] = []): Promise => { + const operationId = "dictionary"; + + const rawSingleValueParameters = decodeRequestParameters({ + ...(event.pathParameters || {}), + ...(event.queryStringParameters || {}), + ...(event.headers || {}), + }) as { [key: string]: string | undefined }; + const rawMultiValueParameters = decodeRequestParameters({ + ...(event.multiValueQueryStringParameters || {}), + ...(event.multiValueHeaders || {}), + }) as { [key: string]: string[] | undefined }; + + const marshal = (statusCode: number, responseBody: any): string => { + let marshalledBody = responseBody; + switch(statusCode) { + case 200: + marshalledBody = JSON.stringify(AdditionalPropertiesResponseToJSON(marshalledBody)); + break; + default: + break; + } + + return marshalledBody; + }; + + const errorHeaders = (statusCode: number): { [key: string]: string } => { + let headers = {}; + + switch(statusCode) { + default: + break; + } + + return headers; + }; + + let requestParameters: DictionaryRequestParameters | undefined = undefined; + + try { + requestParameters = { + + }; + } catch (e: any) { + const res = { + statusCode: 400, + body: { message: e.message }, + headers: extractResponseHeadersFromInterceptors(handlers), + }; + return { + ...res, + headers: { + ...errorHeaders(res.statusCode), + ...res.headers, + }, + body: res.body ? marshal(res.statusCode, res.body) : '', + }; + } + + const demarshal = (bodyString: string): any => { + return {}; + }; + const body = parseBody(event.body, demarshal, ['application/json']) as DictionaryRequestBody; + + const chain = buildHandlerChain(...additionalInterceptors, ...handlers); + const response = await chain.next({ + input: { + requestParameters, + body, + }, + event, + context, + interceptorContext: { operationId }, + }); + + return { + ...response, + headers: { + ...errorHeaders(response.statusCode), + ...response.headers, + }, + body: response.body ? marshal(response.statusCode, response.body) : '', + }; +}; /** * Path, Query and Header parameters for InlineEnum */ @@ -9482,15 +9642,16 @@ export const reservedKeywordsHandler = ( export interface HandlerRouterHandlers { readonly arrayOfOneOfs: OperationApiGatewayLambdaHandler<'arrayOfOneOfs'>; readonly arrayRequestParameters: OperationApiGatewayLambdaHandler<'arrayRequestParameters'>; + readonly dictionary: OperationApiGatewayLambdaHandler<'dictionary'>; readonly inlineEnum: OperationApiGatewayLambdaHandler<'inlineEnum'>; readonly inlineRequestBody: OperationApiGatewayLambdaHandler<'inlineRequestBody'>; readonly namedOneOf: OperationApiGatewayLambdaHandler<'namedOneOf'>; readonly reservedKeywords: OperationApiGatewayLambdaHandler<'reservedKeywords'>; } -export type AnyOperationRequestParameters = | ArrayOfOneOfsRequestParameters| ArrayRequestParametersRequestParameters| InlineEnumRequestParameters| InlineRequestBodyRequestParameters| NamedOneOfRequestParameters| ReservedKeywordsRequestParameters; -export type AnyOperationRequestBodies = | ArrayOfOneOfsRequestBody| ArrayRequestParametersRequestBody| InlineEnumRequestBody| InlineRequestBodyRequestBody| NamedOneOfRequestBody| ReservedKeywordsRequestBody; -export type AnyOperationResponses = | ArrayOfOneOfsOperationResponses| ArrayRequestParametersOperationResponses| InlineEnumOperationResponses| InlineRequestBodyOperationResponses| NamedOneOfOperationResponses| ReservedKeywordsOperationResponses; +export type AnyOperationRequestParameters = | ArrayOfOneOfsRequestParameters| ArrayRequestParametersRequestParameters| DictionaryRequestParameters| InlineEnumRequestParameters| InlineRequestBodyRequestParameters| NamedOneOfRequestParameters| ReservedKeywordsRequestParameters; +export type AnyOperationRequestBodies = | ArrayOfOneOfsRequestBody| ArrayRequestParametersRequestBody| DictionaryRequestBody| InlineEnumRequestBody| InlineRequestBodyRequestBody| NamedOneOfRequestBody| ReservedKeywordsRequestBody; +export type AnyOperationResponses = | ArrayOfOneOfsOperationResponses| ArrayRequestParametersOperationResponses| DictionaryOperationResponses| InlineEnumOperationResponses| InlineRequestBodyOperationResponses| NamedOneOfOperationResponses| ReservedKeywordsOperationResponses; export interface HandlerRouterProps< RequestParameters, @@ -9834,6 +9995,86 @@ export const buildTryCatchInterceptor = ; +} + + +/** + * Check if a given object implements the Dictionary interface. + */ +export function instanceOfDictionary(value: object): boolean { + let isInstance = true; + return isInstance; +} + +export function DictionaryFromJSON(json: any): Dictionary { + return DictionaryFromJSONTyped(json, false); +} + +export function DictionaryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Dictionary { + return json; +} + +export function DictionaryToJSON(value?: Dictionary | null): any { + return value; +} + ", "src/models/InlineEnum200Response.ts": "/* tslint:disable */ /* eslint-disable */ @@ -10323,17 +10616,85 @@ export function NamedOneOfUnionToJSON(value?: NamedOneOfUnion | null): any { }; } +", + "src/models/SomeObject.ts": "/* tslint:disable */ +/* eslint-disable */ +/** + * Edge Cases + * + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ +import { exists, mapValues } from './model-utils'; + +/** + * + * @export + * @interface SomeObject + */ +export interface SomeObject { + /** + * + * @type {string} + * @memberof SomeObject + */ + a?: string; +} + + +/** + * Check if a given object implements the SomeObject interface. + */ +export function instanceOfSomeObject(value: object): boolean { + let isInstance = true; + return isInstance; +} + +export function SomeObjectFromJSON(json: any): SomeObject { + return SomeObjectFromJSONTyped(json, false); +} + +export function SomeObjectFromJSONTyped(json: any, ignoreDiscriminator: boolean): SomeObject { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'a': !exists(json, 'a') ? undefined : json['a'], + }; +} + +export function SomeObjectToJSON(value?: SomeObject | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'a': value.a, + }; +} + ", "src/models/index.ts": "/* tslint:disable */ /* eslint-disable */ +export * from './AdditionalPropertiesResponse'; export * from './AnotherNamedOneOf'; export * from './ArrayOfOneOfs'; +export * from './Dictionary'; export * from './InlineEnum200Response'; export * from './InlineEnum200ResponseCategoryEnum'; export * from './InlineRequestBodyRequestContent'; export * from './MyEnum'; export * from './NamedOneOf'; export * from './NamedOneOfUnion'; +export * from './SomeObject'; ", "src/models/model-utils.ts": "/* tslint:disable */ /* eslint-disable */