From 8b2b96e61eb58cb4602c8f89577bbd3f53b95e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Gate=C3=B1o?= <50761868+ajgateno@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:54:55 -0500 Subject: [PATCH] fix(java): Fix usage of cursor pagination causing endpoint return type to be void (#5708) * fix(java): Fix usage of cursor pagination causing endpoint return type to be void * Add test case * Run seed against new test case * Allow objects with nonempty path to be used for cursor pagination * run seed * Add a utility to find the property type of the desired property within the request body * Add new test case just for deep cursor path * run new fixture * run the fixture * Refactor next page number offset pagination for easier overriding * Fix fixture * Add more test cases * Add test case as expected failure * test udpate * Handle different zero value possibilities for next snippet * Fix nits * Change test definition * Delete pagination gens * delete long snapshots * Delete all complex * Rerun pagination tests --------- Co-authored-by: Alberto Co-authored-by: fern-support <115122769+fern-api[bot]@users.noreply.github.com> --- .../endpoint/AbstractEndpointWriter.java | 276 ++- .../endpoint/EnrichedCursorPathGetter.java | 32 + .../endpoint/EnrichedCursorPathItem.java | 34 + .../endpoint/EnrichedCursorPathSetter.java | 17 + .../endpoint/OnlyRequestEndpointWriter.java | 3 + .../endpoint/PaginationPathUtils.java | 586 ++++++ .../WrappedRequestEndpointWriter.java | 3 +- .../generators/endpoint/ZeroValueUtils.java | 204 ++ .../type_deep-cursor-path_A.json | 62 + .../type_deep-cursor-path_B.json | 46 + .../type_deep-cursor-path_C.json | 34 + .../type_deep-cursor-path_D.json | 17 + ..._deep-cursor-path_IndirectionRequired.json | 26 + .../type_deep-cursor-path_InlineA.json | 62 + .../type_deep-cursor-path_InlineB.json | 46 + .../type_deep-cursor-path_InlineC.json | 34 + .../type_deep-cursor-path_InlineD.json | 17 + .../type_deep-cursor-path_MainRequired.json | 39 + .../type_deep-cursor-path_Response.json | 26 + .../pagination/type_complex_Conversation.json | 13 + .../pagination/type_complex_CursorPages.json | 76 + ...e_complex_MultipleFilterSearchRequest.json | 128 ++ ...x_MultipleFilterSearchRequestOperator.json | 8 + ...plex_MultipleFilterSearchRequestValue.json | 118 ++ ...complex_PaginatedConversationResponse.json | 121 ++ .../type_complex_SearchRequest.json | 156 ++ .../type_complex_SearchRequestQuery.json | 112 ++ ...ype_complex_SingleFilterSearchRequest.json | 53 + ...lex_SingleFilterSearchRequestOperator.json | 16 + .../type_complex_StartingAfterPaging.json | 23 + .../java-pagination-deep-cursor-path.json | 1417 ++++++++++++++ .../__test__/test-definitions/pagination.json | 1728 +++++++++++++++++ .../java-pagination-deep-cursor-path.json | 517 +++++ .../__test__/__snapshots__/pagination.json | 494 +++++ .../pagination/.mock/definition/complex.yml | 112 ++ .../model/complex/Conversation.java | 86 + .../pagination/model/complex/CursorPages.java | 158 ++ .../complex/MultipleFilterSearchRequest.java | 103 + .../MultipleFilterSearchRequestOperator.java | 24 + .../MultipleFilterSearchRequestValue.java | 101 + .../PaginatedConversationResponse.java | 161 ++ .../model/complex/SearchRequest.java | 116 ++ .../model/complex/SearchRequestQuery.java | 94 + .../complex/SingleFilterSearchRequest.java | 125 ++ .../SingleFilterSearchRequestOperator.java | 40 + .../model/complex/StartingAfterPaging.java | 116 ++ .../.github/workflows/ci.yml | 61 + .../.gitignore | 24 + .../.mock/definition/api.yml | 2 + .../.mock/definition/deep-cursor-path.yml | 87 + .../.mock/fern.config.json | 1 + .../.mock/generators.yml | 2 + .../build.gradle | 101 + .../sample-app/build.gradle | 19 + .../sample-app/src/main/java/sample/App.java | 13 + .../settings.gradle | 3 + .../snippet-templates.json | 0 .../snippet.json | 0 .../SeedDeepCursorPathClient.java | 28 + .../SeedDeepCursorPathClientBuilder.java | 31 + .../deepCursorPath/core/ClientOptions.java | 118 ++ .../core/DateTimeDeserializer.java | 55 + .../seed/deepCursorPath/core/Environment.java | 20 + .../seed/deepCursorPath/core/FileStream.java | 60 + .../core/InputStreamRequestBody.java | 79 + .../seed/deepCursorPath/core/MediaTypes.java | 13 + .../deepCursorPath/core/ObjectMappers.java | 36 + .../deepCursorPath/core/RequestOptions.java | 58 + .../core/ResponseBodyInputStream.java | 45 + .../core/ResponseBodyReader.java | 44 + .../deepCursorPath/core/RetryInterceptor.java | 78 + .../core/SeedDeepCursorPathApiException.java | 45 + .../core/SeedDeepCursorPathException.java | 17 + .../com/seed/deepCursorPath/core/Stream.java | 97 + .../seed/deepCursorPath/core/Suppliers.java | 23 + .../core/pagination/BasePage.java | 24 + .../core/pagination/SyncPage.java | 24 + .../core/pagination/SyncPagingIterable.java | 61 + .../deepcursorpath/DeepCursorPathClient.java | 220 +++ .../resources/deepcursorpath/types/A.java | 95 + .../resources/deepcursorpath/types/B.java | 102 + .../resources/deepcursorpath/types/C.java | 95 + .../resources/deepcursorpath/types/D.java | 95 + .../types/IndirectionRequired.java | 126 ++ .../deepcursorpath/types/InlineA.java | 95 + .../deepcursorpath/types/InlineB.java | 102 + .../deepcursorpath/types/InlineC.java | 95 + .../deepcursorpath/types/InlineD.java | 95 + .../deepcursorpath/types/MainRequired.java | 102 + .../deepcursorpath/types/Response.java | 125 ++ .../com/seed/deepCursorPath/TestClient.java | 11 + .../pagination/.mock/definition/complex.yml | 112 ++ .../seed/pagination/SeedPaginationClient.java | 8 + .../resources/complex/ComplexClient.java | 95 + .../resources/complex/types/Conversation.java | 102 + .../resources/complex/types/CursorPages.java | 174 ++ .../types/MultipleFilterSearchRequest.java | 120 ++ .../MultipleFilterSearchRequestOperator.java | 24 + .../MultipleFilterSearchRequestValue.java | 101 + .../types/PaginatedConversationResponse.java | 179 ++ .../complex/types/SearchRequest.java | 135 ++ .../complex/types/SearchRequestQuery.java | 94 + .../types/SingleFilterSearchRequest.java | 143 ++ .../SingleFilterSearchRequestOperator.java | 40 + .../complex/types/StartingAfterPaging.java | 131 ++ .../resources/users/UsersClient.java | 56 +- seed/java-sdk/seed.yml | 3 + .../definition/api.yml | 2 + .../definition/deep-cursor-path.yml | 87 + .../generators.yml | 2 + .../apis/pagination/definition/complex.yml | 112 ++ 111 files changed, 12034 insertions(+), 93 deletions(-) create mode 100644 generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathGetter.java create mode 100644 generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathItem.java create mode 100644 generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathSetter.java create mode 100644 generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/PaginationPathUtils.java create mode 100644 generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/ZeroValueUtils.java create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_A.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_B.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_C.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_D.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_IndirectionRequired.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineA.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineB.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineC.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineD.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_MainRequired.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_Response.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_Conversation.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_CursorPages.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequest.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequestOperator.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequestValue.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_PaginatedConversationResponse.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SearchRequest.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SearchRequestQuery.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SingleFilterSearchRequest.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SingleFilterSearchRequestOperator.json create mode 100644 packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_StartingAfterPaging.json create mode 100644 packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions/java-pagination-deep-cursor-path.json create mode 100644 packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/java-pagination-deep-cursor-path.json create mode 100644 seed/java-model/pagination/.mock/definition/complex.yml create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/Conversation.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/CursorPages.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequest.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequestOperator.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequestValue.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/PaginatedConversationResponse.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SearchRequest.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SearchRequestQuery.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SingleFilterSearchRequest.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SingleFilterSearchRequestOperator.java create mode 100644 seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/StartingAfterPaging.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.github/workflows/ci.yml create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.gitignore create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/definition/api.yml create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/definition/deep-cursor-path.yml create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/fern.config.json create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/generators.yml create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/build.gradle create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/sample-app/build.gradle create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/sample-app/src/main/java/sample/App.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/settings.gradle create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/snippet-templates.json create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/snippet.json create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/SeedDeepCursorPathClient.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/SeedDeepCursorPathClientBuilder.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ClientOptions.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/DateTimeDeserializer.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Environment.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/FileStream.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/InputStreamRequestBody.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/MediaTypes.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ObjectMappers.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/RequestOptions.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ResponseBodyInputStream.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ResponseBodyReader.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/RetryInterceptor.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/SeedDeepCursorPathApiException.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/SeedDeepCursorPathException.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Stream.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Suppliers.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/BasePage.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/SyncPage.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/SyncPagingIterable.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/DeepCursorPathClient.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/A.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/B.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/C.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/D.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/IndirectionRequired.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineA.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineB.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineC.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineD.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/MainRequired.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/Response.java create mode 100644 seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/test/java/com/seed/deepCursorPath/TestClient.java create mode 100644 seed/java-sdk/pagination/.mock/definition/complex.yml create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/ComplexClient.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/Conversation.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/CursorPages.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequest.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequestOperator.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequestValue.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/PaginatedConversationResponse.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SearchRequest.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SearchRequestQuery.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SingleFilterSearchRequest.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SingleFilterSearchRequestOperator.java create mode 100644 seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/StartingAfterPaging.java create mode 100644 test-definitions/fern/apis/java-pagination-deep-cursor-path/definition/api.yml create mode 100644 test-definitions/fern/apis/java-pagination-deep-cursor-path/definition/deep-cursor-path.yml create mode 100644 test-definitions/fern/apis/java-pagination-deep-cursor-path/generators.yml create mode 100644 test-definitions/fern/apis/pagination/definition/complex.yml diff --git a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/AbstractEndpointWriter.java b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/AbstractEndpointWriter.java index 185bccc4b55..3fe03e43316 100644 --- a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/AbstractEndpointWriter.java +++ b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/AbstractEndpointWriter.java @@ -73,6 +73,8 @@ public abstract class AbstractEndpointWriter { public static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; public static final String REQUEST_BUILDER_NAME = "_requestBuilder"; public static final String REQUEST_OPTIONS_PARAMETER_NAME = "requestOptions"; + private static final String INTEGER_ONE = "1"; + private static final String DECIMAL_ONE = "1.0"; private final HttpService httpService; private final HttpEndpoint httpEndpoint; private final GeneratedClientOptions generatedClientOptions; @@ -777,10 +779,6 @@ public JsonResponseBodyWithProperty _visitUnknown(Object unknownType) { httpEndpoint.getPagination().get().visit(new Visitor() { @Override public Void visitCursor(CursorPagination cursor) { - if (cursor.getPage().getPropertyPath().isPresent() - && !cursor.getPage().getPropertyPath().get().isEmpty()) { - return null; - } SnippetAndResultType nextSnippet = getNestedPropertySnippet( cursor.getNext().getPropertyPath(), cursor.getNext().getProperty(), @@ -820,18 +818,52 @@ public String _visitUnknown(Object o) { throw new IllegalArgumentException("Unknown request property value type."); } }); + + String propertyOverrideOnRequest = builderStartingAfterProperty; + String propertyOverrideValueOnRequest = getStartingAfterVariableName(); + + if (cursor.getPage().getPropertyPath().isPresent() + && !cursor.getPage().getPropertyPath().get().isEmpty()) { + List setters = PaginationPathUtils.getPathSetters( + cursor.getPage().getPropertyPath().get(), + httpEndpoint, + clientGeneratorContext, + requestParameterSpec.name, + propertyOverrideOnRequest, + propertyOverrideValueOnRequest); + setters.stream() + .map(EnrichedCursorPathSetter::setter) + .forEach(httpResponseBuilder::addStatement); + + if (!setters.isEmpty()) { + EnrichedCursorPathGetter propertyOverrideGetter = + setters.get(setters.size() - 1).getter(); + propertyOverrideOnRequest = propertyOverrideGetter.propertyName(); + propertyOverrideValueOnRequest = propertyOverrideGetter.propertyName(); + + if (!propertyOverrideGetter.pathItem().optional() + && propertyOverrideGetter.optional()) { + propertyOverrideValueOnRequest += ".get()"; + } + } else { + throw new IllegalStateException( + "There should be at least one setter if the path is nonempty"); + } + } + httpResponseBuilder.addStatement( "$T $L = $T.builder().from($L).$L($L).build()", requestParameterSpec.type, getNextRequestVariableName(), requestParameterSpec.type, requestParameterSpec.name, - builderStartingAfterProperty, - getStartingAfterVariableName()); + propertyOverrideOnRequest, + propertyOverrideValueOnRequest); SnippetAndResultType resultSnippet = getNestedPropertySnippet( cursor.getResults().getPropertyPath(), cursor.getResults().getProperty(), body.getResponseBodyType()); + CodeBlock resultBlock = CodeBlock.builder() .add( "$T $L = $L", @@ -841,10 +873,31 @@ public String _visitUnknown(Object o) { .add(resultSnippet.codeBlock) .build(); httpResponseBuilder.addStatement(resultBlock); + + CodeBlock hasNextPageBlock; + + if (nextSnippet.typeReference.getContainer().isPresent()) { + if (nextSnippet.typeReference.getContainer().get().isOptional()) { + hasNextPageBlock = CodeBlock.of("$L.isPresent()", getStartingAfterVariableName()); + } else { + throw new IllegalStateException( + "Found non-optional container as next page token. This should be impossible " + + "due to fern check validation."); + } + } else if (nextSnippet.typeReference.getPrimitive().isPresent()) { + hasNextPageBlock = ZeroValueUtils.isNonzeroValue( + getStartingAfterVariableName(), + nextSnippet.typeReference.getPrimitive().get()); + } else { + throw new IllegalStateException( + "Found non-optional, non-primitive as next page token. This should be impossible " + + "due to fern check validation."); + } + httpResponseBuilder.addStatement( - "return new $T<>($L.isPresent(), $L, () -> $L($L))", + "return new $T<>($L, $L, () -> $L($L))", pagerClassName, - getStartingAfterVariableName(), + hasNextPageBlock, getResultVariableName(), endpointName, methodParameters); @@ -865,10 +918,6 @@ public String _visitUnknown(Object o) { @Override public Void visitOffset(OffsetPagination offset) { - if (offset.getPage().getPropertyPath().isPresent() - && !offset.getPage().getPropertyPath().get().isEmpty()) { - return null; - } com.fern.ir.model.types.TypeReference pageType = offset.getPage() .getProperty() .visit(new RequestPropertyValue.Visitor() { @@ -890,82 +939,111 @@ public com.fern.ir.model.types.TypeReference _visitUnknown(Object o) { } }); Boolean pageIsOptional = pageType.visit(new TypeReferenceIsOptional(true)); + + String newNumberFieldNamePascal = offset.getPage() + .getProperty() + .visit(new RequestPropertyValue.Visitor() { + + @Override + public String visitQuery(QueryParameter queryParameter) { + return queryParameter + .getName() + .getName() + .getPascalCase() + .getUnsafeName(); + } + + @Override + public String visitBody(ObjectProperty objectProperty) { + return objectProperty + .getName() + .getName() + .getPascalCase() + .getUnsafeName(); + } + + @Override + public String _visitUnknown(Object o) { + throw new IllegalArgumentException("Unknown request property value type."); + } + }); + + CodeBlock newNumberGetter = + CodeBlock.of("$L.get$L()", requestParameterSpec.name, newNumberFieldNamePascal); + boolean numberGetterOptional = false; + + if (offset.getPage().getPropertyPath().isPresent() + && !offset.getPage().getPropertyPath().get().isEmpty()) { + // NOTE: We don't care about the build-after property names because we're not going to + // use the setter--just the getter. + List setters = PaginationPathUtils.getPathSetters( + offset.getPage().getPropertyPath().get(), + httpEndpoint, + clientGeneratorContext, + requestParameterSpec.name, + "", + ""); + + if (setters.isEmpty()) { + throw new IllegalStateException( + "There should be at least one setter if the path is nonempty"); + } + + // The 0th getter is what we want here because it contains the pagination index as a + // property by definition of the path in the IR. + EnrichedCursorPathGetter getter = setters.get(0).getter(); + if (getter.optional()) { + if (pageIsOptional) { + newNumberGetter = CodeBlock.of( + "$L.flatMap($T::get$L)", + getter.getter(), + getter.typeName(), + newNumberFieldNamePascal); + } else { + newNumberGetter = CodeBlock.of( + "$L.map($T::get$L).get()", + getter.getter(), + getter.typeName(), + newNumberFieldNamePascal); + } + } else { + newNumberGetter = CodeBlock.of("$L.get$L", getter.getter(), newNumberFieldNamePascal); + } + } + + com.fern.ir.model.types.TypeReference numberType = pageType.getContainer() + .map(containerType -> containerType.visit(new ContainerTypeToUnderlyingType())) + .orElse(pageType); + TypeName numberTypeName = + clientGeneratorContext.getPoetTypeNameMapper().convertToTypeName(true, numberType); + + String one = INTEGER_ONE; + if (numberTypeName.equals(TypeName.FLOAT) || numberTypeName.equals(TypeName.DOUBLE)) { + one = DECIMAL_ONE; + } + if (pageIsOptional) { - com.fern.ir.model.types.TypeReference numberType = - pageType.getContainer().get().visit(new ContainerTypeToUnderlyingType()); httpResponseBuilder.addStatement(CodeBlock.of( - "$T $L = $L.get$L().map(page -> page + 1).orElse(1)", - clientGeneratorContext - .getPoetTypeNameMapper() - .convertToTypeName(true, numberType), + "$T $L = $L.map(page -> page + $L).orElse($L)", + numberTypeName, getNewPageNumberVariableName(), - requestParameterSpec.name, - offset.getPage().getProperty().visit(new RequestPropertyValue.Visitor() { - - @Override - public String visitQuery(QueryParameter queryParameter) { - return queryParameter - .getName() - .getName() - .getPascalCase() - .getUnsafeName(); - } - - @Override - public String visitBody(ObjectProperty objectProperty) { - return objectProperty - .getName() - .getName() - .getPascalCase() - .getUnsafeName(); - } - - @Override - public String _visitUnknown(Object o) { - throw new IllegalArgumentException("Unknown request property value type."); - } - }))); + newNumberGetter, + one, + one)); } else { httpResponseBuilder.addStatement(CodeBlock.of( - "$T $L = $L.get$L() + 1", + "$T $L = $L + $L", clientGeneratorContext .getPoetTypeNameMapper() .convertToTypeName(true, pageType), getNewPageNumberVariableName(), - requestParameterSpec.name, - offset.getPage().getProperty().visit(new RequestPropertyValue.Visitor() { - - @Override - public String visitQuery(QueryParameter queryParameter) { - return queryParameter - .getName() - .getName() - .getPascalCase() - .getUnsafeName(); - } - - @Override - public String visitBody(ObjectProperty objectProperty) { - return objectProperty - .getName() - .getName() - .getPascalCase() - .getUnsafeName(); - } - - @Override - public String _visitUnknown(Object o) { - throw new IllegalArgumentException("Unknown request property value type."); - } - }))); + newNumberGetter, + one)); } - httpResponseBuilder.addStatement( - "$T $L = $T.builder().from($L).$L($L).build()", - requestParameterSpec.type, - getNextRequestVariableName(), - requestParameterSpec.type, - requestParameterSpec.name, - offset.getPage().getProperty().visit(new RequestPropertyValue.Visitor() { + + String propertyOverrideOnRequest = offset.getPage() + .getProperty() + .visit(new RequestPropertyValue.Visitor() { @Override public String visitQuery(QueryParameter queryParameter) { @@ -989,8 +1067,46 @@ public String visitBody(ObjectProperty objectProperty) { public String _visitUnknown(Object o) { throw new IllegalArgumentException("Unknown request property value type."); } - }), - getNewPageNumberVariableName()); + }); + String propertyOverrideValueOnRequest = getNewPageNumberVariableName(); + + if (offset.getPage().getPropertyPath().isPresent() + && !offset.getPage().getPropertyPath().get().isEmpty()) { + List setters = PaginationPathUtils.getPathSetters( + offset.getPage().getPropertyPath().get(), + httpEndpoint, + clientGeneratorContext, + requestParameterSpec.name, + propertyOverrideOnRequest, + propertyOverrideValueOnRequest); + setters.stream() + .map(EnrichedCursorPathSetter::setter) + .forEach(httpResponseBuilder::addStatement); + + if (!setters.isEmpty()) { + EnrichedCursorPathGetter propertyOverrideGetter = + setters.get(setters.size() - 1).getter(); + propertyOverrideOnRequest = propertyOverrideGetter.propertyName(); + propertyOverrideValueOnRequest = propertyOverrideGetter.propertyName(); + + if (!propertyOverrideGetter.pathItem().optional() + && propertyOverrideGetter.optional()) { + propertyOverrideValueOnRequest += ".get()"; + } + } else { + throw new IllegalStateException( + "There should be at least one setter if the path is nonempty"); + } + } + + httpResponseBuilder.addStatement( + "$T $L = $T.builder().from($L).$L($L).build()", + requestParameterSpec.type, + getNextRequestVariableName(), + requestParameterSpec.type, + requestParameterSpec.name, + propertyOverrideOnRequest, + propertyOverrideValueOnRequest); SnippetAndResultType resultSnippet = getNestedPropertySnippet( offset.getResults().getPropertyPath(), diff --git a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathGetter.java b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathGetter.java new file mode 100644 index 00000000000..220a83dada0 --- /dev/null +++ b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathGetter.java @@ -0,0 +1,32 @@ +package com.fern.java.client.generators.endpoint; + +import com.squareup.javapoet.CodeBlock; +import com.squareup.javapoet.TypeName; +import java.util.Optional; +import org.immutables.value.Value; + +// TODO(ajgateno): This will be necessary until the required IR changes include more information about the path +@Value.Immutable +public interface EnrichedCursorPathGetter { + + EnrichedCursorPathItem pathItem(); + + CodeBlock getter(); + + TypeName typeName(); + + Optional previous(); + + @Value.Default + default boolean optional() { + return false; + } + + default String propertyName() { + return pathItem().name().getCamelCase().getSafeName(); + } + + static ImmutableEnrichedCursorPathGetter.Builder builder() { + return ImmutableEnrichedCursorPathGetter.builder(); + } +} diff --git a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathItem.java b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathItem.java new file mode 100644 index 00000000000..ce2c458ab9c --- /dev/null +++ b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathItem.java @@ -0,0 +1,34 @@ +package com.fern.java.client.generators.endpoint; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fern.ir.model.commons.Name; +import org.immutables.value.Value; + +// TODO(ajgateno): This will be necessary until the required IR changes include more information about the path +@Value.Immutable +@JsonSerialize(as = ImmutableEnrichedCursorPathItem.class) +@JsonDeserialize(as = ImmutableEnrichedCursorPathItem.class) +public interface EnrichedCursorPathItem { + + @JsonProperty("name") + Name name(); + + @Value.Default + @JsonProperty("optional") + default boolean optional() { + return false; + } + + // TODO(ajgateno): Check for wrapped aliases and add a .value to getter if necessary + @Value.Default + @JsonProperty("alias") + default boolean alias() { + return false; + } + + static ImmutableEnrichedCursorPathItem.Builder builder() { + return ImmutableEnrichedCursorPathItem.builder(); + } +} diff --git a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathSetter.java b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathSetter.java new file mode 100644 index 00000000000..9f4e87a42b1 --- /dev/null +++ b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/EnrichedCursorPathSetter.java @@ -0,0 +1,17 @@ +package com.fern.java.client.generators.endpoint; + +import com.squareup.javapoet.CodeBlock; +import org.immutables.value.Value; + +// TODO(ajgateno): This will be necessary until the required IR changes include more information about the path +@Value.Immutable +public interface EnrichedCursorPathSetter { + + EnrichedCursorPathGetter getter(); + + CodeBlock setter(); + + static ImmutableEnrichedCursorPathSetter.Builder builder() { + return ImmutableEnrichedCursorPathSetter.builder(); + } +} diff --git a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/OnlyRequestEndpointWriter.java b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/OnlyRequestEndpointWriter.java index 9c481c9c85f..5323838daa7 100644 --- a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/OnlyRequestEndpointWriter.java +++ b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/OnlyRequestEndpointWriter.java @@ -194,6 +194,9 @@ public CodeBlock getInitializeRequestCodeBlock( @Override public Void visitTypeReference(HttpRequestBodyReference typeReference) { builder.add(".addHeader($S, $S)\n", AbstractEndpointWriter.CONTENT_TYPE_HEADER, contentType); + AbstractEndpointWriter.responseContentType(httpEndpoint.getResponse()) + .ifPresent(responseContentType -> builder.add( + ".addHeader($S, $S)\n", AbstractEndpointWriter.ACCEPT_HEADER, contentType)); return null; } diff --git a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/PaginationPathUtils.java b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/PaginationPathUtils.java new file mode 100644 index 00000000000..ecda3fd9b4c --- /dev/null +++ b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/PaginationPathUtils.java @@ -0,0 +1,586 @@ +package com.fern.java.client.generators.endpoint; + +import com.fern.ir.model.commons.Name; +import com.fern.ir.model.http.BytesRequest; +import com.fern.ir.model.http.FileUploadRequest; +import com.fern.ir.model.http.HttpEndpoint; +import com.fern.ir.model.http.HttpRequestBody; +import com.fern.ir.model.http.HttpRequestBodyReference; +import com.fern.ir.model.http.InlinedRequestBody; +import com.fern.ir.model.http.InlinedRequestBodyProperty; +import com.fern.ir.model.types.ContainerType; +import com.fern.ir.model.types.Literal; +import com.fern.ir.model.types.MapType; +import com.fern.ir.model.types.NamedType; +import com.fern.ir.model.types.ObjectProperty; +import com.fern.ir.model.types.ObjectTypeDeclaration; +import com.fern.ir.model.types.PrimitiveType; +import com.fern.ir.model.types.TypeDeclaration; +import com.fern.ir.model.types.TypeReference; +import com.fern.java.AbstractGeneratorContext; +import com.squareup.javapoet.ClassName; +import com.squareup.javapoet.CodeBlock; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeName; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class PaginationPathUtils { + + public static Optional getPropertyTypeFromRequest( + HttpEndpoint httpEndpoint, Name desiredPropertyName, AbstractGeneratorContext generatorContext) { + if (httpEndpoint.getRequestBody().isEmpty()) { + return Optional.empty(); + } + + HttpRequestBody body = httpEndpoint.getRequestBody().get(); + return body.visit(new TypeReferenceFinder(desiredPropertyName, generatorContext)); + } + + public static Optional getPropertyFromProperty( + TypeReference typeReference, Name desiredPropertyName, AbstractGeneratorContext generatorContext) { + Optional maybeDeclaration = typeReference.visit(new TypeReferenceResolver(generatorContext)); + + if (maybeDeclaration.isEmpty()) { + return Optional.empty(); + } + + TypeDeclaration declaration = maybeDeclaration.get(); + Optional maybeObjectDeclaration = + declaration.getShape().getObject(); + + if (maybeObjectDeclaration.isEmpty()) { + return Optional.empty(); + } + + ObjectTypeDeclaration objectDeclaration = maybeObjectDeclaration.get(); + + Optional maybeFoundExtended = objectDeclaration.getExtendedProperties().stream() + .flatMap(List::stream) + .filter(prop -> prop.getName() + .getName() + .getCamelCase() + .getSafeName() + .equals(desiredPropertyName.getCamelCase().getSafeName())) + .map(ObjectProperty::getValueType) + .findAny(); + + if (maybeFoundExtended.isPresent()) { + return maybeFoundExtended; + } + + return objectDeclaration.getProperties().stream() + .filter(prop -> prop.getName() + .getName() + .getCamelCase() + .getSafeName() + .equals(desiredPropertyName.getCamelCase().getSafeName())) + .map(ObjectProperty::getValueType) + .findAny(); + } + + public static Optional enriched(Name name, TypeReference pathPropertyType) { + return pathPropertyType.visit(new TypeReferenceEnricher(name)); + } + + public static Optional unboxedTypeName( + AbstractGeneratorContext generatorContext, TypeReference reference) { + return reference.visit(new UnboxedTypeNameGetter(generatorContext, reference)); + } + + public static List getPathSetters( + List propertyPath, + HttpEndpoint httpEndpoint, + AbstractGeneratorContext generatorContext, + String requestParameterSpecName, + String propertyOverrideOnRequest, + String propertyOverrideValueOnRequest) { + List result = new ArrayList<>(); + + List enrichedItems = new ArrayList<>(); + Optional curr = + getPropertyTypeFromRequest(httpEndpoint, propertyPath.get(0), generatorContext); + Map referencesByName = new HashMap<>(); + curr.map(curr_ -> referencesByName.put(propertyPath.get(0), curr_)); + + curr.flatMap(curr_ -> enriched(propertyPath.get(0), curr_)).ifPresent(enrichedItems::add); + + for (Name name : propertyPath.subList(1, propertyPath.size())) { + if (curr.isEmpty()) { + break; + } + curr = getPropertyFromProperty(curr.get(), name, generatorContext); + curr.map(curr_ -> referencesByName.put(name, curr_)); + curr.flatMap(curr_ -> enriched(name, curr_)).ifPresent(enrichedItems::add); + } + + List getters = new ArrayList<>(); + getters.add(CodeBlock.builder().add("$L", requestParameterSpecName).build()); + CodeBlock getter = getters.get(0); + boolean optional = false; + String prevName = requestParameterSpecName; + + Map gettersAreOptional = new HashMap<>(); + + for (EnrichedCursorPathItem enriched : enrichedItems) { + if (optional) { + // TODO(ajgateno): Make sure we're using the actual getter names the same way + // they're obtained in the object generator. + if (enriched.optional()) { + getter = getter.toBuilder() + .add( + ".flatMap($L::get$L)", + prevName, + enriched.name().getPascalCase().getSafeName()) + .build(); + } else { + getter = getter.toBuilder() + .add( + ".map($L::get$L)", + prevName, + enriched.name().getPascalCase().getSafeName()) + .build(); + } + } else { + getter = getter.toBuilder() + .add(".get$L()", enriched.name().getPascalCase().getSafeName()) + .build(); + } + getters.add(getter); + optional = optional || enriched.optional(); + gettersAreOptional.put(enriched, optional); + // TODO(ajgateno): Ensure this is always the type name; could probably add it to the + // EnrichedCursorPathItem + prevName = enriched.name().getPascalCase().getSafeName(); + } + + List enrichedGetters = new ArrayList<>(); + for (int i = 0; i < enrichedItems.size(); i++) { + Optional previous = Optional.empty(); + + if (i > 0) { + previous = Optional.of(enrichedGetters.get(enrichedGetters.size() - 1)); + } + + com.fern.ir.model.types.TypeReference typeReference = referencesByName.get( + enrichedItems.get(enrichedItems.size() - 1 - i).name()); + + enrichedGetters.add(EnrichedCursorPathGetter.builder() + .pathItem(enrichedItems.get(enrichedItems.size() - 1 - i)) + .getter(getters.get(getters.size() - 1 - i)) + // TODO(ajgateno) handle empty + .typeName(unboxedTypeName(generatorContext, typeReference).get()) + .previous(previous) + .optional(gettersAreOptional.get(enrichedItems.get(enrichedItems.size() - 1 - i))) + .build()); + } + + for (EnrichedCursorPathGetter enrichedGetter : enrichedGetters) { + ImmutableEnrichedCursorPathSetter.Builder builder = + EnrichedCursorPathSetter.builder().getter(enrichedGetter); + + if (enrichedGetter.previous().isEmpty()) { + if (enrichedGetter.optional()) { + builder.setter(CodeBlock.builder() + .add( + "$T $L = ", + ParameterizedTypeName.get(ClassName.get(Optional.class), enrichedGetter.typeName()), + enrichedGetter.propertyName()) + .add("$L.map($L -> ", enrichedGetter.getter(), enrichedGetter.propertyName() + "_") + .add( + "$T.builder().from($L).$L($L).build()", + enrichedGetter.typeName(), + enrichedGetter.propertyName() + "_", + propertyOverrideOnRequest, + propertyOverrideValueOnRequest) + .add(")") + .build()); + } else { + builder.setter(CodeBlock.builder() + .add("$T $L = ", enrichedGetter.typeName(), enrichedGetter.propertyName()) + .add( + "$T.builder().from($L).$L($L).build()", + enrichedGetter.typeName(), + enrichedGetter.typeName(), + propertyOverrideOnRequest, + propertyOverrideValueOnRequest) + .build()); + } + } else { + if (enrichedGetter.previous().get().optional()) { + if (enrichedGetter.optional()) { + builder.setter(CodeBlock.builder() + .add( + "$T $L = ", + ParameterizedTypeName.get( + ClassName.get(Optional.class), enrichedGetter.typeName()), + enrichedGetter.propertyName()) + .add( + "$L.flatMap($L -> ", + enrichedGetter.previous().get().propertyName(), + enrichedGetter.previous().get().propertyName() + "_") + .add("$L.map($L -> ", enrichedGetter.getter(), enrichedGetter.propertyName() + "_") + .add( + "$T.builder().from($L).$L($L).build()", + enrichedGetter.typeName(), + enrichedGetter.propertyName() + "_", + enrichedGetter.previous().get().propertyName(), + enrichedGetter.previous().get().propertyName() + "_") + .add(")") + .add(")") + .build()); + } else { + builder.setter(CodeBlock.builder() + .add("$T $L = ", enrichedGetter.typeName(), enrichedGetter.propertyName()) + .add( + "$L.map($L -> ", + enrichedGetter.previous().get().propertyName(), + enrichedGetter.previous().get().propertyName() + "_") + .add( + "$T.builder().from($L).$L($L).build()", + enrichedGetter.typeName(), + enrichedGetter.getter(), + enrichedGetter.previous().get().propertyName(), + enrichedGetter.previous().get().propertyName() + "_") + .add(")") + .build()); + } + } else { + if (enrichedGetter.optional()) { + builder.setter(CodeBlock.builder() + .add( + "$T $L = ", + ParameterizedTypeName.get( + ClassName.get(Optional.class), enrichedGetter.typeName()), + enrichedGetter.propertyName()) + .add("$L.map($L -> ", enrichedGetter.getter(), enrichedGetter.propertyName() + "_") + .add( + "$T.builder().from($L).$L($L).build()", + enrichedGetter.typeName(), + enrichedGetter.propertyName() + "_", + enrichedGetter.previous().get().propertyName(), + enrichedGetter.previous().get().propertyName()) + .add(")") + .build()); + } else { + builder.setter(CodeBlock.builder() + .add("$T $L = ", enrichedGetter.typeName(), enrichedGetter.propertyName()) + .add( + "$T.builder().from($L).$L($L).build())", + enrichedGetter.typeName(), + enrichedGetter.getter(), + enrichedGetter.previous().get().propertyName(), + enrichedGetter.previous().get().propertyName()) + .build()); + } + } + } + + result.add(builder.build()); + } + + return result; + } + + public static class TypeReferenceEnricher + implements TypeReference.Visitor>, + ContainerType.Visitor> { + + private final Name name; + private final boolean optional; + + public TypeReferenceEnricher(Name name) { + this(name, false); + } + + private TypeReferenceEnricher(Name name, boolean optional) { + this.name = name; + this.optional = optional; + } + + @Override + public Optional visitContainer(ContainerType containerType) { + return containerType.visit(this); + } + + @Override + public Optional visitNamed(NamedType namedType) { + return Optional.of(EnrichedCursorPathItem.builder() + .name(name) + .optional(optional) + .build()); + } + + @Override + public Optional visitPrimitive(PrimitiveType primitiveType) { + // NOTE: Primitives won't show up on the path because they have to be the last entry + return Optional.empty(); + } + + @Override + public Optional visitUnknown() { + return Optional.empty(); + } + + @Override + public Optional visitList(TypeReference typeReference) { + // NOTE: Lists are currently not supported in cursor paths + return Optional.empty(); + } + + @Override + public Optional visitMap(MapType mapType) { + // NOTE: Maps are currently not supported in cursor paths + return Optional.empty(); + } + + @Override + public Optional visitOptional(TypeReference typeReference) { + return typeReference.visit(new TypeReferenceEnricher(name, true)); + } + + @Override + public Optional visitSet(TypeReference typeReference) { + // NOTE: Sets are currently not supported in cursor paths + return Optional.empty(); + } + + @Override + public Optional visitLiteral(Literal literal) { + // NOTE: Container literals won't show up on the path because they have to be the last entry + return Optional.empty(); + } + + @Override + public Optional _visitUnknown(Object o) { + return Optional.empty(); + } + } + + public static class TypeReferenceFinder implements HttpRequestBody.Visitor> { + + private final Name desiredPropertyName; + private final AbstractGeneratorContext generatorContext; + + public TypeReferenceFinder(Name desiredPropertyName, AbstractGeneratorContext generatorContext) { + this.desiredPropertyName = desiredPropertyName; + this.generatorContext = generatorContext; + } + + @Override + public Optional visitInlinedRequestBody(InlinedRequestBody inlinedRequestBody) { + Optional maybeFoundExtended = inlinedRequestBody.getExtendedProperties().stream() + .flatMap(List::stream) + .filter(prop -> prop.getName() + .getName() + .getCamelCase() + .getSafeName() + .equals(desiredPropertyName.getCamelCase().getSafeName())) + .map(ObjectProperty::getValueType) + .findAny(); + + if (maybeFoundExtended.isPresent()) { + return maybeFoundExtended; + } + + return inlinedRequestBody.getProperties().stream() + .filter(prop -> prop.getName() + .getName() + .getCamelCase() + .getSafeName() + .equals(desiredPropertyName.getCamelCase().getSafeName())) + .map(InlinedRequestBodyProperty::getValueType) + .findAny(); + } + + @Override + public Optional visitReference(HttpRequestBodyReference httpRequestBodyReference) { + // NOTE: Should not happen for this use-case since we should only allow named types for + // pagination. + if (httpRequestBodyReference.getRequestBodyType().getNamed().isEmpty()) { + return Optional.empty(); + } + + Optional maybeDeclaration = + httpRequestBodyReference.getRequestBodyType().visit(new TypeReferenceResolver(generatorContext)); + + if (maybeDeclaration.isEmpty()) { + return Optional.empty(); + } + + TypeDeclaration declaration = maybeDeclaration.get(); + Optional maybeObjectDeclaration = + declaration.getShape().getObject(); + + if (maybeObjectDeclaration.isEmpty()) { + return Optional.empty(); + } + + ObjectTypeDeclaration objectDeclaration = maybeObjectDeclaration.get(); + + Optional maybeFoundExtended = objectDeclaration.getExtendedProperties().stream() + .flatMap(List::stream) + .filter(prop -> prop.getName() + .getName() + .getCamelCase() + .getSafeName() + .equals(desiredPropertyName.getCamelCase().getSafeName())) + .map(ObjectProperty::getValueType) + .findAny(); + + if (maybeFoundExtended.isPresent()) { + return maybeFoundExtended; + } + + return objectDeclaration.getProperties().stream() + .filter(prop -> prop.getName() + .getName() + .getCamelCase() + .getSafeName() + .equals(desiredPropertyName.getCamelCase().getSafeName())) + .map(ObjectProperty::getValueType) + .findAny(); + } + + @Override + public Optional visitFileUpload(FileUploadRequest fileUploadRequest) { + return Optional.empty(); + } + + @Override + public Optional visitBytes(BytesRequest bytesRequest) { + return Optional.empty(); + } + + @Override + public Optional _visitUnknown(Object o) { + return Optional.empty(); + } + } + + public static class TypeReferenceResolver + implements TypeReference.Visitor>, + ContainerType.Visitor> { + + private final AbstractGeneratorContext generatorContext; + + public TypeReferenceResolver(AbstractGeneratorContext generatorContext) { + this.generatorContext = generatorContext; + } + + @Override + public Optional visitList(TypeReference typeReference) { + return Optional.empty(); + } + + @Override + public Optional visitMap(MapType mapType) { + return Optional.empty(); + } + + @Override + public Optional visitOptional(TypeReference typeReference) { + return typeReference.visit(this); + } + + @Override + public Optional visitSet(TypeReference typeReference) { + return Optional.empty(); + } + + @Override + public Optional visitLiteral(Literal literal) { + return Optional.empty(); + } + + @Override + public Optional visitContainer(ContainerType containerType) { + return containerType.visit(this); + } + + @Override + public Optional visitNamed(NamedType namedType) { + return Optional.ofNullable(generatorContext.getTypeDeclarations().get(namedType.getTypeId())); + } + + @Override + public Optional visitPrimitive(PrimitiveType primitiveType) { + return Optional.empty(); + } + + @Override + public Optional visitUnknown() { + return Optional.empty(); + } + + @Override + public Optional _visitUnknown(Object o) { + return Optional.empty(); + } + } + + public static class UnboxedTypeNameGetter + implements TypeReference.Visitor>, ContainerType.Visitor> { + + private AbstractGeneratorContext generatorContext; + private TypeReference reference; + + public UnboxedTypeNameGetter(AbstractGeneratorContext generatorContext, TypeReference reference) { + this.generatorContext = generatorContext; + this.reference = reference; + } + + @Override + public Optional visitList(TypeReference typeReference) { + return Optional.empty(); + } + + @Override + public Optional visitMap(MapType mapType) { + return Optional.empty(); + } + + @Override + public Optional visitOptional(TypeReference typeReference) { + return typeReference.visit(new UnboxedTypeNameGetter(generatorContext, typeReference)); + } + + @Override + public Optional visitSet(TypeReference typeReference) { + return Optional.empty(); + } + + @Override + public Optional visitLiteral(Literal literal) { + return Optional.empty(); + } + + @Override + public Optional visitContainer(ContainerType containerType) { + return containerType.visit(this); + } + + @Override + public Optional visitNamed(NamedType namedType) { + return Optional.of(generatorContext.getPoetTypeNameMapper().convertToTypeName(true, reference)); + } + + @Override + public Optional visitPrimitive(PrimitiveType primitiveType) { + return Optional.empty(); + } + + @Override + public Optional visitUnknown() { + return Optional.empty(); + } + + @Override + public Optional _visitUnknown(Object o) { + return Optional.empty(); + } + } +} diff --git a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/WrappedRequestEndpointWriter.java b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/WrappedRequestEndpointWriter.java index 7b0b43d167f..c2f9e2dff0e 100644 --- a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/WrappedRequestEndpointWriter.java +++ b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/WrappedRequestEndpointWriter.java @@ -223,7 +223,8 @@ public CodeBlock getInitializeRequestCodeBlock( clientOptionsMember.name, ClientOptionsGenerator.HEADERS_METHOD_NAME, AbstractEndpointWriter.REQUEST_OPTIONS_PARAMETER_NAME) - .add(".addHeader($S, $S);\n", AbstractEndpointWriter.CONTENT_TYPE_HEADER, contentType); + .add(".addHeader($S, $S)\n", AbstractEndpointWriter.CONTENT_TYPE_HEADER, contentType) + .add(".addHeader($S, $S);\n", AbstractEndpointWriter.ACCEPT_HEADER, contentType); } else { requestBodyCodeBlock.add( ".headers($T.of($L.$L($L)));\n", diff --git a/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/ZeroValueUtils.java b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/ZeroValueUtils.java new file mode 100644 index 00000000000..151e9412ff8 --- /dev/null +++ b/generators/java/sdk/src/main/java/com/fern/java/client/generators/endpoint/ZeroValueUtils.java @@ -0,0 +1,204 @@ +package com.fern.java.client.generators.endpoint; + +import com.fern.ir.model.types.Base64Type; +import com.fern.ir.model.types.BigIntegerType; +import com.fern.ir.model.types.BooleanType; +import com.fern.ir.model.types.DateTimeType; +import com.fern.ir.model.types.DateType; +import com.fern.ir.model.types.DoubleType; +import com.fern.ir.model.types.FloatType; +import com.fern.ir.model.types.IntegerType; +import com.fern.ir.model.types.LongType; +import com.fern.ir.model.types.PrimitiveType; +import com.fern.ir.model.types.PrimitiveTypeV1; +import com.fern.ir.model.types.PrimitiveTypeV2; +import com.fern.ir.model.types.StringType; +import com.fern.ir.model.types.Uint64Type; +import com.fern.ir.model.types.UintType; +import com.fern.ir.model.types.UuidType; +import com.squareup.javapoet.CodeBlock; +import java.math.BigInteger; +import java.util.Arrays; + +public class ZeroValueUtils { + + public static CodeBlock isNonzeroValue(String variableName, PrimitiveType primitiveType) { + if (primitiveType.getV2().isPresent()) { + PrimitiveTypeV2 v2 = primitiveType.getV2().get(); + return v2.visit(new IsV2NonzeroValue(variableName)); + } + + PrimitiveTypeV1 v1 = primitiveType.getV1(); + return v1.visit(new IsV1NonzeroValue(variableName)); + } + + public static class IsV1NonzeroValue implements PrimitiveTypeV1.Visitor { + + private final String variableName; + + public IsV1NonzeroValue(String variableName) { + this.variableName = variableName; + } + + @Override + public CodeBlock visitInteger() { + return CodeBlock.of("$L != 0", variableName); + } + + @Override + public CodeBlock visitLong() { + return CodeBlock.of("$L != 0L", variableName); + } + + @Override + public CodeBlock visitUint() { + // TODO(ajgateno): Implement uints property in java generator + return CodeBlock.of("$L != 0L", variableName); + } + + @Override + public CodeBlock visitUint64() { + // TODO(ajgateno): Implement uints property in java generator + return CodeBlock.of("$L != 0L", variableName); + } + + @Override + public CodeBlock visitFloat() { + return CodeBlock.of("$L != 0.0", variableName); + } + + @Override + public CodeBlock visitDouble() { + return CodeBlock.of("$L != 0.0", variableName); + } + + @Override + public CodeBlock visitBoolean() { + return CodeBlock.of("$L", variableName); + } + + @Override + public CodeBlock visitString() { + return CodeBlock.of("!$L.isEmpty()", variableName); + } + + @Override + public CodeBlock visitDate() { + // TODO(ajgateno): Maybe come back and test to make sure this is the right zero value + return CodeBlock.of("!$L.isEmpty()", variableName); + } + + @Override + public CodeBlock visitDateTime() { + // TODO(ajgateno): Maybe come back and test to make sure this is the right zero value + return CodeBlock.of("!$L.isEmpty()", variableName); + } + + @Override + public CodeBlock visitUuid() { + // TODO(ajgateno): Maybe come back and test to make sure this is the right zero value + return CodeBlock.of("!$L.isEmpty()", variableName); + } + + @Override + public CodeBlock visitBase64() { + // TODO(ajgateno): Maybe come back and test to make sure this is the right zero value + return CodeBlock.of("$T.equals($L, new byte[0])", Arrays.class, variableName); + } + + @Override + public CodeBlock visitBigInteger() { + return CodeBlock.of("$L.equals($T.ZERO)", variableName, BigInteger.class); + } + + @Override + public CodeBlock visitUnknown(String s) { + throw new IllegalArgumentException("Received unknown primitive type: " + s); + } + } + + public static class IsV2NonzeroValue implements PrimitiveTypeV2.Visitor { + + private final String variableName; + + public IsV2NonzeroValue(String variableName) { + this.variableName = variableName; + } + + @Override + public CodeBlock visitInteger(IntegerType integerType) { + return CodeBlock.of("$L != 0", variableName); + } + + @Override + public CodeBlock visitLong(LongType longType) { + return CodeBlock.of("$L != 0L", variableName); + } + + @Override + public CodeBlock visitUint(UintType uintType) { + // TODO(ajgateno): Implement uints property in java generator + return CodeBlock.of("$L != 0L", variableName); + } + + @Override + public CodeBlock visitUint64(Uint64Type uint64Type) { + // TODO(ajgateno): Implement uints property in java generator + return CodeBlock.of("$L != 0L", variableName); + } + + @Override + public CodeBlock visitFloat(FloatType floatType) { + return CodeBlock.of("$L != 0.0", variableName); + } + + @Override + public CodeBlock visitDouble(DoubleType doubleType) { + return CodeBlock.of("$L != 0.0", variableName); + } + + @Override + public CodeBlock visitBoolean(BooleanType booleanType) { + return CodeBlock.of("$L", variableName); + } + + @Override + public CodeBlock visitString(StringType stringType) { + return CodeBlock.of("!$L.isEmpty()", variableName); + } + + @Override + public CodeBlock visitDate(DateType dateType) { + // TODO(ajgateno): Maybe come back and test to make sure this is the right zero value + return CodeBlock.of("!$L.isEmpty()", variableName); + } + + @Override + public CodeBlock visitDateTime(DateTimeType dateTimeType) { + // TODO(ajgateno): Maybe come back and test to make sure this is the right zero value + return CodeBlock.of("!$L.isEmpty()", variableName); + } + + @Override + public CodeBlock visitUuid(UuidType uuidType) { + // TODO(ajgateno): Maybe come back and test to make sure this is the right zero value + return CodeBlock.of("!$L.isEmpty()", variableName); + } + + @Override + public CodeBlock visitBase64(Base64Type base64Type) { + // TODO(ajgateno): Maybe come back and test to make sure this is the right zero value + return CodeBlock.of("$T.equals($L, new byte[0])", Arrays.class, variableName); + } + + @Override + public CodeBlock visitBigInteger(BigIntegerType bigIntegerType) { + return CodeBlock.of("$L.equals($T.ZERO)", variableName, BigInteger.class); + } + + @Override + public CodeBlock _visitUnknown(Object o) { + throw new IllegalArgumentException("Received unknown primitive type: " + o); + } + } +} diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_A.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_A.json new file mode 100644 index 00000000000..27818f5f11f --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_A.json @@ -0,0 +1,62 @@ +{ + "type": "object", + "properties": { + "b": { + "oneOf": [ + { + "$ref": "#/definitions/deep-cursor-path.B" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "deep-cursor-path.D": { + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "deep-cursor-path.C": { + "type": "object", + "properties": { + "d": { + "oneOf": [ + { + "$ref": "#/definitions/deep-cursor-path.D" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "deep-cursor-path.B": { + "type": "object", + "properties": { + "c": { + "$ref": "#/definitions/deep-cursor-path.C" + } + }, + "required": [ + "c" + ], + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_B.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_B.json new file mode 100644 index 00000000000..072d1ded975 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_B.json @@ -0,0 +1,46 @@ +{ + "type": "object", + "properties": { + "c": { + "$ref": "#/definitions/deep-cursor-path.C" + } + }, + "required": [ + "c" + ], + "additionalProperties": false, + "definitions": { + "deep-cursor-path.D": { + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "deep-cursor-path.C": { + "type": "object", + "properties": { + "d": { + "oneOf": [ + { + "$ref": "#/definitions/deep-cursor-path.D" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_C.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_C.json new file mode 100644 index 00000000000..230fe06fc73 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_C.json @@ -0,0 +1,34 @@ +{ + "type": "object", + "properties": { + "d": { + "oneOf": [ + { + "$ref": "#/definitions/deep-cursor-path.D" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "deep-cursor-path.D": { + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_D.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_D.json new file mode 100644 index 00000000000..572d79a81b7 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_D.json @@ -0,0 +1,17 @@ +{ + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": {} +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_IndirectionRequired.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_IndirectionRequired.json new file mode 100644 index 00000000000..8cd0c286310 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_IndirectionRequired.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "results": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "results" + ], + "additionalProperties": false, + "definitions": {} +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineA.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineA.json new file mode 100644 index 00000000000..c7ef5da7f93 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineA.json @@ -0,0 +1,62 @@ +{ + "type": "object", + "properties": { + "b": { + "oneOf": [ + { + "$ref": "#/definitions/deep-cursor-path.InlineB" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "deep-cursor-path.InlineD": { + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "deep-cursor-path.InlineC": { + "type": "object", + "properties": { + "b": { + "oneOf": [ + { + "$ref": "#/definitions/deep-cursor-path.InlineD" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "deep-cursor-path.InlineB": { + "type": "object", + "properties": { + "c": { + "$ref": "#/definitions/deep-cursor-path.InlineC" + } + }, + "required": [ + "c" + ], + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineB.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineB.json new file mode 100644 index 00000000000..6a1e23569ae --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineB.json @@ -0,0 +1,46 @@ +{ + "type": "object", + "properties": { + "c": { + "$ref": "#/definitions/deep-cursor-path.InlineC" + } + }, + "required": [ + "c" + ], + "additionalProperties": false, + "definitions": { + "deep-cursor-path.InlineD": { + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "deep-cursor-path.InlineC": { + "type": "object", + "properties": { + "b": { + "oneOf": [ + { + "$ref": "#/definitions/deep-cursor-path.InlineD" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineC.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineC.json new file mode 100644 index 00000000000..b73e5b48c3f --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineC.json @@ -0,0 +1,34 @@ +{ + "type": "object", + "properties": { + "b": { + "oneOf": [ + { + "$ref": "#/definitions/deep-cursor-path.InlineD" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "deep-cursor-path.InlineD": { + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineD.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineD.json new file mode 100644 index 00000000000..572d79a81b7 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_InlineD.json @@ -0,0 +1,17 @@ +{ + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": {} +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_MainRequired.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_MainRequired.json new file mode 100644 index 00000000000..81d42343137 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_MainRequired.json @@ -0,0 +1,39 @@ +{ + "type": "object", + "properties": { + "indirection": { + "$ref": "#/definitions/deep-cursor-path.IndirectionRequired" + } + }, + "required": [ + "indirection" + ], + "additionalProperties": false, + "definitions": { + "deep-cursor-path.IndirectionRequired": { + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "results": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "results" + ], + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_Response.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_Response.json new file mode 100644 index 00000000000..8cd0c286310 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-pagination-deep-cursor-path/type_deep-cursor-path_Response.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "properties": { + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "results": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "results" + ], + "additionalProperties": false, + "definitions": {} +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_Conversation.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_Conversation.json new file mode 100644 index 00000000000..080dd1a61ae --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_Conversation.json @@ -0,0 +1,13 @@ +{ + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ], + "additionalProperties": false, + "definitions": {} +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_CursorPages.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_CursorPages.json new file mode 100644 index 00000000000..c9d9ec3f5fd --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_CursorPages.json @@ -0,0 +1,76 @@ +{ + "type": "object", + "properties": { + "next": { + "oneOf": [ + { + "$ref": "#/definitions/complex.StartingAfterPaging" + }, + { + "type": "null" + } + ] + }, + "page": { + "oneOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] + }, + "per_page": { + "oneOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] + }, + "total_pages": { + "oneOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] + }, + "type": { + "const": "pages" + } + }, + "required": [ + "type" + ], + "additionalProperties": false, + "definitions": { + "complex.StartingAfterPaging": { + "type": "object", + "properties": { + "per_page": { + "type": "integer" + }, + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "per_page" + ], + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequest.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequest.json new file mode 100644 index 00000000000..6463425d638 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequest.json @@ -0,0 +1,128 @@ +{ + "type": "object", + "properties": { + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestValue" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "complex.MultipleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "AND", + "OR" + ] + }, + "complex.MultipleFilterSearchRequest": { + "type": "object", + "properties": { + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestValue" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "complex.SingleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "=", + "!=", + "IN", + "NIN", + "<", + ">", + "~", + "!~", + "^", + "$" + ] + }, + "complex.SingleFilterSearchRequest": { + "type": "object", + "properties": { + "field": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.SingleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "complex.MultipleFilterSearchRequestValue": { + "anyOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.MultipleFilterSearchRequest" + } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.SingleFilterSearchRequest" + } + } + ] + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequestOperator.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequestOperator.json new file mode 100644 index 00000000000..67b89119482 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequestOperator.json @@ -0,0 +1,8 @@ +{ + "type": "string", + "enum": [ + "AND", + "OR" + ], + "definitions": {} +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequestValue.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequestValue.json new file mode 100644 index 00000000000..3f8d36d079e --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_MultipleFilterSearchRequestValue.json @@ -0,0 +1,118 @@ +{ + "anyOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.MultipleFilterSearchRequest" + } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.SingleFilterSearchRequest" + } + } + ], + "definitions": { + "complex.MultipleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "AND", + "OR" + ] + }, + "complex.SingleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "=", + "!=", + "IN", + "NIN", + "<", + ">", + "~", + "!~", + "^", + "$" + ] + }, + "complex.SingleFilterSearchRequest": { + "type": "object", + "properties": { + "field": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.SingleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "complex.MultipleFilterSearchRequestValue": { + "anyOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.MultipleFilterSearchRequest" + } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.SingleFilterSearchRequest" + } + } + ] + }, + "complex.MultipleFilterSearchRequest": { + "type": "object", + "properties": { + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestValue" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_PaginatedConversationResponse.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_PaginatedConversationResponse.json new file mode 100644 index 00000000000..2c0cd5d49e0 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_PaginatedConversationResponse.json @@ -0,0 +1,121 @@ +{ + "type": "object", + "properties": { + "conversations": { + "type": "array", + "items": { + "$ref": "#/definitions/complex.Conversation" + } + }, + "pages": { + "oneOf": [ + { + "$ref": "#/definitions/complex.CursorPages" + }, + { + "type": "null" + } + ] + }, + "total_count": { + "type": "integer" + }, + "type": { + "const": "conversation.list" + } + }, + "required": [ + "conversations", + "total_count", + "type" + ], + "additionalProperties": false, + "definitions": { + "complex.Conversation": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + }, + "required": [ + "foo" + ], + "additionalProperties": false + }, + "complex.StartingAfterPaging": { + "type": "object", + "properties": { + "per_page": { + "type": "integer" + }, + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "per_page" + ], + "additionalProperties": false + }, + "complex.CursorPages": { + "type": "object", + "properties": { + "next": { + "oneOf": [ + { + "$ref": "#/definitions/complex.StartingAfterPaging" + }, + { + "type": "null" + } + ] + }, + "page": { + "oneOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] + }, + "per_page": { + "oneOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] + }, + "total_pages": { + "oneOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] + }, + "type": { + "const": "pages" + } + }, + "required": [ + "type" + ], + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SearchRequest.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SearchRequest.json new file mode 100644 index 00000000000..5ee0c6d9c17 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SearchRequest.json @@ -0,0 +1,156 @@ +{ + "type": "object", + "properties": { + "pagination": { + "oneOf": [ + { + "$ref": "#/definitions/complex.StartingAfterPaging" + }, + { + "type": "null" + } + ] + }, + "query": { + "$ref": "#/definitions/complex.SearchRequestQuery" + } + }, + "required": [ + "query" + ], + "additionalProperties": false, + "definitions": { + "complex.StartingAfterPaging": { + "type": "object", + "properties": { + "per_page": { + "type": "integer" + }, + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "per_page" + ], + "additionalProperties": false + }, + "complex.SingleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "=", + "!=", + "IN", + "NIN", + "<", + ">", + "~", + "!~", + "^", + "$" + ] + }, + "complex.SingleFilterSearchRequest": { + "type": "object", + "properties": { + "field": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.SingleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "complex.MultipleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "AND", + "OR" + ] + }, + "complex.MultipleFilterSearchRequestValue": { + "anyOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.MultipleFilterSearchRequest" + } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.SingleFilterSearchRequest" + } + } + ] + }, + "complex.MultipleFilterSearchRequest": { + "type": "object", + "properties": { + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestValue" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "complex.SearchRequestQuery": { + "anyOf": [ + { + "$ref": "#/definitions/complex.SingleFilterSearchRequest" + }, + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequest" + } + ] + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SearchRequestQuery.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SearchRequestQuery.json new file mode 100644 index 00000000000..fb3ad37cf82 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SearchRequestQuery.json @@ -0,0 +1,112 @@ +{ + "anyOf": [ + { + "$ref": "#/definitions/complex.SingleFilterSearchRequest" + }, + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequest" + } + ], + "definitions": { + "complex.SingleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "=", + "!=", + "IN", + "NIN", + "<", + ">", + "~", + "!~", + "^", + "$" + ] + }, + "complex.SingleFilterSearchRequest": { + "type": "object", + "properties": { + "field": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.SingleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "complex.MultipleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "AND", + "OR" + ] + }, + "complex.MultipleFilterSearchRequestValue": { + "anyOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.MultipleFilterSearchRequest" + } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/complex.SingleFilterSearchRequest" + } + } + ] + }, + "complex.MultipleFilterSearchRequest": { + "type": "object", + "properties": { + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "$ref": "#/definitions/complex.MultipleFilterSearchRequestValue" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SingleFilterSearchRequest.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SingleFilterSearchRequest.json new file mode 100644 index 00000000000..d83e1af0a66 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SingleFilterSearchRequest.json @@ -0,0 +1,53 @@ +{ + "type": "object", + "properties": { + "field": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "operator": { + "oneOf": [ + { + "$ref": "#/definitions/complex.SingleFilterSearchRequestOperator" + }, + { + "type": "null" + } + ] + }, + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "complex.SingleFilterSearchRequestOperator": { + "type": "string", + "enum": [ + "=", + "!=", + "IN", + "NIN", + "<", + ">", + "~", + "!~", + "^", + "$" + ] + } + } +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SingleFilterSearchRequestOperator.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SingleFilterSearchRequestOperator.json new file mode 100644 index 00000000000..657f0f986a6 --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_SingleFilterSearchRequestOperator.json @@ -0,0 +1,16 @@ +{ + "type": "string", + "enum": [ + "=", + "!=", + "IN", + "NIN", + "<", + ">", + "~", + "!~", + "^", + "$" + ], + "definitions": {} +} \ No newline at end of file diff --git a/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_StartingAfterPaging.json b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_StartingAfterPaging.json new file mode 100644 index 00000000000..fb270f0a29e --- /dev/null +++ b/packages/cli/fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/pagination/type_complex_StartingAfterPaging.json @@ -0,0 +1,23 @@ +{ + "type": "object", + "properties": { + "per_page": { + "type": "integer" + }, + "starting_after": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "per_page" + ], + "additionalProperties": false, + "definitions": {} +} \ No newline at end of file diff --git a/packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions/java-pagination-deep-cursor-path.json b/packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions/java-pagination-deep-cursor-path.json new file mode 100644 index 00000000000..b8646db6b96 --- /dev/null +++ b/packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions/java-pagination-deep-cursor-path.json @@ -0,0 +1,1417 @@ +{ + "version": "1.0.0", + "types": { + "type_deep-cursor-path:D": { + "type": "object", + "declaration": { + "name": { + "originalName": "D", + "camelCase": { + "unsafeName": "d", + "safeName": "d" + }, + "snakeCase": { + "unsafeName": "d", + "safeName": "d" + }, + "screamingSnakeCase": { + "unsafeName": "D", + "safeName": "D" + }, + "pascalCase": { + "unsafeName": "D", + "safeName": "D" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "starting_after", + "camelCase": { + "unsafeName": "startingAfter", + "safeName": "startingAfter" + }, + "snakeCase": { + "unsafeName": "starting_after", + "safeName": "starting_after" + }, + "screamingSnakeCase": { + "unsafeName": "STARTING_AFTER", + "safeName": "STARTING_AFTER" + }, + "pascalCase": { + "unsafeName": "StartingAfter", + "safeName": "StartingAfter" + } + }, + "wireValue": "starting_after" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "STRING" + } + } + } + ] + }, + "type_deep-cursor-path:C": { + "type": "object", + "declaration": { + "name": { + "originalName": "C", + "camelCase": { + "unsafeName": "c", + "safeName": "c" + }, + "snakeCase": { + "unsafeName": "c", + "safeName": "c" + }, + "screamingSnakeCase": { + "unsafeName": "C", + "safeName": "C" + }, + "pascalCase": { + "unsafeName": "C", + "safeName": "C" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "d", + "camelCase": { + "unsafeName": "d", + "safeName": "d" + }, + "snakeCase": { + "unsafeName": "d", + "safeName": "d" + }, + "screamingSnakeCase": { + "unsafeName": "D", + "safeName": "D" + }, + "pascalCase": { + "unsafeName": "D", + "safeName": "D" + } + }, + "wireValue": "d" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_deep-cursor-path:D" + } + } + } + ] + }, + "type_deep-cursor-path:B": { + "type": "object", + "declaration": { + "name": { + "originalName": "B", + "camelCase": { + "unsafeName": "b", + "safeName": "b" + }, + "snakeCase": { + "unsafeName": "b", + "safeName": "b" + }, + "screamingSnakeCase": { + "unsafeName": "B", + "safeName": "B" + }, + "pascalCase": { + "unsafeName": "B", + "safeName": "B" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "c", + "camelCase": { + "unsafeName": "c", + "safeName": "c" + }, + "snakeCase": { + "unsafeName": "c", + "safeName": "c" + }, + "screamingSnakeCase": { + "unsafeName": "C", + "safeName": "C" + }, + "pascalCase": { + "unsafeName": "C", + "safeName": "C" + } + }, + "wireValue": "c" + }, + "typeReference": { + "type": "named", + "value": "type_deep-cursor-path:C" + } + } + ] + }, + "type_deep-cursor-path:A": { + "type": "object", + "declaration": { + "name": { + "originalName": "A", + "camelCase": { + "unsafeName": "a", + "safeName": "a" + }, + "snakeCase": { + "unsafeName": "a", + "safeName": "a" + }, + "screamingSnakeCase": { + "unsafeName": "A", + "safeName": "A" + }, + "pascalCase": { + "unsafeName": "A", + "safeName": "A" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "b", + "camelCase": { + "unsafeName": "b", + "safeName": "b" + }, + "snakeCase": { + "unsafeName": "b", + "safeName": "b" + }, + "screamingSnakeCase": { + "unsafeName": "B", + "safeName": "B" + }, + "pascalCase": { + "unsafeName": "B", + "safeName": "B" + } + }, + "wireValue": "b" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_deep-cursor-path:B" + } + } + } + ] + }, + "type_deep-cursor-path:Response": { + "type": "object", + "declaration": { + "name": { + "originalName": "Response", + "camelCase": { + "unsafeName": "response", + "safeName": "response" + }, + "snakeCase": { + "unsafeName": "response", + "safeName": "response" + }, + "screamingSnakeCase": { + "unsafeName": "RESPONSE", + "safeName": "RESPONSE" + }, + "pascalCase": { + "unsafeName": "Response", + "safeName": "Response" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "starting_after", + "camelCase": { + "unsafeName": "startingAfter", + "safeName": "startingAfter" + }, + "snakeCase": { + "unsafeName": "starting_after", + "safeName": "starting_after" + }, + "screamingSnakeCase": { + "unsafeName": "STARTING_AFTER", + "safeName": "STARTING_AFTER" + }, + "pascalCase": { + "unsafeName": "StartingAfter", + "safeName": "StartingAfter" + } + }, + "wireValue": "starting_after" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "STRING" + } + } + }, + { + "name": { + "name": { + "originalName": "results", + "camelCase": { + "unsafeName": "results", + "safeName": "results" + }, + "snakeCase": { + "unsafeName": "results", + "safeName": "results" + }, + "screamingSnakeCase": { + "unsafeName": "RESULTS", + "safeName": "RESULTS" + }, + "pascalCase": { + "unsafeName": "Results", + "safeName": "Results" + } + }, + "wireValue": "results" + }, + "typeReference": { + "type": "list", + "value": { + "type": "primitive", + "value": "STRING" + } + } + } + ] + }, + "type_deep-cursor-path:IndirectionRequired": { + "type": "object", + "declaration": { + "name": { + "originalName": "IndirectionRequired", + "camelCase": { + "unsafeName": "indirectionRequired", + "safeName": "indirectionRequired" + }, + "snakeCase": { + "unsafeName": "indirection_required", + "safeName": "indirection_required" + }, + "screamingSnakeCase": { + "unsafeName": "INDIRECTION_REQUIRED", + "safeName": "INDIRECTION_REQUIRED" + }, + "pascalCase": { + "unsafeName": "IndirectionRequired", + "safeName": "IndirectionRequired" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "starting_after", + "camelCase": { + "unsafeName": "startingAfter", + "safeName": "startingAfter" + }, + "snakeCase": { + "unsafeName": "starting_after", + "safeName": "starting_after" + }, + "screamingSnakeCase": { + "unsafeName": "STARTING_AFTER", + "safeName": "STARTING_AFTER" + }, + "pascalCase": { + "unsafeName": "StartingAfter", + "safeName": "StartingAfter" + } + }, + "wireValue": "starting_after" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "STRING" + } + } + }, + { + "name": { + "name": { + "originalName": "results", + "camelCase": { + "unsafeName": "results", + "safeName": "results" + }, + "snakeCase": { + "unsafeName": "results", + "safeName": "results" + }, + "screamingSnakeCase": { + "unsafeName": "RESULTS", + "safeName": "RESULTS" + }, + "pascalCase": { + "unsafeName": "Results", + "safeName": "Results" + } + }, + "wireValue": "results" + }, + "typeReference": { + "type": "list", + "value": { + "type": "primitive", + "value": "STRING" + } + } + } + ] + }, + "type_deep-cursor-path:MainRequired": { + "type": "object", + "declaration": { + "name": { + "originalName": "MainRequired", + "camelCase": { + "unsafeName": "mainRequired", + "safeName": "mainRequired" + }, + "snakeCase": { + "unsafeName": "main_required", + "safeName": "main_required" + }, + "screamingSnakeCase": { + "unsafeName": "MAIN_REQUIRED", + "safeName": "MAIN_REQUIRED" + }, + "pascalCase": { + "unsafeName": "MainRequired", + "safeName": "MainRequired" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "indirection", + "camelCase": { + "unsafeName": "indirection", + "safeName": "indirection" + }, + "snakeCase": { + "unsafeName": "indirection", + "safeName": "indirection" + }, + "screamingSnakeCase": { + "unsafeName": "INDIRECTION", + "safeName": "INDIRECTION" + }, + "pascalCase": { + "unsafeName": "Indirection", + "safeName": "Indirection" + } + }, + "wireValue": "indirection" + }, + "typeReference": { + "type": "named", + "value": "type_deep-cursor-path:IndirectionRequired" + } + } + ] + }, + "type_deep-cursor-path:InlineD": { + "type": "object", + "declaration": { + "name": { + "originalName": "InlineD", + "camelCase": { + "unsafeName": "inlineD", + "safeName": "inlineD" + }, + "snakeCase": { + "unsafeName": "inline_d", + "safeName": "inline_d" + }, + "screamingSnakeCase": { + "unsafeName": "INLINE_D", + "safeName": "INLINE_D" + }, + "pascalCase": { + "unsafeName": "InlineD", + "safeName": "InlineD" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "starting_after", + "camelCase": { + "unsafeName": "startingAfter", + "safeName": "startingAfter" + }, + "snakeCase": { + "unsafeName": "starting_after", + "safeName": "starting_after" + }, + "screamingSnakeCase": { + "unsafeName": "STARTING_AFTER", + "safeName": "STARTING_AFTER" + }, + "pascalCase": { + "unsafeName": "StartingAfter", + "safeName": "StartingAfter" + } + }, + "wireValue": "starting_after" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "STRING" + } + } + } + ] + }, + "type_deep-cursor-path:InlineC": { + "type": "object", + "declaration": { + "name": { + "originalName": "InlineC", + "camelCase": { + "unsafeName": "inlineC", + "safeName": "inlineC" + }, + "snakeCase": { + "unsafeName": "inline_c", + "safeName": "inline_c" + }, + "screamingSnakeCase": { + "unsafeName": "INLINE_C", + "safeName": "INLINE_C" + }, + "pascalCase": { + "unsafeName": "InlineC", + "safeName": "InlineC" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "b", + "camelCase": { + "unsafeName": "b", + "safeName": "b" + }, + "snakeCase": { + "unsafeName": "b", + "safeName": "b" + }, + "screamingSnakeCase": { + "unsafeName": "B", + "safeName": "B" + }, + "pascalCase": { + "unsafeName": "B", + "safeName": "B" + } + }, + "wireValue": "b" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_deep-cursor-path:InlineD" + } + } + } + ] + }, + "type_deep-cursor-path:InlineB": { + "type": "object", + "declaration": { + "name": { + "originalName": "InlineB", + "camelCase": { + "unsafeName": "inlineB", + "safeName": "inlineB" + }, + "snakeCase": { + "unsafeName": "inline_b", + "safeName": "inline_b" + }, + "screamingSnakeCase": { + "unsafeName": "INLINE_B", + "safeName": "INLINE_B" + }, + "pascalCase": { + "unsafeName": "InlineB", + "safeName": "InlineB" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "c", + "camelCase": { + "unsafeName": "c", + "safeName": "c" + }, + "snakeCase": { + "unsafeName": "c", + "safeName": "c" + }, + "screamingSnakeCase": { + "unsafeName": "C", + "safeName": "C" + }, + "pascalCase": { + "unsafeName": "C", + "safeName": "C" + } + }, + "wireValue": "c" + }, + "typeReference": { + "type": "named", + "value": "type_deep-cursor-path:InlineC" + } + } + ] + }, + "type_deep-cursor-path:InlineA": { + "type": "object", + "declaration": { + "name": { + "originalName": "InlineA", + "camelCase": { + "unsafeName": "inlineA", + "safeName": "inlineA" + }, + "snakeCase": { + "unsafeName": "inline_a", + "safeName": "inline_a" + }, + "screamingSnakeCase": { + "unsafeName": "INLINE_A", + "safeName": "INLINE_A" + }, + "pascalCase": { + "unsafeName": "InlineA", + "safeName": "InlineA" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "b", + "camelCase": { + "unsafeName": "b", + "safeName": "b" + }, + "snakeCase": { + "unsafeName": "b", + "safeName": "b" + }, + "screamingSnakeCase": { + "unsafeName": "B", + "safeName": "B" + }, + "pascalCase": { + "unsafeName": "B", + "safeName": "B" + } + }, + "wireValue": "b" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_deep-cursor-path:InlineB" + } + } + } + ] + } + }, + "headers": [], + "endpoints": { + "endpoint_deep-cursor-path.do-thing": { + "auth": null, + "declaration": { + "name": { + "originalName": "do-thing", + "camelCase": { + "unsafeName": "doThing", + "safeName": "doThing" + }, + "snakeCase": { + "unsafeName": "do_thing", + "safeName": "do_thing" + }, + "screamingSnakeCase": { + "unsafeName": "DO_THING", + "safeName": "DO_THING" + }, + "pascalCase": { + "unsafeName": "DoThing", + "safeName": "DoThing" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "location": { + "method": "POST", + "path": "/" + }, + "request": { + "type": "body", + "pathParameters": [], + "body": { + "type": "typeReference", + "value": { + "type": "named", + "value": "type_deep-cursor-path:A" + } + } + }, + "response": { + "type": "json" + } + }, + "endpoint_deep-cursor-path.do-thing-required": { + "auth": null, + "declaration": { + "name": { + "originalName": "do-thing-required", + "camelCase": { + "unsafeName": "doThingRequired", + "safeName": "doThingRequired" + }, + "snakeCase": { + "unsafeName": "do_thing_required", + "safeName": "do_thing_required" + }, + "screamingSnakeCase": { + "unsafeName": "DO_THING_REQUIRED", + "safeName": "DO_THING_REQUIRED" + }, + "pascalCase": { + "unsafeName": "DoThingRequired", + "safeName": "DoThingRequired" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "location": { + "method": "POST", + "path": "/" + }, + "request": { + "type": "body", + "pathParameters": [], + "body": { + "type": "typeReference", + "value": { + "type": "named", + "value": "type_deep-cursor-path:MainRequired" + } + } + }, + "response": { + "type": "json" + } + }, + "endpoint_deep-cursor-path.do-thing-inline": { + "auth": null, + "declaration": { + "name": { + "originalName": "do-thing-inline", + "camelCase": { + "unsafeName": "doThingInline", + "safeName": "doThingInline" + }, + "snakeCase": { + "unsafeName": "do_thing_inline", + "safeName": "do_thing_inline" + }, + "screamingSnakeCase": { + "unsafeName": "DO_THING_INLINE", + "safeName": "DO_THING_INLINE" + }, + "pascalCase": { + "unsafeName": "DoThingInline", + "safeName": "DoThingInline" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + ], + "packagePath": [], + "file": { + "originalName": "deep-cursor-path", + "camelCase": { + "unsafeName": "deepCursorPath", + "safeName": "deepCursorPath" + }, + "snakeCase": { + "unsafeName": "deep_cursor_path", + "safeName": "deep_cursor_path" + }, + "screamingSnakeCase": { + "unsafeName": "DEEP_CURSOR_PATH", + "safeName": "DEEP_CURSOR_PATH" + }, + "pascalCase": { + "unsafeName": "DeepCursorPath", + "safeName": "DeepCursorPath" + } + } + } + }, + "location": { + "method": "POST", + "path": "/" + }, + "request": { + "type": "body", + "pathParameters": [], + "body": { + "type": "typeReference", + "value": { + "type": "named", + "value": "type_deep-cursor-path:InlineA" + } + } + }, + "response": { + "type": "json" + } + } + }, + "environments": null +} \ No newline at end of file diff --git a/packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions/pagination.json b/packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions/pagination.json index 7cda0b384cd..e769e491f20 100644 --- a/packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions/pagination.json +++ b/packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions/pagination.json @@ -153,6 +153,1628 @@ } ] }, + "type_complex:SearchRequestQuery": { + "type": "undiscriminatedUnion", + "declaration": { + "name": { + "originalName": "SearchRequestQuery", + "camelCase": { + "unsafeName": "searchRequestQuery", + "safeName": "searchRequestQuery" + }, + "snakeCase": { + "unsafeName": "search_request_query", + "safeName": "search_request_query" + }, + "screamingSnakeCase": { + "unsafeName": "SEARCH_REQUEST_QUERY", + "safeName": "SEARCH_REQUEST_QUERY" + }, + "pascalCase": { + "unsafeName": "SearchRequestQuery", + "safeName": "SearchRequestQuery" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "types": [ + { + "type": "named", + "value": "type_complex:SingleFilterSearchRequest" + }, + { + "type": "named", + "value": "type_complex:MultipleFilterSearchRequest" + } + ] + }, + "type_complex:MultipleFilterSearchRequest": { + "type": "object", + "declaration": { + "name": { + "originalName": "MultipleFilterSearchRequest", + "camelCase": { + "unsafeName": "multipleFilterSearchRequest", + "safeName": "multipleFilterSearchRequest" + }, + "snakeCase": { + "unsafeName": "multiple_filter_search_request", + "safeName": "multiple_filter_search_request" + }, + "screamingSnakeCase": { + "unsafeName": "MULTIPLE_FILTER_SEARCH_REQUEST", + "safeName": "MULTIPLE_FILTER_SEARCH_REQUEST" + }, + "pascalCase": { + "unsafeName": "MultipleFilterSearchRequest", + "safeName": "MultipleFilterSearchRequest" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "operator", + "camelCase": { + "unsafeName": "operator", + "safeName": "operator" + }, + "snakeCase": { + "unsafeName": "operator", + "safeName": "operator" + }, + "screamingSnakeCase": { + "unsafeName": "OPERATOR", + "safeName": "OPERATOR" + }, + "pascalCase": { + "unsafeName": "Operator", + "safeName": "Operator" + } + }, + "wireValue": "operator" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_complex:MultipleFilterSearchRequestOperator" + } + } + }, + { + "name": { + "name": { + "originalName": "value", + "camelCase": { + "unsafeName": "value", + "safeName": "value" + }, + "snakeCase": { + "unsafeName": "value", + "safeName": "value" + }, + "screamingSnakeCase": { + "unsafeName": "VALUE", + "safeName": "VALUE" + }, + "pascalCase": { + "unsafeName": "Value", + "safeName": "Value" + } + }, + "wireValue": "value" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_complex:MultipleFilterSearchRequestValue" + } + } + } + ] + }, + "type_complex:MultipleFilterSearchRequestOperator": { + "type": "enum", + "declaration": { + "name": { + "originalName": "MultipleFilterSearchRequestOperator", + "camelCase": { + "unsafeName": "multipleFilterSearchRequestOperator", + "safeName": "multipleFilterSearchRequestOperator" + }, + "snakeCase": { + "unsafeName": "multiple_filter_search_request_operator", + "safeName": "multiple_filter_search_request_operator" + }, + "screamingSnakeCase": { + "unsafeName": "MULTIPLE_FILTER_SEARCH_REQUEST_OPERATOR", + "safeName": "MULTIPLE_FILTER_SEARCH_REQUEST_OPERATOR" + }, + "pascalCase": { + "unsafeName": "MultipleFilterSearchRequestOperator", + "safeName": "MultipleFilterSearchRequestOperator" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "values": [ + { + "name": { + "originalName": "AND", + "camelCase": { + "unsafeName": "and", + "safeName": "and" + }, + "snakeCase": { + "unsafeName": "and", + "safeName": "and" + }, + "screamingSnakeCase": { + "unsafeName": "AND", + "safeName": "AND" + }, + "pascalCase": { + "unsafeName": "And", + "safeName": "And" + } + }, + "wireValue": "AND" + }, + { + "name": { + "originalName": "OR", + "camelCase": { + "unsafeName": "or", + "safeName": "or" + }, + "snakeCase": { + "unsafeName": "or", + "safeName": "or" + }, + "screamingSnakeCase": { + "unsafeName": "OR", + "safeName": "OR" + }, + "pascalCase": { + "unsafeName": "Or", + "safeName": "Or" + } + }, + "wireValue": "OR" + } + ] + }, + "type_complex:MultipleFilterSearchRequestValue": { + "type": "undiscriminatedUnion", + "declaration": { + "name": { + "originalName": "MultipleFilterSearchRequestValue", + "camelCase": { + "unsafeName": "multipleFilterSearchRequestValue", + "safeName": "multipleFilterSearchRequestValue" + }, + "snakeCase": { + "unsafeName": "multiple_filter_search_request_value", + "safeName": "multiple_filter_search_request_value" + }, + "screamingSnakeCase": { + "unsafeName": "MULTIPLE_FILTER_SEARCH_REQUEST_VALUE", + "safeName": "MULTIPLE_FILTER_SEARCH_REQUEST_VALUE" + }, + "pascalCase": { + "unsafeName": "MultipleFilterSearchRequestValue", + "safeName": "MultipleFilterSearchRequestValue" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "types": [ + { + "type": "list", + "value": { + "type": "named", + "value": "type_complex:MultipleFilterSearchRequest" + } + }, + { + "type": "list", + "value": { + "type": "named", + "value": "type_complex:SingleFilterSearchRequest" + } + } + ] + }, + "type_complex:SingleFilterSearchRequest": { + "type": "object", + "declaration": { + "name": { + "originalName": "SingleFilterSearchRequest", + "camelCase": { + "unsafeName": "singleFilterSearchRequest", + "safeName": "singleFilterSearchRequest" + }, + "snakeCase": { + "unsafeName": "single_filter_search_request", + "safeName": "single_filter_search_request" + }, + "screamingSnakeCase": { + "unsafeName": "SINGLE_FILTER_SEARCH_REQUEST", + "safeName": "SINGLE_FILTER_SEARCH_REQUEST" + }, + "pascalCase": { + "unsafeName": "SingleFilterSearchRequest", + "safeName": "SingleFilterSearchRequest" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "field", + "camelCase": { + "unsafeName": "field", + "safeName": "field" + }, + "snakeCase": { + "unsafeName": "field", + "safeName": "field" + }, + "screamingSnakeCase": { + "unsafeName": "FIELD", + "safeName": "FIELD" + }, + "pascalCase": { + "unsafeName": "Field", + "safeName": "Field" + } + }, + "wireValue": "field" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "STRING" + } + } + }, + { + "name": { + "name": { + "originalName": "operator", + "camelCase": { + "unsafeName": "operator", + "safeName": "operator" + }, + "snakeCase": { + "unsafeName": "operator", + "safeName": "operator" + }, + "screamingSnakeCase": { + "unsafeName": "OPERATOR", + "safeName": "OPERATOR" + }, + "pascalCase": { + "unsafeName": "Operator", + "safeName": "Operator" + } + }, + "wireValue": "operator" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_complex:SingleFilterSearchRequestOperator" + } + } + }, + { + "name": { + "name": { + "originalName": "value", + "camelCase": { + "unsafeName": "value", + "safeName": "value" + }, + "snakeCase": { + "unsafeName": "value", + "safeName": "value" + }, + "screamingSnakeCase": { + "unsafeName": "VALUE", + "safeName": "VALUE" + }, + "pascalCase": { + "unsafeName": "Value", + "safeName": "Value" + } + }, + "wireValue": "value" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "STRING" + } + } + } + ] + }, + "type_complex:SingleFilterSearchRequestOperator": { + "type": "enum", + "declaration": { + "name": { + "originalName": "SingleFilterSearchRequestOperator", + "camelCase": { + "unsafeName": "singleFilterSearchRequestOperator", + "safeName": "singleFilterSearchRequestOperator" + }, + "snakeCase": { + "unsafeName": "single_filter_search_request_operator", + "safeName": "single_filter_search_request_operator" + }, + "screamingSnakeCase": { + "unsafeName": "SINGLE_FILTER_SEARCH_REQUEST_OPERATOR", + "safeName": "SINGLE_FILTER_SEARCH_REQUEST_OPERATOR" + }, + "pascalCase": { + "unsafeName": "SingleFilterSearchRequestOperator", + "safeName": "SingleFilterSearchRequestOperator" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "values": [ + { + "name": { + "originalName": "Equals", + "camelCase": { + "unsafeName": "equals", + "safeName": "equals" + }, + "snakeCase": { + "unsafeName": "equals", + "safeName": "equals" + }, + "screamingSnakeCase": { + "unsafeName": "EQUALS", + "safeName": "EQUALS" + }, + "pascalCase": { + "unsafeName": "Equals", + "safeName": "Equals" + } + }, + "wireValue": "=" + }, + { + "name": { + "originalName": "NotEquals", + "camelCase": { + "unsafeName": "notEquals", + "safeName": "notEquals" + }, + "snakeCase": { + "unsafeName": "not_equals", + "safeName": "not_equals" + }, + "screamingSnakeCase": { + "unsafeName": "NOT_EQUALS", + "safeName": "NOT_EQUALS" + }, + "pascalCase": { + "unsafeName": "NotEquals", + "safeName": "NotEquals" + } + }, + "wireValue": "!=" + }, + { + "name": { + "originalName": "In", + "camelCase": { + "unsafeName": "in", + "safeName": "in" + }, + "snakeCase": { + "unsafeName": "in", + "safeName": "in" + }, + "screamingSnakeCase": { + "unsafeName": "IN", + "safeName": "IN" + }, + "pascalCase": { + "unsafeName": "In", + "safeName": "In" + } + }, + "wireValue": "IN" + }, + { + "name": { + "originalName": "NotIn", + "camelCase": { + "unsafeName": "notIn", + "safeName": "notIn" + }, + "snakeCase": { + "unsafeName": "not_in", + "safeName": "not_in" + }, + "screamingSnakeCase": { + "unsafeName": "NOT_IN", + "safeName": "NOT_IN" + }, + "pascalCase": { + "unsafeName": "NotIn", + "safeName": "NotIn" + } + }, + "wireValue": "NIN" + }, + { + "name": { + "originalName": "LessThan", + "camelCase": { + "unsafeName": "lessThan", + "safeName": "lessThan" + }, + "snakeCase": { + "unsafeName": "less_than", + "safeName": "less_than" + }, + "screamingSnakeCase": { + "unsafeName": "LESS_THAN", + "safeName": "LESS_THAN" + }, + "pascalCase": { + "unsafeName": "LessThan", + "safeName": "LessThan" + } + }, + "wireValue": "<" + }, + { + "name": { + "originalName": "GreaterThan", + "camelCase": { + "unsafeName": "greaterThan", + "safeName": "greaterThan" + }, + "snakeCase": { + "unsafeName": "greater_than", + "safeName": "greater_than" + }, + "screamingSnakeCase": { + "unsafeName": "GREATER_THAN", + "safeName": "GREATER_THAN" + }, + "pascalCase": { + "unsafeName": "GreaterThan", + "safeName": "GreaterThan" + } + }, + "wireValue": ">" + }, + { + "name": { + "originalName": "Contains", + "camelCase": { + "unsafeName": "contains", + "safeName": "contains" + }, + "snakeCase": { + "unsafeName": "contains", + "safeName": "contains" + }, + "screamingSnakeCase": { + "unsafeName": "CONTAINS", + "safeName": "CONTAINS" + }, + "pascalCase": { + "unsafeName": "Contains", + "safeName": "Contains" + } + }, + "wireValue": "~" + }, + { + "name": { + "originalName": "DoesNotContain", + "camelCase": { + "unsafeName": "doesNotContain", + "safeName": "doesNotContain" + }, + "snakeCase": { + "unsafeName": "does_not_contain", + "safeName": "does_not_contain" + }, + "screamingSnakeCase": { + "unsafeName": "DOES_NOT_CONTAIN", + "safeName": "DOES_NOT_CONTAIN" + }, + "pascalCase": { + "unsafeName": "DoesNotContain", + "safeName": "DoesNotContain" + } + }, + "wireValue": "!~" + }, + { + "name": { + "originalName": "StartsWith", + "camelCase": { + "unsafeName": "startsWith", + "safeName": "startsWith" + }, + "snakeCase": { + "unsafeName": "starts_with", + "safeName": "starts_with" + }, + "screamingSnakeCase": { + "unsafeName": "STARTS_WITH", + "safeName": "STARTS_WITH" + }, + "pascalCase": { + "unsafeName": "StartsWith", + "safeName": "StartsWith" + } + }, + "wireValue": "^" + }, + { + "name": { + "originalName": "EndsWith", + "camelCase": { + "unsafeName": "endsWith", + "safeName": "endsWith" + }, + "snakeCase": { + "unsafeName": "ends_with", + "safeName": "ends_with" + }, + "screamingSnakeCase": { + "unsafeName": "ENDS_WITH", + "safeName": "ENDS_WITH" + }, + "pascalCase": { + "unsafeName": "EndsWith", + "safeName": "EndsWith" + } + }, + "wireValue": "$" + } + ] + }, + "type_complex:SearchRequest": { + "type": "object", + "declaration": { + "name": { + "originalName": "SearchRequest", + "camelCase": { + "unsafeName": "searchRequest", + "safeName": "searchRequest" + }, + "snakeCase": { + "unsafeName": "search_request", + "safeName": "search_request" + }, + "screamingSnakeCase": { + "unsafeName": "SEARCH_REQUEST", + "safeName": "SEARCH_REQUEST" + }, + "pascalCase": { + "unsafeName": "SearchRequest", + "safeName": "SearchRequest" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "pagination", + "camelCase": { + "unsafeName": "pagination", + "safeName": "pagination" + }, + "snakeCase": { + "unsafeName": "pagination", + "safeName": "pagination" + }, + "screamingSnakeCase": { + "unsafeName": "PAGINATION", + "safeName": "PAGINATION" + }, + "pascalCase": { + "unsafeName": "Pagination", + "safeName": "Pagination" + } + }, + "wireValue": "pagination" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_complex:StartingAfterPaging" + } + } + }, + { + "name": { + "name": { + "originalName": "query", + "camelCase": { + "unsafeName": "query", + "safeName": "query" + }, + "snakeCase": { + "unsafeName": "query", + "safeName": "query" + }, + "screamingSnakeCase": { + "unsafeName": "QUERY", + "safeName": "QUERY" + }, + "pascalCase": { + "unsafeName": "Query", + "safeName": "Query" + } + }, + "wireValue": "query" + }, + "typeReference": { + "type": "named", + "value": "type_complex:SearchRequestQuery" + } + } + ] + }, + "type_complex:PaginatedConversationResponse": { + "type": "object", + "declaration": { + "name": { + "originalName": "PaginatedConversationResponse", + "camelCase": { + "unsafeName": "paginatedConversationResponse", + "safeName": "paginatedConversationResponse" + }, + "snakeCase": { + "unsafeName": "paginated_conversation_response", + "safeName": "paginated_conversation_response" + }, + "screamingSnakeCase": { + "unsafeName": "PAGINATED_CONVERSATION_RESPONSE", + "safeName": "PAGINATED_CONVERSATION_RESPONSE" + }, + "pascalCase": { + "unsafeName": "PaginatedConversationResponse", + "safeName": "PaginatedConversationResponse" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "conversations", + "camelCase": { + "unsafeName": "conversations", + "safeName": "conversations" + }, + "snakeCase": { + "unsafeName": "conversations", + "safeName": "conversations" + }, + "screamingSnakeCase": { + "unsafeName": "CONVERSATIONS", + "safeName": "CONVERSATIONS" + }, + "pascalCase": { + "unsafeName": "Conversations", + "safeName": "Conversations" + } + }, + "wireValue": "conversations" + }, + "typeReference": { + "type": "list", + "value": { + "type": "named", + "value": "type_complex:Conversation" + } + } + }, + { + "name": { + "name": { + "originalName": "pages", + "camelCase": { + "unsafeName": "pages", + "safeName": "pages" + }, + "snakeCase": { + "unsafeName": "pages", + "safeName": "pages" + }, + "screamingSnakeCase": { + "unsafeName": "PAGES", + "safeName": "PAGES" + }, + "pascalCase": { + "unsafeName": "Pages", + "safeName": "Pages" + } + }, + "wireValue": "pages" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_complex:CursorPages" + } + } + }, + { + "name": { + "name": { + "originalName": "total_count", + "camelCase": { + "unsafeName": "totalCount", + "safeName": "totalCount" + }, + "snakeCase": { + "unsafeName": "total_count", + "safeName": "total_count" + }, + "screamingSnakeCase": { + "unsafeName": "TOTAL_COUNT", + "safeName": "TOTAL_COUNT" + }, + "pascalCase": { + "unsafeName": "TotalCount", + "safeName": "TotalCount" + } + }, + "wireValue": "total_count" + }, + "typeReference": { + "type": "primitive", + "value": "INTEGER" + } + }, + { + "name": { + "name": { + "originalName": "type", + "camelCase": { + "unsafeName": "type", + "safeName": "type" + }, + "snakeCase": { + "unsafeName": "type", + "safeName": "type" + }, + "screamingSnakeCase": { + "unsafeName": "TYPE", + "safeName": "TYPE" + }, + "pascalCase": { + "unsafeName": "Type", + "safeName": "Type" + } + }, + "wireValue": "type" + }, + "typeReference": { + "type": "literal", + "value": { + "type": "string", + "value": "conversation.list" + } + } + } + ] + }, + "type_complex:CursorPages": { + "type": "object", + "declaration": { + "name": { + "originalName": "CursorPages", + "camelCase": { + "unsafeName": "cursorPages", + "safeName": "cursorPages" + }, + "snakeCase": { + "unsafeName": "cursor_pages", + "safeName": "cursor_pages" + }, + "screamingSnakeCase": { + "unsafeName": "CURSOR_PAGES", + "safeName": "CURSOR_PAGES" + }, + "pascalCase": { + "unsafeName": "CursorPages", + "safeName": "CursorPages" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "next", + "camelCase": { + "unsafeName": "next", + "safeName": "next" + }, + "snakeCase": { + "unsafeName": "next", + "safeName": "next" + }, + "screamingSnakeCase": { + "unsafeName": "NEXT", + "safeName": "NEXT" + }, + "pascalCase": { + "unsafeName": "Next", + "safeName": "Next" + } + }, + "wireValue": "next" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "named", + "value": "type_complex:StartingAfterPaging" + } + } + }, + { + "name": { + "name": { + "originalName": "page", + "camelCase": { + "unsafeName": "page", + "safeName": "page" + }, + "snakeCase": { + "unsafeName": "page", + "safeName": "page" + }, + "screamingSnakeCase": { + "unsafeName": "PAGE", + "safeName": "PAGE" + }, + "pascalCase": { + "unsafeName": "Page", + "safeName": "Page" + } + }, + "wireValue": "page" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "INTEGER" + } + } + }, + { + "name": { + "name": { + "originalName": "per_page", + "camelCase": { + "unsafeName": "perPage", + "safeName": "perPage" + }, + "snakeCase": { + "unsafeName": "per_page", + "safeName": "per_page" + }, + "screamingSnakeCase": { + "unsafeName": "PER_PAGE", + "safeName": "PER_PAGE" + }, + "pascalCase": { + "unsafeName": "PerPage", + "safeName": "PerPage" + } + }, + "wireValue": "per_page" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "INTEGER" + } + } + }, + { + "name": { + "name": { + "originalName": "total_pages", + "camelCase": { + "unsafeName": "totalPages", + "safeName": "totalPages" + }, + "snakeCase": { + "unsafeName": "total_pages", + "safeName": "total_pages" + }, + "screamingSnakeCase": { + "unsafeName": "TOTAL_PAGES", + "safeName": "TOTAL_PAGES" + }, + "pascalCase": { + "unsafeName": "TotalPages", + "safeName": "TotalPages" + } + }, + "wireValue": "total_pages" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "INTEGER" + } + } + }, + { + "name": { + "name": { + "originalName": "type", + "camelCase": { + "unsafeName": "type", + "safeName": "type" + }, + "snakeCase": { + "unsafeName": "type", + "safeName": "type" + }, + "screamingSnakeCase": { + "unsafeName": "TYPE", + "safeName": "TYPE" + }, + "pascalCase": { + "unsafeName": "Type", + "safeName": "Type" + } + }, + "wireValue": "type" + }, + "typeReference": { + "type": "literal", + "value": { + "type": "string", + "value": "pages" + } + } + } + ] + }, + "type_complex:StartingAfterPaging": { + "type": "object", + "declaration": { + "name": { + "originalName": "StartingAfterPaging", + "camelCase": { + "unsafeName": "startingAfterPaging", + "safeName": "startingAfterPaging" + }, + "snakeCase": { + "unsafeName": "starting_after_paging", + "safeName": "starting_after_paging" + }, + "screamingSnakeCase": { + "unsafeName": "STARTING_AFTER_PAGING", + "safeName": "STARTING_AFTER_PAGING" + }, + "pascalCase": { + "unsafeName": "StartingAfterPaging", + "safeName": "StartingAfterPaging" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "per_page", + "camelCase": { + "unsafeName": "perPage", + "safeName": "perPage" + }, + "snakeCase": { + "unsafeName": "per_page", + "safeName": "per_page" + }, + "screamingSnakeCase": { + "unsafeName": "PER_PAGE", + "safeName": "PER_PAGE" + }, + "pascalCase": { + "unsafeName": "PerPage", + "safeName": "PerPage" + } + }, + "wireValue": "per_page" + }, + "typeReference": { + "type": "primitive", + "value": "INTEGER" + } + }, + { + "name": { + "name": { + "originalName": "starting_after", + "camelCase": { + "unsafeName": "startingAfter", + "safeName": "startingAfter" + }, + "snakeCase": { + "unsafeName": "starting_after", + "safeName": "starting_after" + }, + "screamingSnakeCase": { + "unsafeName": "STARTING_AFTER", + "safeName": "STARTING_AFTER" + }, + "pascalCase": { + "unsafeName": "StartingAfter", + "safeName": "StartingAfter" + } + }, + "wireValue": "starting_after" + }, + "typeReference": { + "type": "optional", + "value": { + "type": "primitive", + "value": "STRING" + } + } + } + ] + }, + "type_complex:Conversation": { + "type": "object", + "declaration": { + "name": { + "originalName": "Conversation", + "camelCase": { + "unsafeName": "conversation", + "safeName": "conversation" + }, + "snakeCase": { + "unsafeName": "conversation", + "safeName": "conversation" + }, + "screamingSnakeCase": { + "unsafeName": "CONVERSATION", + "safeName": "CONVERSATION" + }, + "pascalCase": { + "unsafeName": "Conversation", + "safeName": "Conversation" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "properties": [ + { + "name": { + "name": { + "originalName": "foo", + "camelCase": { + "unsafeName": "foo", + "safeName": "foo" + }, + "snakeCase": { + "unsafeName": "foo", + "safeName": "foo" + }, + "screamingSnakeCase": { + "unsafeName": "FOO", + "safeName": "FOO" + }, + "pascalCase": { + "unsafeName": "Foo", + "safeName": "Foo" + } + }, + "wireValue": "foo" + }, + "typeReference": { + "type": "primitive", + "value": "STRING" + } + } + ] + }, "type_users:Order": { "type": "enum", "declaration": { @@ -2092,6 +3714,112 @@ }, "headers": [], "endpoints": { + "endpoint_complex.search": { + "auth": { + "type": "bearer", + "token": { + "originalName": "token", + "camelCase": { + "unsafeName": "token", + "safeName": "token" + }, + "snakeCase": { + "unsafeName": "token", + "safeName": "token" + }, + "screamingSnakeCase": { + "unsafeName": "TOKEN", + "safeName": "TOKEN" + }, + "pascalCase": { + "unsafeName": "Token", + "safeName": "Token" + } + } + }, + "declaration": { + "name": { + "originalName": "search", + "camelCase": { + "unsafeName": "search", + "safeName": "search" + }, + "snakeCase": { + "unsafeName": "search", + "safeName": "search" + }, + "screamingSnakeCase": { + "unsafeName": "SEARCH", + "safeName": "SEARCH" + }, + "pascalCase": { + "unsafeName": "Search", + "safeName": "Search" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + ], + "packagePath": [], + "file": { + "originalName": "complex", + "camelCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "snakeCase": { + "unsafeName": "complex", + "safeName": "complex" + }, + "screamingSnakeCase": { + "unsafeName": "COMPLEX", + "safeName": "COMPLEX" + }, + "pascalCase": { + "unsafeName": "Complex", + "safeName": "Complex" + } + } + } + }, + "location": { + "method": "POST", + "path": "/conversations/search" + }, + "request": { + "type": "body", + "pathParameters": [], + "body": { + "type": "typeReference", + "value": { + "type": "named", + "value": "type_complex:SearchRequest" + } + } + }, + "response": { + "type": "json" + } + }, "endpoint_users.listWithCursorPagination": { "auth": { "type": "bearer", diff --git a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/java-pagination-deep-cursor-path.json b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/java-pagination-deep-cursor-path.json new file mode 100644 index 00000000000..33e7138e210 --- /dev/null +++ b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/java-pagination-deep-cursor-path.json @@ -0,0 +1,517 @@ +{ + "types": { + "type_deep-cursor-path:D": { + "name": "D", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "starting_after", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + } + ] + } + }, + "type_deep-cursor-path:C": { + "name": "C", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "d", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_deep-cursor-path:D" + } + } + } + ] + } + }, + "type_deep-cursor-path:B": { + "name": "B", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "c", + "valueType": { + "type": "id", + "value": "type_deep-cursor-path:C" + } + } + ] + } + }, + "type_deep-cursor-path:A": { + "name": "A", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "b", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_deep-cursor-path:B" + } + } + } + ] + } + }, + "type_deep-cursor-path:Response": { + "name": "Response", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "starting_after", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + }, + { + "key": "results", + "valueType": { + "type": "list", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + } + ] + } + }, + "type_deep-cursor-path:IndirectionRequired": { + "name": "IndirectionRequired", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "starting_after", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + }, + { + "key": "results", + "valueType": { + "type": "list", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + } + ] + } + }, + "type_deep-cursor-path:MainRequired": { + "name": "MainRequired", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "indirection", + "valueType": { + "type": "id", + "value": "type_deep-cursor-path:IndirectionRequired" + } + } + ] + } + }, + "type_deep-cursor-path:InlineD": { + "name": "InlineD", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "starting_after", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + } + ] + } + }, + "type_deep-cursor-path:InlineC": { + "name": "InlineC", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "b", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_deep-cursor-path:InlineD" + } + } + } + ] + } + }, + "type_deep-cursor-path:InlineB": { + "name": "InlineB", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "c", + "valueType": { + "type": "id", + "value": "type_deep-cursor-path:InlineC" + } + } + ] + } + }, + "type_deep-cursor-path:InlineA": { + "name": "InlineA", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "b", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_deep-cursor-path:InlineB" + } + } + } + ] + } + } + }, + "subpackages": { + "subpackage_deep-cursor-path": { + "subpackageId": "subpackage_deep-cursor-path", + "displayName": "Long Path", + "name": "deep-cursor-path", + "endpoints": [ + { + "auth": false, + "method": "POST", + "id": "do-thing", + "originalEndpointId": "endpoint_deep-cursor-path.do-thing", + "name": "Do Thing", + "path": { + "pathParameters": [], + "parts": [ + { + "type": "literal", + "value": "" + }, + { + "type": "literal", + "value": "/" + } + ] + }, + "queryParameters": [], + "headers": [], + "request": { + "type": { + "type": "json", + "contentType": "application/json", + "shape": { + "type": "reference", + "value": { + "type": "id", + "value": "type_deep-cursor-path:A" + } + } + } + }, + "response": { + "type": { + "type": "reference", + "value": { + "type": "id", + "value": "type_deep-cursor-path:Response" + } + } + }, + "errorsV2": [], + "examples": [ + { + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": {}, + "requestBodyV3": { + "type": "json", + "value": {} + }, + "responseStatusCode": 200, + "responseBody": { + "starting_after": "starting_after", + "results": [ + "results", + "results" + ] + }, + "responseBodyV3": { + "type": "json", + "value": { + "starting_after": "starting_after", + "results": [ + "results", + "results" + ] + } + }, + "codeSamples": [] + } + ] + }, + { + "auth": false, + "method": "POST", + "id": "do-thing-required", + "originalEndpointId": "endpoint_deep-cursor-path.do-thing-required", + "name": "Do Thing", + "path": { + "pathParameters": [], + "parts": [ + { + "type": "literal", + "value": "" + }, + { + "type": "literal", + "value": "/" + } + ] + }, + "queryParameters": [], + "headers": [], + "request": { + "type": { + "type": "json", + "contentType": "application/json", + "shape": { + "type": "reference", + "value": { + "type": "id", + "value": "type_deep-cursor-path:MainRequired" + } + } + } + }, + "response": { + "type": { + "type": "reference", + "value": { + "type": "id", + "value": "type_deep-cursor-path:Response" + } + } + }, + "errorsV2": [], + "examples": [ + { + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "indirection": { + "results": [ + "results", + "results" + ] + } + }, + "requestBodyV3": { + "type": "json", + "value": { + "indirection": { + "results": [ + "results", + "results" + ] + } + } + }, + "responseStatusCode": 200, + "responseBody": { + "starting_after": "starting_after", + "results": [ + "results", + "results" + ] + }, + "responseBodyV3": { + "type": "json", + "value": { + "starting_after": "starting_after", + "results": [ + "results", + "results" + ] + } + }, + "codeSamples": [] + } + ] + }, + { + "auth": false, + "method": "POST", + "id": "do-thing-inline", + "originalEndpointId": "endpoint_deep-cursor-path.do-thing-inline", + "name": "Do Thing", + "path": { + "pathParameters": [], + "parts": [ + { + "type": "literal", + "value": "" + }, + { + "type": "literal", + "value": "/" + } + ] + }, + "queryParameters": [], + "headers": [], + "request": { + "type": { + "type": "json", + "contentType": "application/json", + "shape": { + "type": "reference", + "value": { + "type": "id", + "value": "type_deep-cursor-path:InlineA" + } + } + } + }, + "response": { + "type": { + "type": "reference", + "value": { + "type": "id", + "value": "type_deep-cursor-path:Response" + } + } + }, + "errorsV2": [], + "examples": [ + { + "path": "", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": {}, + "requestBodyV3": { + "type": "json", + "value": {} + }, + "responseStatusCode": 200, + "responseBody": { + "starting_after": "starting_after", + "results": [ + "results", + "results" + ] + }, + "responseBodyV3": { + "type": "json", + "value": { + "starting_after": "starting_after", + "results": [ + "results", + "results" + ] + } + }, + "codeSamples": [] + } + ] + } + ], + "webhooks": [], + "websockets": [], + "types": [ + "type_deep-cursor-path:D", + "type_deep-cursor-path:C", + "type_deep-cursor-path:B", + "type_deep-cursor-path:A", + "type_deep-cursor-path:Response", + "type_deep-cursor-path:IndirectionRequired", + "type_deep-cursor-path:MainRequired", + "type_deep-cursor-path:InlineD", + "type_deep-cursor-path:InlineC", + "type_deep-cursor-path:InlineB", + "type_deep-cursor-path:InlineA" + ], + "subpackages": [] + } + }, + "rootPackage": { + "endpoints": [], + "webhooks": [], + "websockets": [], + "types": [], + "subpackages": [ + "subpackage_deep-cursor-path" + ] + }, + "snippetsConfiguration": {}, + "globalHeaders": [] +} \ No newline at end of file diff --git a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/pagination.json b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/pagination.json index fbfe6929cf1..bfeba257ad5 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/pagination.json +++ b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/pagination.json @@ -49,6 +49,365 @@ ] } }, + "type_complex:SearchRequestQuery": { + "name": "SearchRequestQuery", + "shape": { + "type": "undiscriminatedUnion", + "variants": [ + { + "typeName": "SingleFilterSearchRequest", + "type": { + "type": "id", + "value": "type_complex:SingleFilterSearchRequest" + } + }, + { + "typeName": "MultipleFilterSearchRequest", + "type": { + "type": "id", + "value": "type_complex:MultipleFilterSearchRequest" + } + } + ] + } + }, + "type_complex:MultipleFilterSearchRequest": { + "name": "MultipleFilterSearchRequest", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "operator", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_complex:MultipleFilterSearchRequestOperator" + } + } + }, + { + "key": "value", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_complex:MultipleFilterSearchRequestValue" + } + } + } + ] + } + }, + "type_complex:MultipleFilterSearchRequestOperator": { + "name": "MultipleFilterSearchRequestOperator", + "shape": { + "type": "enum", + "values": [ + { + "value": "AND" + }, + { + "value": "OR" + } + ] + } + }, + "type_complex:MultipleFilterSearchRequestValue": { + "name": "MultipleFilterSearchRequestValue", + "shape": { + "type": "undiscriminatedUnion", + "variants": [ + { + "type": { + "type": "list", + "itemType": { + "type": "id", + "value": "type_complex:MultipleFilterSearchRequest" + } + } + }, + { + "type": { + "type": "list", + "itemType": { + "type": "id", + "value": "type_complex:SingleFilterSearchRequest" + } + } + } + ] + } + }, + "type_complex:SingleFilterSearchRequest": { + "name": "SingleFilterSearchRequest", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "field", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + }, + { + "key": "operator", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_complex:SingleFilterSearchRequestOperator" + } + } + }, + { + "key": "value", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + } + ] + } + }, + "type_complex:SingleFilterSearchRequestOperator": { + "name": "SingleFilterSearchRequestOperator", + "shape": { + "type": "enum", + "values": [ + { + "value": "=" + }, + { + "value": "!=" + }, + { + "value": "IN" + }, + { + "value": "NIN" + }, + { + "value": "<" + }, + { + "value": ">" + }, + { + "value": "~" + }, + { + "value": "!~" + }, + { + "value": "^" + }, + { + "value": "$" + } + ] + } + }, + "type_complex:SearchRequest": { + "name": "SearchRequest", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "pagination", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_complex:StartingAfterPaging" + } + } + }, + { + "key": "query", + "valueType": { + "type": "id", + "value": "type_complex:SearchRequestQuery" + } + } + ] + } + }, + "type_complex:PaginatedConversationResponse": { + "name": "PaginatedConversationResponse", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "conversations", + "valueType": { + "type": "list", + "itemType": { + "type": "id", + "value": "type_complex:Conversation" + } + } + }, + { + "key": "pages", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_complex:CursorPages" + } + } + }, + { + "key": "total_count", + "valueType": { + "type": "primitive", + "value": { + "type": "integer" + } + } + }, + { + "key": "type", + "valueType": { + "type": "literal", + "value": { + "type": "stringLiteral", + "value": "conversation.list" + } + } + } + ] + } + }, + "type_complex:CursorPages": { + "name": "CursorPages", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "next", + "valueType": { + "type": "optional", + "itemType": { + "type": "id", + "value": "type_complex:StartingAfterPaging" + } + } + }, + { + "key": "page", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "integer" + } + } + } + }, + { + "key": "per_page", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "integer" + } + } + } + }, + { + "key": "total_pages", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "integer" + } + } + } + }, + { + "key": "type", + "valueType": { + "type": "literal", + "value": { + "type": "stringLiteral", + "value": "pages" + } + } + } + ] + } + }, + "type_complex:StartingAfterPaging": { + "name": "StartingAfterPaging", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "per_page", + "valueType": { + "type": "primitive", + "value": { + "type": "integer" + } + } + }, + { + "key": "starting_after", + "valueType": { + "type": "optional", + "itemType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + } + ] + } + }, + "type_complex:Conversation": { + "name": "Conversation", + "shape": { + "type": "object", + "extends": [], + "properties": [ + { + "key": "foo", + "valueType": { + "type": "primitive", + "value": { + "type": "string" + } + } + } + ] + } + }, "type_users:Order": { "name": "Order", "shape": { @@ -447,6 +806,140 @@ } }, "subpackages": { + "subpackage_complex": { + "subpackageId": "subpackage_complex", + "displayName": "Conversations", + "name": "complex", + "endpoints": [ + { + "auth": true, + "method": "POST", + "id": "search", + "originalEndpointId": "endpoint_complex.search", + "name": "Search conversations", + "path": { + "pathParameters": [], + "parts": [ + { + "type": "literal", + "value": "" + }, + { + "type": "literal", + "value": "/conversations/search" + } + ] + }, + "queryParameters": [], + "headers": [], + "request": { + "type": { + "type": "json", + "contentType": "application/json", + "shape": { + "type": "reference", + "value": { + "type": "id", + "value": "type_complex:SearchRequest" + } + } + } + }, + "response": { + "type": { + "type": "reference", + "value": { + "type": "id", + "value": "type_complex:PaginatedConversationResponse" + } + } + }, + "errorsV2": [], + "examples": [ + { + "path": "/conversations/search", + "pathParameters": {}, + "queryParameters": {}, + "headers": {}, + "requestBody": { + "query": {} + }, + "requestBodyV3": { + "type": "json", + "value": { + "query": {} + } + }, + "responseStatusCode": 200, + "responseBody": { + "conversations": [ + { + "foo": "foo" + }, + { + "foo": "foo" + } + ], + "pages": { + "next": { + "per_page": 1, + "starting_after": "starting_after" + }, + "page": 1, + "per_page": 1, + "total_pages": 1, + "type": "pages" + }, + "total_count": 1, + "type": "conversation.list" + }, + "responseBodyV3": { + "type": "json", + "value": { + "conversations": [ + { + "foo": "foo" + }, + { + "foo": "foo" + } + ], + "pages": { + "next": { + "per_page": 1, + "starting_after": "starting_after" + }, + "page": 1, + "per_page": 1, + "total_pages": 1, + "type": "pages" + }, + "total_count": 1, + "type": "conversation.list" + } + }, + "codeSamples": [] + } + ] + } + ], + "webhooks": [], + "websockets": [], + "types": [ + "type_complex:SearchRequestQuery", + "type_complex:MultipleFilterSearchRequest", + "type_complex:MultipleFilterSearchRequestOperator", + "type_complex:MultipleFilterSearchRequestValue", + "type_complex:SingleFilterSearchRequest", + "type_complex:SingleFilterSearchRequestOperator", + "type_complex:SearchRequest", + "type_complex:PaginatedConversationResponse", + "type_complex:CursorPages", + "type_complex:StartingAfterPaging", + "type_complex:Conversation" + ], + "subpackages": [] + }, "subpackage_users": { "subpackageId": "subpackage_users", "name": "users", @@ -1761,6 +2254,7 @@ "type_:UsernamePage" ], "subpackages": [ + "subpackage_complex", "subpackage_users" ] }, diff --git a/seed/java-model/pagination/.mock/definition/complex.yml b/seed/java-model/pagination/.mock/definition/complex.yml new file mode 100644 index 00000000000..538b1882df8 --- /dev/null +++ b/seed/java-model/pagination/.mock/definition/complex.yml @@ -0,0 +1,112 @@ +types: + SearchRequestQuery: + discriminated: false + inline: true + union: + - type: SingleFilterSearchRequest + - type: MultipleFilterSearchRequest + MultipleFilterSearchRequest: + properties: + operator: + type: optional + value: + type: optional + MultipleFilterSearchRequestOperator: + enum: + - AND + - OR + inline: true + MultipleFilterSearchRequestValue: + discriminated: false + inline: true + union: + - type: list + - type: list + SingleFilterSearchRequest: + properties: + field: + type: optional + operator: + type: optional + value: + type: optional + SingleFilterSearchRequestOperator: + enum: + - name: Equals + value: '=' + - name: NotEquals + value: '!=' + - name: In + value: IN + - name: NotIn + value: NIN + - name: LessThan + value: < + - name: GreaterThan + value: '>' + - name: Contains + value: '~' + - name: DoesNotContain + value: '!~' + - name: StartsWith + value: ^ + - name: EndsWith + value: $ + inline: true + SearchRequest: + properties: + pagination: + type: optional + query: SearchRequestQuery + PaginatedConversationResponse: + properties: + conversations: + type: list + pages: + type: optional + total_count: + type: integer + type: + type: literal<"conversation.list"> + CursorPages: + properties: + next: + type: optional + page: + type: optional + per_page: + type: optional + total_pages: + type: optional + type: + type: literal<"pages"> + StartingAfterPaging: + properties: + per_page: + type: integer + starting_after: + type: optional + Conversation: + properties: + foo: string +service: + auth: false + base-path: '' + display-name: Conversations + endpoints: + search: + auth: true + display-name: Search conversations + method: POST + pagination: + cursor: $request.pagination.starting_after + next_cursor: $response.pages.next.starting_after + results: $response.conversations + path: /conversations/search + request: + body: + type: SearchRequest + content-type: application/json + response: + type: PaginatedConversationResponse + diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/Conversation.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/Conversation.java new file mode 100644 index 00000000000..b045a298467 --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/Conversation.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Conversation.Builder.class) +public final class Conversation { + private final String foo; + + private Conversation(String foo) { + this.foo = foo; + } + + @JsonProperty("foo") + public String getFoo() { + return foo; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Conversation && equalTo((Conversation) other); + } + + private boolean equalTo(Conversation other) { + return foo.equals(other.foo); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.foo); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static FooStage builder() { + return new Builder(); + } + + public interface FooStage { + _FinalStage foo(String foo); + + Builder from(Conversation other); + } + + public interface _FinalStage { + Conversation build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements FooStage, _FinalStage { + private String foo; + + private Builder() {} + + @java.lang.Override + public Builder from(Conversation other) { + foo(other.getFoo()); + return this; + } + + @java.lang.Override + @JsonSetter("foo") + public _FinalStage foo(String foo) { + this.foo = Objects.requireNonNull(foo, "foo must not be null"); + return this; + } + + @java.lang.Override + public Conversation build() { + return new Conversation(foo); + } + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/CursorPages.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/CursorPages.java new file mode 100644 index 00000000000..9864d78c86d --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/CursorPages.java @@ -0,0 +1,158 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CursorPages.Builder.class) +public final class CursorPages { + private final Optional next; + + private final Optional page; + + private final Optional perPage; + + private final Optional totalPages; + + private CursorPages( + Optional next, + Optional page, + Optional perPage, + Optional totalPages) { + this.next = next; + this.page = page; + this.perPage = perPage; + this.totalPages = totalPages; + } + + @JsonProperty("next") + public Optional getNext() { + return next; + } + + @JsonProperty("page") + public Optional getPage() { + return page; + } + + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @JsonProperty("total_pages") + public Optional getTotalPages() { + return totalPages; + } + + @JsonProperty("type") + public String getType() { + return "pages"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CursorPages && equalTo((CursorPages) other); + } + + private boolean equalTo(CursorPages other) { + return next.equals(other.next) + && page.equals(other.page) + && perPage.equals(other.perPage) + && totalPages.equals(other.totalPages); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.next, this.page, this.perPage, this.totalPages); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional next = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional perPage = Optional.empty(); + + private Optional totalPages = Optional.empty(); + + private Builder() {} + + public Builder from(CursorPages other) { + next(other.getNext()); + page(other.getPage()); + perPage(other.getPerPage()); + totalPages(other.getTotalPages()); + return this; + } + + @JsonSetter(value = "next", nulls = Nulls.SKIP) + public Builder next(Optional next) { + this.next = next; + return this; + } + + public Builder next(StartingAfterPaging next) { + this.next = Optional.ofNullable(next); + return this; + } + + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public Builder page(Optional page) { + this.page = page; + return this; + } + + public Builder page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + @JsonSetter(value = "per_page", nulls = Nulls.SKIP) + public Builder perPage(Optional perPage) { + this.perPage = perPage; + return this; + } + + public Builder perPage(Integer perPage) { + this.perPage = Optional.ofNullable(perPage); + return this; + } + + @JsonSetter(value = "total_pages", nulls = Nulls.SKIP) + public Builder totalPages(Optional totalPages) { + this.totalPages = totalPages; + return this; + } + + public Builder totalPages(Integer totalPages) { + this.totalPages = Optional.ofNullable(totalPages); + return this; + } + + public CursorPages build() { + return new CursorPages(next, page, perPage, totalPages); + } + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequest.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequest.java new file mode 100644 index 00000000000..6f179df9526 --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequest.java @@ -0,0 +1,103 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = MultipleFilterSearchRequest.Builder.class) +public final class MultipleFilterSearchRequest { + private final Optional operator; + + private final Optional value; + + private MultipleFilterSearchRequest( + Optional operator, Optional value) { + this.operator = operator; + this.value = value; + } + + @JsonProperty("operator") + public Optional getOperator() { + return operator; + } + + @JsonProperty("value") + public Optional getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MultipleFilterSearchRequest && equalTo((MultipleFilterSearchRequest) other); + } + + private boolean equalTo(MultipleFilterSearchRequest other) { + return operator.equals(other.operator) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.operator, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional operator = Optional.empty(); + + private Optional value = Optional.empty(); + + private Builder() {} + + public Builder from(MultipleFilterSearchRequest other) { + operator(other.getOperator()); + value(other.getValue()); + return this; + } + + @JsonSetter(value = "operator", nulls = Nulls.SKIP) + public Builder operator(Optional operator) { + this.operator = operator; + return this; + } + + public Builder operator(MultipleFilterSearchRequestOperator operator) { + this.operator = Optional.ofNullable(operator); + return this; + } + + @JsonSetter(value = "value", nulls = Nulls.SKIP) + public Builder value(Optional value) { + this.value = value; + return this; + } + + public Builder value(MultipleFilterSearchRequestValue value) { + this.value = Optional.ofNullable(value); + return this; + } + + public MultipleFilterSearchRequest build() { + return new MultipleFilterSearchRequest(operator, value); + } + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequestOperator.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequestOperator.java new file mode 100644 index 00000000000..60fcb1adabf --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequestOperator.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum MultipleFilterSearchRequestOperator { + AND("AND"), + + OR("OR"); + + private final String value; + + MultipleFilterSearchRequestOperator(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequestValue.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequestValue.java new file mode 100644 index 00000000000..777dfee1a34 --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/MultipleFilterSearchRequestValue.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.seed.pagination.core.ObjectMappers; +import java.io.IOException; +import java.util.List; +import java.util.Objects; + +@JsonDeserialize(using = MultipleFilterSearchRequestValue.Deserializer.class) +public final class MultipleFilterSearchRequestValue { + private final Object value; + + private final int type; + + private MultipleFilterSearchRequestValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visitListOfMultipleFilterSearchRequest((List) this.value); + } else if (this.type == 1) { + return visitor.visitListOfSingleFilterSearchRequest((List) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MultipleFilterSearchRequestValue && equalTo((MultipleFilterSearchRequestValue) other); + } + + private boolean equalTo(MultipleFilterSearchRequestValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static MultipleFilterSearchRequestValue ofListOfMultipleFilterSearchRequest( + List value) { + return new MultipleFilterSearchRequestValue(value, 0); + } + + public static MultipleFilterSearchRequestValue ofListOfSingleFilterSearchRequest( + List value) { + return new MultipleFilterSearchRequestValue(value, 1); + } + + public interface Visitor { + T visitListOfMultipleFilterSearchRequest(List value); + + T visitListOfSingleFilterSearchRequest(List value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(MultipleFilterSearchRequestValue.class); + } + + @java.lang.Override + public MultipleFilterSearchRequestValue deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return ofListOfMultipleFilterSearchRequest(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + try { + return ofListOfSingleFilterSearchRequest(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/PaginatedConversationResponse.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/PaginatedConversationResponse.java new file mode 100644 index 00000000000..afc901c648e --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/PaginatedConversationResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaginatedConversationResponse.Builder.class) +public final class PaginatedConversationResponse { + private final List conversations; + + private final Optional pages; + + private final int totalCount; + + private PaginatedConversationResponse( + List conversations, Optional pages, int totalCount) { + this.conversations = conversations; + this.pages = pages; + this.totalCount = totalCount; + } + + @JsonProperty("conversations") + public List getConversations() { + return conversations; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + @JsonProperty("total_count") + public int getTotalCount() { + return totalCount; + } + + @JsonProperty("type") + public String getType() { + return "conversation.list"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaginatedConversationResponse && equalTo((PaginatedConversationResponse) other); + } + + private boolean equalTo(PaginatedConversationResponse other) { + return conversations.equals(other.conversations) && pages.equals(other.pages) && totalCount == other.totalCount; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversations, this.pages, this.totalCount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalCountStage builder() { + return new Builder(); + } + + public interface TotalCountStage { + _FinalStage totalCount(int totalCount); + + Builder from(PaginatedConversationResponse other); + } + + public interface _FinalStage { + PaginatedConversationResponse build(); + + _FinalStage conversations(List conversations); + + _FinalStage addConversations(Conversation conversations); + + _FinalStage addAllConversations(List conversations); + + _FinalStage pages(Optional pages); + + _FinalStage pages(CursorPages pages); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TotalCountStage, _FinalStage { + private int totalCount; + + private Optional pages = Optional.empty(); + + private List conversations = new ArrayList<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PaginatedConversationResponse other) { + conversations(other.getConversations()); + pages(other.getPages()); + totalCount(other.getTotalCount()); + return this; + } + + @java.lang.Override + @JsonSetter("total_count") + public _FinalStage totalCount(int totalCount) { + this.totalCount = totalCount; + return this; + } + + @java.lang.Override + public _FinalStage pages(CursorPages pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + @java.lang.Override + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public _FinalStage pages(Optional pages) { + this.pages = pages; + return this; + } + + @java.lang.Override + public _FinalStage addAllConversations(List conversations) { + this.conversations.addAll(conversations); + return this; + } + + @java.lang.Override + public _FinalStage addConversations(Conversation conversations) { + this.conversations.add(conversations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "conversations", nulls = Nulls.SKIP) + public _FinalStage conversations(List conversations) { + this.conversations.clear(); + this.conversations.addAll(conversations); + return this; + } + + @java.lang.Override + public PaginatedConversationResponse build() { + return new PaginatedConversationResponse(conversations, pages, totalCount); + } + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SearchRequest.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SearchRequest.java new file mode 100644 index 00000000000..9d206e30787 --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SearchRequest.java @@ -0,0 +1,116 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SearchRequest.Builder.class) +public final class SearchRequest { + private final Optional pagination; + + private final SearchRequestQuery query; + + private SearchRequest(Optional pagination, SearchRequestQuery query) { + this.pagination = pagination; + this.query = query; + } + + @JsonProperty("pagination") + public Optional getPagination() { + return pagination; + } + + @JsonProperty("query") + public SearchRequestQuery getQuery() { + return query; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SearchRequest && equalTo((SearchRequest) other); + } + + private boolean equalTo(SearchRequest other) { + return pagination.equals(other.pagination) && query.equals(other.query); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pagination, this.query); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static QueryStage builder() { + return new Builder(); + } + + public interface QueryStage { + _FinalStage query(SearchRequestQuery query); + + Builder from(SearchRequest other); + } + + public interface _FinalStage { + SearchRequest build(); + + _FinalStage pagination(Optional pagination); + + _FinalStage pagination(StartingAfterPaging pagination); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements QueryStage, _FinalStage { + private SearchRequestQuery query; + + private Optional pagination = Optional.empty(); + + private Builder() {} + + @java.lang.Override + public Builder from(SearchRequest other) { + pagination(other.getPagination()); + query(other.getQuery()); + return this; + } + + @java.lang.Override + @JsonSetter("query") + public _FinalStage query(SearchRequestQuery query) { + this.query = Objects.requireNonNull(query, "query must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage pagination(StartingAfterPaging pagination) { + this.pagination = Optional.ofNullable(pagination); + return this; + } + + @java.lang.Override + @JsonSetter(value = "pagination", nulls = Nulls.SKIP) + public _FinalStage pagination(Optional pagination) { + this.pagination = pagination; + return this; + } + + @java.lang.Override + public SearchRequest build() { + return new SearchRequest(pagination, query); + } + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SearchRequestQuery.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SearchRequestQuery.java new file mode 100644 index 00000000000..27046cb9d37 --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SearchRequestQuery.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.seed.pagination.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = SearchRequestQuery.Deserializer.class) +public final class SearchRequestQuery { + private final Object value; + + private final int type; + + private SearchRequestQuery(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((SingleFilterSearchRequest) this.value); + } else if (this.type == 1) { + return visitor.visit((MultipleFilterSearchRequest) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SearchRequestQuery && equalTo((SearchRequestQuery) other); + } + + private boolean equalTo(SearchRequestQuery other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static SearchRequestQuery of(SingleFilterSearchRequest value) { + return new SearchRequestQuery(value, 0); + } + + public static SearchRequestQuery of(MultipleFilterSearchRequest value) { + return new SearchRequestQuery(value, 1); + } + + public interface Visitor { + T visit(SingleFilterSearchRequest value); + + T visit(MultipleFilterSearchRequest value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(SearchRequestQuery.class); + } + + @java.lang.Override + public SearchRequestQuery deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, SingleFilterSearchRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, MultipleFilterSearchRequest.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SingleFilterSearchRequest.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SingleFilterSearchRequest.java new file mode 100644 index 00000000000..95a1b8bee50 --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SingleFilterSearchRequest.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SingleFilterSearchRequest.Builder.class) +public final class SingleFilterSearchRequest { + private final Optional field; + + private final Optional operator; + + private final Optional value; + + private SingleFilterSearchRequest( + Optional field, Optional operator, Optional value) { + this.field = field; + this.operator = operator; + this.value = value; + } + + @JsonProperty("field") + public Optional getField() { + return field; + } + + @JsonProperty("operator") + public Optional getOperator() { + return operator; + } + + @JsonProperty("value") + public Optional getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SingleFilterSearchRequest && equalTo((SingleFilterSearchRequest) other); + } + + private boolean equalTo(SingleFilterSearchRequest other) { + return field.equals(other.field) && operator.equals(other.operator) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.field, this.operator, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional field = Optional.empty(); + + private Optional operator = Optional.empty(); + + private Optional value = Optional.empty(); + + private Builder() {} + + public Builder from(SingleFilterSearchRequest other) { + field(other.getField()); + operator(other.getOperator()); + value(other.getValue()); + return this; + } + + @JsonSetter(value = "field", nulls = Nulls.SKIP) + public Builder field(Optional field) { + this.field = field; + return this; + } + + public Builder field(String field) { + this.field = Optional.ofNullable(field); + return this; + } + + @JsonSetter(value = "operator", nulls = Nulls.SKIP) + public Builder operator(Optional operator) { + this.operator = operator; + return this; + } + + public Builder operator(SingleFilterSearchRequestOperator operator) { + this.operator = Optional.ofNullable(operator); + return this; + } + + @JsonSetter(value = "value", nulls = Nulls.SKIP) + public Builder value(Optional value) { + this.value = value; + return this; + } + + public Builder value(String value) { + this.value = Optional.ofNullable(value); + return this; + } + + public SingleFilterSearchRequest build() { + return new SingleFilterSearchRequest(field, operator, value); + } + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SingleFilterSearchRequestOperator.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SingleFilterSearchRequestOperator.java new file mode 100644 index 00000000000..b35e2bdbcc6 --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/SingleFilterSearchRequestOperator.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum SingleFilterSearchRequestOperator { + EQUALS("="), + + NOT_EQUALS("!="), + + IN("IN"), + + NOT_IN("NIN"), + + LESS_THAN("<"), + + GREATER_THAN(">"), + + CONTAINS("~"), + + DOES_NOT_CONTAIN("!~"), + + STARTS_WITH("^"), + + ENDS_WITH("$"); + + private final String value; + + SingleFilterSearchRequestOperator(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/StartingAfterPaging.java b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/StartingAfterPaging.java new file mode 100644 index 00000000000..182a3fa0a08 --- /dev/null +++ b/seed/java-model/pagination/src/main/java/com/seed/pagination/model/complex/StartingAfterPaging.java @@ -0,0 +1,116 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.model.complex; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = StartingAfterPaging.Builder.class) +public final class StartingAfterPaging { + private final int perPage; + + private final Optional startingAfter; + + private StartingAfterPaging(int perPage, Optional startingAfter) { + this.perPage = perPage; + this.startingAfter = startingAfter; + } + + @JsonProperty("per_page") + public int getPerPage() { + return perPage; + } + + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StartingAfterPaging && equalTo((StartingAfterPaging) other); + } + + private boolean equalTo(StartingAfterPaging other) { + return perPage == other.perPage && startingAfter.equals(other.startingAfter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.perPage, this.startingAfter); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PerPageStage builder() { + return new Builder(); + } + + public interface PerPageStage { + _FinalStage perPage(int perPage); + + Builder from(StartingAfterPaging other); + } + + public interface _FinalStage { + StartingAfterPaging build(); + + _FinalStage startingAfter(Optional startingAfter); + + _FinalStage startingAfter(String startingAfter); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PerPageStage, _FinalStage { + private int perPage; + + private Optional startingAfter = Optional.empty(); + + private Builder() {} + + @java.lang.Override + public Builder from(StartingAfterPaging other) { + perPage(other.getPerPage()); + startingAfter(other.getStartingAfter()); + return this; + } + + @java.lang.Override + @JsonSetter("per_page") + public _FinalStage perPage(int perPage) { + this.perPage = perPage; + return this; + } + + @java.lang.Override + public _FinalStage startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + @java.lang.Override + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public _FinalStage startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + @java.lang.Override + public StartingAfterPaging build() { + return new StartingAfterPaging(perPage, startingAfter); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.github/workflows/ci.yml b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.github/workflows/ci.yml new file mode 100644 index 00000000000..9910fd269c2 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: ci + +on: [push] + +jobs: + compile: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Java + id: setup-jre + uses: actions/setup-java@v1 + with: + java-version: "11" + architecture: x64 + + - name: Compile + run: ./gradlew compileJava + + test: + needs: [ compile ] + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Java + id: setup-jre + uses: actions/setup-java@v1 + with: + java-version: "11" + architecture: x64 + + - name: Test + run: ./gradlew test + publish: + needs: [ compile, test ] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Java + id: setup-jre + uses: actions/setup-java@v1 + with: + java-version: "11" + architecture: x64 + + - name: Publish to maven + run: | + ./gradlew publish + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + MAVEN_PUBLISH_REGISTRY_URL: "" diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.gitignore b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.gitignore new file mode 100644 index 00000000000..d4199abc2cd --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.gitignore @@ -0,0 +1,24 @@ +*.class +.project +.gradle +? +.classpath +.checkstyle +.settings +.node +build + +# IntelliJ +*.iml +*.ipr +*.iws +.idea/ +out/ + +# Eclipse/IntelliJ APT +generated_src/ +generated_testSrc/ +generated/ + +bin +build \ No newline at end of file diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/definition/api.yml b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/definition/api.yml new file mode 100644 index 00000000000..edd7278a9cb --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/definition/api.yml @@ -0,0 +1,2 @@ +name: deep-cursor-path + diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/definition/deep-cursor-path.yml b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/definition/deep-cursor-path.yml new file mode 100644 index 00000000000..ed77043545a --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/definition/deep-cursor-path.yml @@ -0,0 +1,87 @@ +types: + D: + properties: + starting_after: optional + C: + properties: + d: optional + B: + properties: + c: C + A: + properties: + b: optional + Response: + properties: + starting_after: optional + results: list + IndirectionRequired: + properties: + starting_after: optional + results: list + MainRequired: + properties: + indirection: IndirectionRequired + InlineD: + inline: true + properties: + starting_after: optional + InlineC: + inline: true + properties: + b: optional + InlineB: + inline: true + properties: + c: InlineC + InlineA: + inline: true + properties: + b: optional +service: + auth: false + base-path: '' + display-name: Long Path + endpoints: + do-thing: + display-name: Do Thing + method: POST + pagination: + cursor: $request.b.c.d.starting_after + next_cursor: $response.starting_after + results: $response.results + path: / + request: + body: + type: A + content-type: application/json + response: + type: Response + do-thing-required: + display-name: Do Thing + method: POST + pagination: + cursor: $request.indirection.starting_after + next_cursor: $response.starting_after + results: $response.results + path: / + request: + body: + type: MainRequired + content-type: application/json + response: + type: Response + do-thing-inline: + display-name: Do Thing + method: POST + pagination: + cursor: $request.b.c.b.starting_after + next_cursor: $response.starting_after + results: $response.results + path: / + request: + body: + type: InlineA + content-type: application/json + response: + type: Response diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/fern.config.json b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/fern.config.json new file mode 100644 index 00000000000..4c8e54ac313 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/fern.config.json @@ -0,0 +1 @@ +{"organization": "fern-test", "version": "*"} \ No newline at end of file diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/generators.yml b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/generators.yml new file mode 100644 index 00000000000..311847daa5a --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/.mock/generators.yml @@ -0,0 +1,2 @@ +{} + diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/build.gradle b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/build.gradle new file mode 100644 index 00000000000..9765c03d6b4 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/build.gradle @@ -0,0 +1,101 @@ +plugins { + id 'java-library' + id 'maven-publish' + id 'com.diffplug.spotless' version '6.11.0' +} + +repositories { + mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/releases/' + } +} + +dependencies { + api 'com.squareup.okhttp3:okhttp:4.12.0' + api 'com.fasterxml.jackson.core:jackson-databind:2.17.2' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' +} + + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +tasks.withType(Javadoc) { + failOnError false + options.addStringOption('Xdoclint:none', '-quiet') +} + +spotless { + java { + palantirJavaFormat() + } +} + + +java { + withSourcesJar() + withJavadocJar() +} + + +group = 'com.fern' + +version = '0.0.1' + +jar { + dependsOn(":generatePomFileForMavenPublication") + archiveBaseName = "java-pagination-deep-cursor-path" +} + +sourcesJar { + archiveBaseName = "java-pagination-deep-cursor-path" +} + +javadocJar { + archiveBaseName = "java-pagination-deep-cursor-path" +} + +test { + useJUnitPlatform() + testLogging { + showStandardStreams = true + } +} + +publishing { + publications { + maven(MavenPublication) { + groupId = 'com.fern' + artifactId = 'java-pagination-deep-cursor-path' + version = '0.0.1' + from components.java + pom { + licenses { + license { + name = 'The MIT License (MIT)' + url = 'https://mit-license.org/' + } + } + scm { + connection = 'scm:git:git://github.com/java-pagination-deep-cursor-path/fern.git' + developerConnection = 'scm:git:git://github.com/java-pagination-deep-cursor-path/fern.git' + url = 'https://github.com/java-pagination-deep-cursor-path/fern' + } + } + } + } + repositories { + maven { + url "$System.env.MAVEN_PUBLISH_REGISTRY_URL" + credentials { + username "$System.env.MAVEN_USERNAME" + password "$System.env.MAVEN_PASSWORD" + } + } + } +} + diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/sample-app/build.gradle b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/sample-app/build.gradle new file mode 100644 index 00000000000..4ee8f227b7a --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/sample-app/build.gradle @@ -0,0 +1,19 @@ +plugins { + id 'java-library' +} + +repositories { + mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/releases/' + } +} + +dependencies { + implementation rootProject +} + + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/sample-app/src/main/java/sample/App.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/sample-app/src/main/java/sample/App.java new file mode 100644 index 00000000000..9b1ace8f865 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/sample-app/src/main/java/sample/App.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package sample; + +import java.lang.String; + +public final class App { + public static void main(String[] args) { + // import com.seed.deepCursorPath.SeedDeepCursorPathClient + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/settings.gradle b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/settings.gradle new file mode 100644 index 00000000000..b69f0ad5df1 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/settings.gradle @@ -0,0 +1,3 @@ +rootProject.name = 'java-pagination-deep-cursor-path' + +include 'sample-app' \ No newline at end of file diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/snippet-templates.json b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/snippet-templates.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/snippet.json b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/snippet.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/SeedDeepCursorPathClient.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/SeedDeepCursorPathClient.java new file mode 100644 index 00000000000..1ce90f9e738 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/SeedDeepCursorPathClient.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath; + +import com.seed.deepCursorPath.core.ClientOptions; +import com.seed.deepCursorPath.core.Suppliers; +import com.seed.deepCursorPath.resources.deepcursorpath.DeepCursorPathClient; +import java.util.function.Supplier; + +public class SeedDeepCursorPathClient { + protected final ClientOptions clientOptions; + + protected final Supplier deepCursorPathClient; + + public SeedDeepCursorPathClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.deepCursorPathClient = Suppliers.memoize(() -> new DeepCursorPathClient(clientOptions)); + } + + public DeepCursorPathClient deepCursorPath() { + return this.deepCursorPathClient.get(); + } + + public static SeedDeepCursorPathClientBuilder builder() { + return new SeedDeepCursorPathClientBuilder(); + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/SeedDeepCursorPathClientBuilder.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/SeedDeepCursorPathClientBuilder.java new file mode 100644 index 00000000000..4cf489fb846 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/SeedDeepCursorPathClientBuilder.java @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath; + +import com.seed.deepCursorPath.core.ClientOptions; +import com.seed.deepCursorPath.core.Environment; + +public final class SeedDeepCursorPathClientBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private Environment environment; + + public SeedDeepCursorPathClientBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client + */ + public SeedDeepCursorPathClientBuilder timeout(int timeout) { + this.clientOptionsBuilder.timeout(timeout); + return this; + } + + public SeedDeepCursorPathClient build() { + clientOptionsBuilder.environment(this.environment); + return new SeedDeepCursorPathClient(clientOptionsBuilder.build()); + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ClientOptions.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ClientOptions.java new file mode 100644 index 00000000000..9259154ad7e --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ClientOptions.java @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; +import okhttp3.OkHttpClient; + +public final class ClientOptions { + private final Environment environment; + + private final Map headers; + + private final Map> headerSuppliers; + + private final OkHttpClient httpClient; + + private final int timeout; + + private ClientOptions( + Environment environment, + Map headers, + Map> headerSuppliers, + OkHttpClient httpClient, + int timeout) { + this.environment = environment; + this.headers = new HashMap<>(); + this.headers.putAll(headers); + this.headers.putAll(new HashMap() { + { + put("X-Fern-Language", "JAVA"); + } + }); + this.headerSuppliers = headerSuppliers; + this.httpClient = httpClient; + this.timeout = timeout; + } + + public Environment environment() { + return this.environment; + } + + public Map headers(RequestOptions requestOptions) { + Map values = new HashMap<>(this.headers); + headerSuppliers.forEach((key, supplier) -> { + values.put(key, supplier.get()); + }); + if (requestOptions != null) { + values.putAll(requestOptions.getHeaders()); + } + return values; + } + + public OkHttpClient httpClient() { + return this.httpClient; + } + + public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.httpClient; + } + return this.httpClient + .newBuilder() + .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .build(); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Environment environment; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + private int timeout = 60; + + public Builder environment(Environment environment) { + this.environment = environment; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(int timeout) { + this.timeout = timeout; + return this; + } + + public ClientOptions build() { + OkHttpClient okhttpClient = new OkHttpClient.Builder() + .addInterceptor(new RetryInterceptor(3)) + .callTimeout(this.timeout, TimeUnit.SECONDS) + .build(); + return new ClientOptions(environment, headers, headerSuppliers, okhttpClient, this.timeout); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/DateTimeDeserializer.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/DateTimeDeserializer.java new file mode 100644 index 00000000000..92610738286 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/DateTimeDeserializer.java @@ -0,0 +1,55 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQueries; + +/** + * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. + */ +class DateTimeDeserializer extends JsonDeserializer { + private static final SimpleModule MODULE; + + static { + MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer()); + } + + /** + * Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper. + * + * @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper. + */ + public static SimpleModule getModule() { + return MODULE; + } + + @Override + public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + JsonToken token = parser.currentToken(); + if (token == JsonToken.VALUE_NUMBER_INT) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC); + } else { + TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( + parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from); + + if (temporal.query(TemporalQueries.offset()) == null) { + return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC); + } else { + return OffsetDateTime.from(temporal); + } + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Environment.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Environment.java new file mode 100644 index 00000000000..aabf92c32dd --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Environment.java @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +public final class Environment { + private final String url; + + private Environment(String url) { + this.url = url; + } + + public String getUrl() { + return this.url; + } + + public static Environment custom(String url) { + return new Environment(url); + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/FileStream.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/FileStream.java new file mode 100644 index 00000000000..8bba5e5e440 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/FileStream.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.io.InputStream; +import java.util.Objects; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a file stream with associated metadata for file uploads. + */ +public class FileStream { + private final InputStream inputStream; + private final String fileName; + private final MediaType contentType; + + /** + * Constructs a FileStream with the given input stream and optional metadata. + * + * @param inputStream The input stream of the file content. Must not be null. + * @param fileName The name of the file, or null if unknown. + * @param contentType The MIME type of the file content, or null if unknown. + * @throws NullPointerException if inputStream is null + */ + public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) { + this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null"); + this.fileName = fileName; + this.contentType = contentType; + } + + public FileStream(InputStream inputStream) { + this(inputStream, null, null); + } + + public InputStream getInputStream() { + return inputStream; + } + + @Nullable + public String getFileName() { + return fileName; + } + + @Nullable + public MediaType getContentType() { + return contentType; + } + + /** + * Creates a RequestBody suitable for use with OkHttp client. + * + * @return A RequestBody instance representing this file stream. + */ + public RequestBody toRequestBody() { + return new InputStreamRequestBody(contentType, inputStream); + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/InputStreamRequestBody.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/InputStreamRequestBody.java new file mode 100644 index 00000000000..ef0aca5bc52 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/InputStreamRequestBody.java @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.internal.Util; +import okio.BufferedSink; +import okio.Okio; +import okio.Source; +import org.jetbrains.annotations.Nullable; + +/** + * A custom implementation of OkHttp's RequestBody that wraps an InputStream. + * This class allows streaming of data from an InputStream directly to an HTTP request body, + * which is useful for file uploads or sending large amounts of data without loading it all into memory. + */ +public class InputStreamRequestBody extends RequestBody { + private final InputStream inputStream; + private final MediaType contentType; + + /** + * Constructs an InputStreamRequestBody with the specified content type and input stream. + * + * @param contentType the MediaType of the content, or null if not known + * @param inputStream the InputStream containing the data to be sent + * @throws NullPointerException if inputStream is null + */ + public InputStreamRequestBody(@Nullable MediaType contentType, InputStream inputStream) { + this.contentType = contentType; + this.inputStream = Objects.requireNonNull(inputStream, "inputStream == null"); + } + + /** + * Returns the content type of this request body. + * + * @return the MediaType of the content, or null if not specified + */ + @Nullable + @Override + public MediaType contentType() { + return contentType; + } + + /** + * Returns the content length of this request body, if known. + * This method attempts to determine the length using the InputStream's available() method, + * which may not always accurately reflect the total length of the stream. + * + * @return the content length, or -1 if the length is unknown + * @throws IOException if an I/O error occurs + */ + @Override + public long contentLength() throws IOException { + return inputStream.available() == 0 ? -1 : inputStream.available(); + } + + /** + * Writes the content of the InputStream to the given BufferedSink. + * This method is responsible for transferring the data from the InputStream to the network request. + * + * @param sink the BufferedSink to write the content to + * @throws IOException if an I/O error occurs during writing + */ + @Override + public void writeTo(BufferedSink sink) throws IOException { + Source source = null; + try { + source = Okio.source(inputStream); + sink.writeAll(source); + } finally { + Util.closeQuietly(Objects.requireNonNull(source)); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/MediaTypes.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/MediaTypes.java new file mode 100644 index 00000000000..ac5a442e513 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/MediaTypes.java @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import okhttp3.MediaType; + +public final class MediaTypes { + + public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); + + private MediaTypes() {} +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ObjectMappers.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ObjectMappers.java new file mode 100644 index 00000000000..9b1d451b073 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ObjectMappers.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import java.io.IOException; + +public final class ObjectMappers { + public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() + .addModule(new Jdk8Module()) + .addModule(new JavaTimeModule()) + .addModule(DateTimeDeserializer.getModule()) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); + + private ObjectMappers() {} + + public static String stringify(Object o) { + try { + return JSON_MAPPER + .setSerializationInclusion(JsonInclude.Include.ALWAYS) + .writerWithDefaultPrettyPrinter() + .writeValueAsString(o); + } catch (IOException e) { + return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/RequestOptions.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/RequestOptions.java new file mode 100644 index 00000000000..6da5d378a22 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/RequestOptions.java @@ -0,0 +1,58 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +public final class RequestOptions { + private final Optional timeout; + + private final TimeUnit timeoutTimeUnit; + + private RequestOptions(Optional timeout, TimeUnit timeoutTimeUnit) { + this.timeout = timeout; + this.timeoutTimeUnit = timeoutTimeUnit; + } + + public Optional getTimeout() { + return timeout; + } + + public TimeUnit getTimeoutTimeUnit() { + return timeoutTimeUnit; + } + + public Map getHeaders() { + Map headers = new HashMap<>(); + return headers; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Optional timeout = Optional.empty(); + + private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; + + public Builder timeout(Integer timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { + this.timeout = Optional.of(timeout); + this.timeoutTimeUnit = timeoutTimeUnit; + return this; + } + + public RequestOptions build() { + return new RequestOptions(timeout, timeoutTimeUnit); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ResponseBodyInputStream.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ResponseBodyInputStream.java new file mode 100644 index 00000000000..dbbd670a04a --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ResponseBodyInputStream.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.io.FilterInputStream; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom InputStream that wraps the InputStream from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the stream is closed. + * + * This class extends FilterInputStream and takes an OkHttp Response object as a parameter. + * It retrieves the InputStream from the Response and overrides the close method to close + * both the InputStream and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyInputStream extends FilterInputStream { + private final Response response; + + /** + * Constructs a ResponseBodyInputStream that wraps the InputStream from the given OkHttp + * Response object. + * + * @param response the OkHttp Response object from which the InputStream is retrieved + * @throws IOException if an I/O error occurs while retrieving the InputStream + */ + public ResponseBodyInputStream(Response response) throws IOException { + super(response.body().byteStream()); + this.response = response; + } + + /** + * Closes the InputStream and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the stream is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the stream is closed + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ResponseBodyReader.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ResponseBodyReader.java new file mode 100644 index 00000000000..3b869f6ece8 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/ResponseBodyReader.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.io.FilterReader; +import java.io.IOException; +import okhttp3.Response; + +/** + * A custom Reader that wraps the Reader from the OkHttp Response and ensures that the + * OkHttp Response object is properly closed when the reader is closed. + * + * This class extends FilterReader and takes an OkHttp Response object as a parameter. + * It retrieves the Reader from the Response and overrides the close method to close + * both the Reader and the Response object, ensuring proper resource management and preventing + * premature closure of the underlying HTTP connection. + */ +public class ResponseBodyReader extends FilterReader { + private final Response response; + + /** + * Constructs a ResponseBodyReader that wraps the Reader from the given OkHttp Response object. + * + * @param response the OkHttp Response object from which the Reader is retrieved + * @throws IOException if an I/O error occurs while retrieving the Reader + */ + public ResponseBodyReader(Response response) throws IOException { + super(response.body().charStream()); + this.response = response; + } + + /** + * Closes the Reader and the associated OkHttp Response object. This ensures that the + * underlying HTTP connection is properly closed after the reader is no longer needed. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + super.close(); + response.close(); // Ensure the response is closed when the reader is closed + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/RetryInterceptor.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/RetryInterceptor.java new file mode 100644 index 00000000000..9772e0d2401 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/RetryInterceptor.java @@ -0,0 +1,78 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.io.IOException; +import java.time.Duration; +import java.util.Optional; +import java.util.Random; +import okhttp3.Interceptor; +import okhttp3.Response; + +public class RetryInterceptor implements Interceptor { + + private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private final ExponentialBackoff backoff; + private final Random random = new Random(); + + public RetryInterceptor(int maxRetries) { + this.backoff = new ExponentialBackoff(maxRetries); + } + + @Override + public Response intercept(Chain chain) throws IOException { + Response response = chain.proceed(chain.request()); + + if (shouldRetry(response.code())) { + return retryChain(response, chain); + } + + return response; + } + + private Response retryChain(Response response, Chain chain) throws IOException { + Optional nextBackoff = this.backoff.nextBackoff(); + while (nextBackoff.isPresent()) { + try { + Thread.sleep(nextBackoff.get().toMillis()); + } catch (InterruptedException e) { + throw new IOException("Interrupted while trying request", e); + } + response.close(); + response = chain.proceed(chain.request()); + if (shouldRetry(response.code())) { + nextBackoff = this.backoff.nextBackoff(); + } else { + return response; + } + } + + return response; + } + + private static boolean shouldRetry(int statusCode) { + return statusCode == 408 || statusCode == 409 || statusCode == 429 || statusCode >= 500; + } + + private final class ExponentialBackoff { + + private final int maxNumRetries; + + private int retryNumber = 0; + + ExponentialBackoff(int maxNumRetries) { + this.maxNumRetries = maxNumRetries; + } + + public Optional nextBackoff() { + retryNumber += 1; + if (retryNumber > maxNumRetries) { + return Optional.empty(); + } + + int upperBound = (int) Math.pow(2, retryNumber); + return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/SeedDeepCursorPathApiException.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/SeedDeepCursorPathApiException.java new file mode 100644 index 00000000000..824b41bb515 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/SeedDeepCursorPathApiException.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +/** + * This exception type will be thrown for any non-2XX API responses. + */ +public class SeedDeepCursorPathApiException extends SeedDeepCursorPathException { + /** + * The error code of the response that triggered the exception. + */ + private final int statusCode; + + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public SeedDeepCursorPathApiException(String message, int statusCode, Object body) { + super(message); + this.statusCode = statusCode; + this.body = body; + } + + /** + * @return the statusCode + */ + public int statusCode() { + return this.statusCode; + } + + /** + * @return the body + */ + public Object body() { + return this.body; + } + + @java.lang.Override + public String toString() { + return "SeedDeepCursorPathApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + + ", body: " + body + "}"; + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/SeedDeepCursorPathException.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/SeedDeepCursorPathException.java new file mode 100644 index 00000000000..6808c2b31a6 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/SeedDeepCursorPathException.java @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +/** + * This class serves as the base exception for all errors in the SDK. + */ +public class SeedDeepCursorPathException extends RuntimeException { + public SeedDeepCursorPathException(String message) { + super(message); + } + + public SeedDeepCursorPathException(String message, Exception e) { + super(message, e); + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Stream.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Stream.java new file mode 100644 index 00000000000..c3df0ce1136 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Stream.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.io.Reader; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Scanner; + +/** + * The {@code Stream} class implmenets {@link Iterable} to provide a simple mechanism for reading and parsing + * objects of a given type from data streamed via a {@link Reader} using a specified delimiter. + *

+ * {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a + * {@code Scanner} to block during iteration if the next object is not available. + * + * @param The type of objects in the stream. + */ +public final class Stream implements Iterable { + /** + * The {@link Class} of the objects in the stream. + */ + private final Class valueType; + /** + * The {@link Scanner} used for reading from the input stream and blocking when neede during iteration. + */ + private final Scanner scanner; + + /** + * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. + * + * @param valueType The class of the objects in the stream. + * @param reader The reader that provides the streamed data. + * @param delimiter The delimiter used to separate elements in the stream. + */ + public Stream(Class valueType, Reader reader, String delimiter) { + this.scanner = new Scanner(reader).useDelimiter(delimiter); + this.valueType = valueType; + } + + /** + * Returns an iterator over the elements in this stream that blocks during iteration when the next object is + * not yet available. + * + * @return An iterator that can be used to traverse the elements in the stream. + */ + @Override + public Iterator iterator() { + return new Iterator() { + /** + * Returns {@code true} if there are more elements in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return {@code true} if there are more elements, {@code false} otherwise. + */ + @Override + public boolean hasNext() { + return scanner.hasNext(); + } + + /** + * Returns the next element in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return The next element in the stream. + * @throws NoSuchElementException If there are no more elements in the stream. + */ + @Override + public T next() { + if (!scanner.hasNext()) { + throw new NoSuchElementException(); + } else { + try { + T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + scanner.next().trim(), valueType); + return parsedResponse; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * Removing elements from {@code Stream} is not supported. + * + * @throws UnsupportedOperationException Always, as removal is not supported. + */ + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Suppliers.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Suppliers.java new file mode 100644 index 00000000000..9b259923891 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/Suppliers.java @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +public final class Suppliers { + private Suppliers() {} + + public static Supplier memoize(Supplier delegate) { + AtomicReference value = new AtomicReference<>(); + return () -> { + T val = value.get(); + if (val == null) { + val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); + } + return val; + }; + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/BasePage.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/BasePage.java new file mode 100644 index 00000000000..91038cca555 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/BasePage.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core.pagination; + +import java.util.List; + +public abstract class BasePage { + private final boolean hasNext; + private final List items; + + public BasePage(boolean hasNext, List items) { + this.hasNext = hasNext; + this.items = items; + } + + public boolean hasNext() { + return !items.isEmpty() && hasNext; + } + + public List getItems() { + return items; + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/SyncPage.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/SyncPage.java new file mode 100644 index 00000000000..4c1d457a083 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/SyncPage.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core.pagination; + +import java.util.List; +import java.util.NoSuchElementException; +import java.util.function.Supplier; + +public class SyncPage extends BasePage { + protected final Supplier> nextSupplier; + + public SyncPage(boolean hasNext, List items, Supplier> nextSupplier) { + super(hasNext, items); + this.nextSupplier = nextSupplier; + } + + public SyncPage nextPage() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + return nextSupplier.get(); + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/SyncPagingIterable.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/SyncPagingIterable.java new file mode 100644 index 00000000000..09ecfe72ae2 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/core/pagination/SyncPagingIterable.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.core.pagination; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.function.Supplier; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +public class SyncPagingIterable extends SyncPage implements Iterable { + + public SyncPagingIterable(boolean hasNext, List items, Supplier> getNext) { + super(hasNext, items, getNext); + } + + public SyncPagingIterable(boolean hasNext, Optional> items, Supplier> getNext) { + super(hasNext, items.orElse(new ArrayList<>()), getNext); + } + + public Stream streamItems() { + return StreamSupport.stream(this.spliterator(), false); + } + + @Override + public Iterator iterator() { + return new Iterator() { + private Iterator itemsIterator = getItems().iterator(); + private SyncPage currentPage = SyncPagingIterable.this; + + @Override + public boolean hasNext() { + if (itemsIterator.hasNext()) { + return true; + } + if (currentPage.hasNext()) { + advancePage(); + return itemsIterator.hasNext(); + } + return false; + } + + @Override + public T next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + return itemsIterator.next(); + } + + private void advancePage() { + currentPage = currentPage.nextPage(); + itemsIterator = currentPage.getItems().iterator(); + } + }; + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/DeepCursorPathClient.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/DeepCursorPathClient.java new file mode 100644 index 00000000000..894894d191f --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/DeepCursorPathClient.java @@ -0,0 +1,220 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.seed.deepCursorPath.core.ClientOptions; +import com.seed.deepCursorPath.core.MediaTypes; +import com.seed.deepCursorPath.core.ObjectMappers; +import com.seed.deepCursorPath.core.RequestOptions; +import com.seed.deepCursorPath.core.SeedDeepCursorPathApiException; +import com.seed.deepCursorPath.core.SeedDeepCursorPathException; +import com.seed.deepCursorPath.core.pagination.SyncPagingIterable; +import com.seed.deepCursorPath.resources.deepcursorpath.types.A; +import com.seed.deepCursorPath.resources.deepcursorpath.types.B; +import com.seed.deepCursorPath.resources.deepcursorpath.types.C; +import com.seed.deepCursorPath.resources.deepcursorpath.types.D; +import com.seed.deepCursorPath.resources.deepcursorpath.types.IndirectionRequired; +import com.seed.deepCursorPath.resources.deepcursorpath.types.InlineA; +import com.seed.deepCursorPath.resources.deepcursorpath.types.InlineC; +import com.seed.deepCursorPath.resources.deepcursorpath.types.InlineD; +import com.seed.deepCursorPath.resources.deepcursorpath.types.MainRequired; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class DeepCursorPathClient { + protected final ClientOptions clientOptions; + + public DeepCursorPathClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public SyncPagingIterable doThing() { + return doThing(A.builder().build()); + } + + public SyncPagingIterable doThing(A request) { + return doThing(request, null); + } + + public SyncPagingIterable doThing(A request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new SeedDeepCursorPathException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + com.seed.deepCursorPath.resources.deepcursorpath.types.Response parsedResponse = + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), + com.seed.deepCursorPath.resources.deepcursorpath.types.Response.class); + Optional startingAfter = parsedResponse.getStartingAfter(); + Optional d = request.getB().map(B::getC).flatMap(C::getD).map(d_ -> D.builder() + .from(d_) + .startingAfter(startingAfter) + .build()); + Optional c = d.flatMap(d_ -> request.getB() + .map(B::getC) + .map(c_ -> C.builder().from(c_).d(d_).build())); + Optional b = c.flatMap(c_ -> + request.getB().map(b_ -> B.builder().from(b_).c(c_).build())); + A nextRequest = A.builder().from(request).b(b).build(); + List result = parsedResponse.getResults(); + return new SyncPagingIterable<>( + startingAfter.isPresent(), result, () -> doThing(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SeedDeepCursorPathApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new SeedDeepCursorPathException("Network error executing HTTP request", e); + } + } + + public SyncPagingIterable doThingRequired(MainRequired request) { + return doThingRequired(request, null); + } + + public SyncPagingIterable doThingRequired(MainRequired request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new SeedDeepCursorPathException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + com.seed.deepCursorPath.resources.deepcursorpath.types.Response parsedResponse = + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), + com.seed.deepCursorPath.resources.deepcursorpath.types.Response.class); + Optional startingAfter = parsedResponse.getStartingAfter(); + IndirectionRequired indirection = IndirectionRequired.builder() + .from(com.seed.deepCursorPath.resources.deepcursorpath.types.IndirectionRequired) + .startingAfter(startingAfter) + .build(); + MainRequired nextRequest = MainRequired.builder() + .from(request) + .indirection(indirection) + .build(); + List result = parsedResponse.getResults(); + return new SyncPagingIterable<>( + startingAfter.isPresent(), result, () -> doThingRequired(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SeedDeepCursorPathApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new SeedDeepCursorPathException("Network error executing HTTP request", e); + } + } + + public SyncPagingIterable doThingInline() { + return doThingInline(InlineA.builder().build()); + } + + public SyncPagingIterable doThingInline(InlineA request) { + return doThingInline(request, null); + } + + public SyncPagingIterable doThingInline(InlineA request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new SeedDeepCursorPathException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + com.seed.deepCursorPath.resources.deepcursorpath.types.Response parsedResponse = + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), + com.seed.deepCursorPath.resources.deepcursorpath.types.Response.class); + Optional startingAfter = parsedResponse.getStartingAfter(); + Optional b = request.getB() + .map(B::getC) + .flatMap(C::getB) + .map(b_ -> InlineD.builder() + .from(b_) + .startingAfter(startingAfter) + .build()); + Optional c = b.flatMap(b_ -> request.getB() + .map(B::getC) + .map(c_ -> InlineC.builder().from(c_).b(b_).build())); + Optional b = c.flatMap(c_ -> request.getB() + .map(b_ -> InlineD.builder().from(b_).c(c_).build())); + InlineA nextRequest = InlineA.builder().from(request).b(b).build(); + List result = parsedResponse.getResults(); + return new SyncPagingIterable<>( + startingAfter.isPresent(), result, () -> doThingInline(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SeedDeepCursorPathApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new SeedDeepCursorPathException("Network error executing HTTP request", e); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/A.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/A.java new file mode 100644 index 00000000000..6cfd2336ce5 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/A.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = A.Builder.class) +public final class A { + private final Optional b; + + private final Map additionalProperties; + + private A(Optional b, Map additionalProperties) { + this.b = b; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("b") + public Optional getB() { + return b; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof A && equalTo((A) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(A other) { + return b.equals(other.b); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.b); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional b = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(A other) { + b(other.getB()); + return this; + } + + @JsonSetter(value = "b", nulls = Nulls.SKIP) + public Builder b(Optional b) { + this.b = b; + return this; + } + + public Builder b(B b) { + this.b = Optional.ofNullable(b); + return this; + } + + public A build() { + return new A(b, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/B.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/B.java new file mode 100644 index 00000000000..88ba2fea25a --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/B.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = B.Builder.class) +public final class B { + private final C c; + + private final Map additionalProperties; + + private B(C c, Map additionalProperties) { + this.c = c; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("c") + public C getC() { + return c; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof B && equalTo((B) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(B other) { + return c.equals(other.c); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.c); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CStage builder() { + return new Builder(); + } + + public interface CStage { + _FinalStage c(@NotNull C c); + + Builder from(B other); + } + + public interface _FinalStage { + B build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CStage, _FinalStage { + private C c; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(B other) { + c(other.getC()); + return this; + } + + @java.lang.Override + @JsonSetter("c") + public _FinalStage c(@NotNull C c) { + this.c = Objects.requireNonNull(c, "c must not be null"); + return this; + } + + @java.lang.Override + public B build() { + return new B(c, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/C.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/C.java new file mode 100644 index 00000000000..6331568da83 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/C.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = C.Builder.class) +public final class C { + private final Optional d; + + private final Map additionalProperties; + + private C(Optional d, Map additionalProperties) { + this.d = d; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("d") + public Optional getD() { + return d; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof C && equalTo((C) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(C other) { + return d.equals(other.d); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.d); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional d = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(C other) { + d(other.getD()); + return this; + } + + @JsonSetter(value = "d", nulls = Nulls.SKIP) + public Builder d(Optional d) { + this.d = d; + return this; + } + + public Builder d(D d) { + this.d = Optional.ofNullable(d); + return this; + } + + public C build() { + return new C(d, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/D.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/D.java new file mode 100644 index 00000000000..7022ff8e759 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/D.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = D.Builder.class) +public final class D { + private final Optional startingAfter; + + private final Map additionalProperties; + + private D(Optional startingAfter, Map additionalProperties) { + this.startingAfter = startingAfter; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof D && equalTo((D) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(D other) { + return startingAfter.equals(other.startingAfter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.startingAfter); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional startingAfter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(D other) { + startingAfter(other.getStartingAfter()); + return this; + } + + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public Builder startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + public Builder startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + public D build() { + return new D(startingAfter, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/IndirectionRequired.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/IndirectionRequired.java new file mode 100644 index 00000000000..b66e119cfb4 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/IndirectionRequired.java @@ -0,0 +1,126 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = IndirectionRequired.Builder.class) +public final class IndirectionRequired { + private final Optional startingAfter; + + private final List results; + + private final Map additionalProperties; + + private IndirectionRequired( + Optional startingAfter, List results, Map additionalProperties) { + this.startingAfter = startingAfter; + this.results = results; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @JsonProperty("results") + public List getResults() { + return results; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof IndirectionRequired && equalTo((IndirectionRequired) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(IndirectionRequired other) { + return startingAfter.equals(other.startingAfter) && results.equals(other.results); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.startingAfter, this.results); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional startingAfter = Optional.empty(); + + private List results = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(IndirectionRequired other) { + startingAfter(other.getStartingAfter()); + results(other.getResults()); + return this; + } + + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public Builder startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + public Builder startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + @JsonSetter(value = "results", nulls = Nulls.SKIP) + public Builder results(List results) { + this.results.clear(); + this.results.addAll(results); + return this; + } + + public Builder addResults(String results) { + this.results.add(results); + return this; + } + + public Builder addAllResults(List results) { + this.results.addAll(results); + return this; + } + + public IndirectionRequired build() { + return new IndirectionRequired(startingAfter, results, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineA.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineA.java new file mode 100644 index 00000000000..2c05c65cf3e --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineA.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InlineA.Builder.class) +public final class InlineA { + private final Optional b; + + private final Map additionalProperties; + + private InlineA(Optional b, Map additionalProperties) { + this.b = b; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("b") + public Optional getB() { + return b; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InlineA && equalTo((InlineA) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InlineA other) { + return b.equals(other.b); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.b); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional b = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InlineA other) { + b(other.getB()); + return this; + } + + @JsonSetter(value = "b", nulls = Nulls.SKIP) + public Builder b(Optional b) { + this.b = b; + return this; + } + + public Builder b(InlineB b) { + this.b = Optional.ofNullable(b); + return this; + } + + public InlineA build() { + return new InlineA(b, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineB.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineB.java new file mode 100644 index 00000000000..ac7a2300fb0 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineB.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InlineB.Builder.class) +public final class InlineB { + private final InlineC c; + + private final Map additionalProperties; + + private InlineB(InlineC c, Map additionalProperties) { + this.c = c; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("c") + public InlineC getC() { + return c; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InlineB && equalTo((InlineB) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InlineB other) { + return c.equals(other.c); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.c); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CStage builder() { + return new Builder(); + } + + public interface CStage { + _FinalStage c(@NotNull InlineC c); + + Builder from(InlineB other); + } + + public interface _FinalStage { + InlineB build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CStage, _FinalStage { + private InlineC c; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(InlineB other) { + c(other.getC()); + return this; + } + + @java.lang.Override + @JsonSetter("c") + public _FinalStage c(@NotNull InlineC c) { + this.c = Objects.requireNonNull(c, "c must not be null"); + return this; + } + + @java.lang.Override + public InlineB build() { + return new InlineB(c, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineC.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineC.java new file mode 100644 index 00000000000..1419eeab4d4 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineC.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InlineC.Builder.class) +public final class InlineC { + private final Optional b; + + private final Map additionalProperties; + + private InlineC(Optional b, Map additionalProperties) { + this.b = b; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("b") + public Optional getB() { + return b; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InlineC && equalTo((InlineC) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InlineC other) { + return b.equals(other.b); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.b); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional b = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InlineC other) { + b(other.getB()); + return this; + } + + @JsonSetter(value = "b", nulls = Nulls.SKIP) + public Builder b(Optional b) { + this.b = b; + return this; + } + + public Builder b(InlineD b) { + this.b = Optional.ofNullable(b); + return this; + } + + public InlineC build() { + return new InlineC(b, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineD.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineD.java new file mode 100644 index 00000000000..f99acc84c22 --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/InlineD.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = InlineD.Builder.class) +public final class InlineD { + private final Optional startingAfter; + + private final Map additionalProperties; + + private InlineD(Optional startingAfter, Map additionalProperties) { + this.startingAfter = startingAfter; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InlineD && equalTo((InlineD) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InlineD other) { + return startingAfter.equals(other.startingAfter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.startingAfter); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional startingAfter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InlineD other) { + startingAfter(other.getStartingAfter()); + return this; + } + + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public Builder startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + public Builder startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + public InlineD build() { + return new InlineD(startingAfter, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/MainRequired.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/MainRequired.java new file mode 100644 index 00000000000..5e9b5cdfc1f --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/MainRequired.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = MainRequired.Builder.class) +public final class MainRequired { + private final IndirectionRequired indirection; + + private final Map additionalProperties; + + private MainRequired(IndirectionRequired indirection, Map additionalProperties) { + this.indirection = indirection; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("indirection") + public IndirectionRequired getIndirection() { + return indirection; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MainRequired && equalTo((MainRequired) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MainRequired other) { + return indirection.equals(other.indirection); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.indirection); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IndirectionStage builder() { + return new Builder(); + } + + public interface IndirectionStage { + _FinalStage indirection(@NotNull IndirectionRequired indirection); + + Builder from(MainRequired other); + } + + public interface _FinalStage { + MainRequired build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IndirectionStage, _FinalStage { + private IndirectionRequired indirection; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(MainRequired other) { + indirection(other.getIndirection()); + return this; + } + + @java.lang.Override + @JsonSetter("indirection") + public _FinalStage indirection(@NotNull IndirectionRequired indirection) { + this.indirection = Objects.requireNonNull(indirection, "indirection must not be null"); + return this; + } + + @java.lang.Override + public MainRequired build() { + return new MainRequired(indirection, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/Response.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/Response.java new file mode 100644 index 00000000000..e73bde24c6d --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/main/java/com/seed/deepCursorPath/resources/deepcursorpath/types/Response.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath.resources.deepcursorpath.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.deepCursorPath.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Response.Builder.class) +public final class Response { + private final Optional startingAfter; + + private final List results; + + private final Map additionalProperties; + + private Response(Optional startingAfter, List results, Map additionalProperties) { + this.startingAfter = startingAfter; + this.results = results; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @JsonProperty("results") + public List getResults() { + return results; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Response && equalTo((Response) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Response other) { + return startingAfter.equals(other.startingAfter) && results.equals(other.results); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.startingAfter, this.results); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional startingAfter = Optional.empty(); + + private List results = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Response other) { + startingAfter(other.getStartingAfter()); + results(other.getResults()); + return this; + } + + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public Builder startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + public Builder startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + @JsonSetter(value = "results", nulls = Nulls.SKIP) + public Builder results(List results) { + this.results.clear(); + this.results.addAll(results); + return this; + } + + public Builder addResults(String results) { + this.results.add(results); + return this; + } + + public Builder addAllResults(List results) { + this.results.addAll(results); + return this; + } + + public Response build() { + return new Response(startingAfter, results, additionalProperties); + } + } +} diff --git a/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/test/java/com/seed/deepCursorPath/TestClient.java b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/test/java/com/seed/deepCursorPath/TestClient.java new file mode 100644 index 00000000000..b3fc6eda5ef --- /dev/null +++ b/seed/java-sdk/java-pagination-deep-cursor-path/java-pagination-deep-cursor-path/src/test/java/com/seed/deepCursorPath/TestClient.java @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.deepCursorPath; + +public final class TestClient { + public void test() { + // Add tests here and mark this file in .fernignore + assert true; + } +} diff --git a/seed/java-sdk/pagination/.mock/definition/complex.yml b/seed/java-sdk/pagination/.mock/definition/complex.yml new file mode 100644 index 00000000000..538b1882df8 --- /dev/null +++ b/seed/java-sdk/pagination/.mock/definition/complex.yml @@ -0,0 +1,112 @@ +types: + SearchRequestQuery: + discriminated: false + inline: true + union: + - type: SingleFilterSearchRequest + - type: MultipleFilterSearchRequest + MultipleFilterSearchRequest: + properties: + operator: + type: optional + value: + type: optional + MultipleFilterSearchRequestOperator: + enum: + - AND + - OR + inline: true + MultipleFilterSearchRequestValue: + discriminated: false + inline: true + union: + - type: list + - type: list + SingleFilterSearchRequest: + properties: + field: + type: optional + operator: + type: optional + value: + type: optional + SingleFilterSearchRequestOperator: + enum: + - name: Equals + value: '=' + - name: NotEquals + value: '!=' + - name: In + value: IN + - name: NotIn + value: NIN + - name: LessThan + value: < + - name: GreaterThan + value: '>' + - name: Contains + value: '~' + - name: DoesNotContain + value: '!~' + - name: StartsWith + value: ^ + - name: EndsWith + value: $ + inline: true + SearchRequest: + properties: + pagination: + type: optional + query: SearchRequestQuery + PaginatedConversationResponse: + properties: + conversations: + type: list + pages: + type: optional + total_count: + type: integer + type: + type: literal<"conversation.list"> + CursorPages: + properties: + next: + type: optional + page: + type: optional + per_page: + type: optional + total_pages: + type: optional + type: + type: literal<"pages"> + StartingAfterPaging: + properties: + per_page: + type: integer + starting_after: + type: optional + Conversation: + properties: + foo: string +service: + auth: false + base-path: '' + display-name: Conversations + endpoints: + search: + auth: true + display-name: Search conversations + method: POST + pagination: + cursor: $request.pagination.starting_after + next_cursor: $response.pages.next.starting_after + results: $response.conversations + path: /conversations/search + request: + body: + type: SearchRequest + content-type: application/json + response: + type: PaginatedConversationResponse + diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/SeedPaginationClient.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/SeedPaginationClient.java index f06b172de68..9d152af0543 100644 --- a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/SeedPaginationClient.java +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/SeedPaginationClient.java @@ -5,19 +5,27 @@ import com.seed.pagination.core.ClientOptions; import com.seed.pagination.core.Suppliers; +import com.seed.pagination.resources.complex.ComplexClient; import com.seed.pagination.resources.users.UsersClient; import java.util.function.Supplier; public class SeedPaginationClient { protected final ClientOptions clientOptions; + protected final Supplier complexClient; + protected final Supplier usersClient; public SeedPaginationClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.complexClient = Suppliers.memoize(() -> new ComplexClient(clientOptions)); this.usersClient = Suppliers.memoize(() -> new UsersClient(clientOptions)); } + public ComplexClient complex() { + return this.complexClient.get(); + } + public UsersClient users() { return this.usersClient.get(); } diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/ComplexClient.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/ComplexClient.java new file mode 100644 index 00000000000..07b8734ce94 --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/ComplexClient.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.seed.pagination.core.ClientOptions; +import com.seed.pagination.core.MediaTypes; +import com.seed.pagination.core.ObjectMappers; +import com.seed.pagination.core.RequestOptions; +import com.seed.pagination.core.SeedPaginationApiException; +import com.seed.pagination.core.SeedPaginationException; +import com.seed.pagination.core.pagination.SyncPagingIterable; +import com.seed.pagination.resources.complex.types.Conversation; +import com.seed.pagination.resources.complex.types.CursorPages; +import com.seed.pagination.resources.complex.types.PaginatedConversationResponse; +import com.seed.pagination.resources.complex.types.SearchRequest; +import com.seed.pagination.resources.complex.types.StartingAfterPaging; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class ComplexClient { + protected final ClientOptions clientOptions; + + public ComplexClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public SyncPagingIterable search(SearchRequest request) { + return search(request, null); + } + + public SyncPagingIterable search(SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new SeedPaginationException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + PaginatedConversationResponse parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedConversationResponse.class); + Optional startingAfter = parsedResponse + .getPages() + .flatMap(CursorPages::getNext) + .flatMap(StartingAfterPaging::getStartingAfter); + Optional pagination = request.getPagination() + .map(pagination_ -> StartingAfterPaging.builder() + .from(pagination_) + .startingAfter(startingAfter) + .build()); + SearchRequest nextRequest = SearchRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getConversations(); + return new SyncPagingIterable<>( + startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions)); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new SeedPaginationApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); + } catch (IOException e) { + throw new SeedPaginationException("Network error executing HTTP request", e); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/Conversation.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/Conversation.java new file mode 100644 index 00000000000..3b99e901f2a --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/Conversation.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Conversation.Builder.class) +public final class Conversation { + private final String foo; + + private final Map additionalProperties; + + private Conversation(String foo, Map additionalProperties) { + this.foo = foo; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("foo") + public String getFoo() { + return foo; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Conversation && equalTo((Conversation) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Conversation other) { + return foo.equals(other.foo); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.foo); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static FooStage builder() { + return new Builder(); + } + + public interface FooStage { + _FinalStage foo(@NotNull String foo); + + Builder from(Conversation other); + } + + public interface _FinalStage { + Conversation build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements FooStage, _FinalStage { + private String foo; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Conversation other) { + foo(other.getFoo()); + return this; + } + + @java.lang.Override + @JsonSetter("foo") + public _FinalStage foo(@NotNull String foo) { + this.foo = Objects.requireNonNull(foo, "foo must not be null"); + return this; + } + + @java.lang.Override + public Conversation build() { + return new Conversation(foo, additionalProperties); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/CursorPages.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/CursorPages.java new file mode 100644 index 00000000000..1e2e26883af --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/CursorPages.java @@ -0,0 +1,174 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CursorPages.Builder.class) +public final class CursorPages { + private final Optional next; + + private final Optional page; + + private final Optional perPage; + + private final Optional totalPages; + + private final Map additionalProperties; + + private CursorPages( + Optional next, + Optional page, + Optional perPage, + Optional totalPages, + Map additionalProperties) { + this.next = next; + this.page = page; + this.perPage = perPage; + this.totalPages = totalPages; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("next") + public Optional getNext() { + return next; + } + + @JsonProperty("page") + public Optional getPage() { + return page; + } + + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @JsonProperty("total_pages") + public Optional getTotalPages() { + return totalPages; + } + + @JsonProperty("type") + public String getType() { + return "pages"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CursorPages && equalTo((CursorPages) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CursorPages other) { + return next.equals(other.next) + && page.equals(other.page) + && perPage.equals(other.perPage) + && totalPages.equals(other.totalPages); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.next, this.page, this.perPage, this.totalPages); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional next = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional perPage = Optional.empty(); + + private Optional totalPages = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CursorPages other) { + next(other.getNext()); + page(other.getPage()); + perPage(other.getPerPage()); + totalPages(other.getTotalPages()); + return this; + } + + @JsonSetter(value = "next", nulls = Nulls.SKIP) + public Builder next(Optional next) { + this.next = next; + return this; + } + + public Builder next(StartingAfterPaging next) { + this.next = Optional.ofNullable(next); + return this; + } + + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public Builder page(Optional page) { + this.page = page; + return this; + } + + public Builder page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + @JsonSetter(value = "per_page", nulls = Nulls.SKIP) + public Builder perPage(Optional perPage) { + this.perPage = perPage; + return this; + } + + public Builder perPage(Integer perPage) { + this.perPage = Optional.ofNullable(perPage); + return this; + } + + @JsonSetter(value = "total_pages", nulls = Nulls.SKIP) + public Builder totalPages(Optional totalPages) { + this.totalPages = totalPages; + return this; + } + + public Builder totalPages(Integer totalPages) { + this.totalPages = Optional.ofNullable(totalPages); + return this; + } + + public CursorPages build() { + return new CursorPages(next, page, perPage, totalPages, additionalProperties); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequest.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequest.java new file mode 100644 index 00000000000..ca0bfa743d1 --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequest.java @@ -0,0 +1,120 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = MultipleFilterSearchRequest.Builder.class) +public final class MultipleFilterSearchRequest { + private final Optional operator; + + private final Optional value; + + private final Map additionalProperties; + + private MultipleFilterSearchRequest( + Optional operator, + Optional value, + Map additionalProperties) { + this.operator = operator; + this.value = value; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("operator") + public Optional getOperator() { + return operator; + } + + @JsonProperty("value") + public Optional getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MultipleFilterSearchRequest && equalTo((MultipleFilterSearchRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MultipleFilterSearchRequest other) { + return operator.equals(other.operator) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.operator, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional operator = Optional.empty(); + + private Optional value = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(MultipleFilterSearchRequest other) { + operator(other.getOperator()); + value(other.getValue()); + return this; + } + + @JsonSetter(value = "operator", nulls = Nulls.SKIP) + public Builder operator(Optional operator) { + this.operator = operator; + return this; + } + + public Builder operator(MultipleFilterSearchRequestOperator operator) { + this.operator = Optional.ofNullable(operator); + return this; + } + + @JsonSetter(value = "value", nulls = Nulls.SKIP) + public Builder value(Optional value) { + this.value = value; + return this; + } + + public Builder value(MultipleFilterSearchRequestValue value) { + this.value = Optional.ofNullable(value); + return this; + } + + public MultipleFilterSearchRequest build() { + return new MultipleFilterSearchRequest(operator, value, additionalProperties); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequestOperator.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequestOperator.java new file mode 100644 index 00000000000..863fffdcd31 --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequestOperator.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum MultipleFilterSearchRequestOperator { + AND("AND"), + + OR("OR"); + + private final String value; + + MultipleFilterSearchRequestOperator(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequestValue.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequestValue.java new file mode 100644 index 00000000000..50c82a7ca60 --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/MultipleFilterSearchRequestValue.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.seed.pagination.core.ObjectMappers; +import java.io.IOException; +import java.util.List; +import java.util.Objects; + +@JsonDeserialize(using = MultipleFilterSearchRequestValue.Deserializer.class) +public final class MultipleFilterSearchRequestValue { + private final Object value; + + private final int type; + + private MultipleFilterSearchRequestValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visitListOfMultipleFilterSearchRequest((List) this.value); + } else if (this.type == 1) { + return visitor.visitListOfSingleFilterSearchRequest((List) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MultipleFilterSearchRequestValue && equalTo((MultipleFilterSearchRequestValue) other); + } + + private boolean equalTo(MultipleFilterSearchRequestValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static MultipleFilterSearchRequestValue ofListOfMultipleFilterSearchRequest( + List value) { + return new MultipleFilterSearchRequestValue(value, 0); + } + + public static MultipleFilterSearchRequestValue ofListOfSingleFilterSearchRequest( + List value) { + return new MultipleFilterSearchRequestValue(value, 1); + } + + public interface Visitor { + T visitListOfMultipleFilterSearchRequest(List value); + + T visitListOfSingleFilterSearchRequest(List value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(MultipleFilterSearchRequestValue.class); + } + + @java.lang.Override + public MultipleFilterSearchRequestValue deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return ofListOfMultipleFilterSearchRequest(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + try { + return ofListOfSingleFilterSearchRequest(ObjectMappers.JSON_MAPPER.convertValue( + value, new TypeReference>() {})); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/PaginatedConversationResponse.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/PaginatedConversationResponse.java new file mode 100644 index 00000000000..e8bf77ec408 --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/PaginatedConversationResponse.java @@ -0,0 +1,179 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaginatedConversationResponse.Builder.class) +public final class PaginatedConversationResponse { + private final List conversations; + + private final Optional pages; + + private final int totalCount; + + private final Map additionalProperties; + + private PaginatedConversationResponse( + List conversations, + Optional pages, + int totalCount, + Map additionalProperties) { + this.conversations = conversations; + this.pages = pages; + this.totalCount = totalCount; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("conversations") + public List getConversations() { + return conversations; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + @JsonProperty("total_count") + public int getTotalCount() { + return totalCount; + } + + @JsonProperty("type") + public String getType() { + return "conversation.list"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaginatedConversationResponse && equalTo((PaginatedConversationResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaginatedConversationResponse other) { + return conversations.equals(other.conversations) && pages.equals(other.pages) && totalCount == other.totalCount; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversations, this.pages, this.totalCount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalCountStage builder() { + return new Builder(); + } + + public interface TotalCountStage { + _FinalStage totalCount(int totalCount); + + Builder from(PaginatedConversationResponse other); + } + + public interface _FinalStage { + PaginatedConversationResponse build(); + + _FinalStage conversations(List conversations); + + _FinalStage addConversations(Conversation conversations); + + _FinalStage addAllConversations(List conversations); + + _FinalStage pages(Optional pages); + + _FinalStage pages(CursorPages pages); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TotalCountStage, _FinalStage { + private int totalCount; + + private Optional pages = Optional.empty(); + + private List conversations = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PaginatedConversationResponse other) { + conversations(other.getConversations()); + pages(other.getPages()); + totalCount(other.getTotalCount()); + return this; + } + + @java.lang.Override + @JsonSetter("total_count") + public _FinalStage totalCount(int totalCount) { + this.totalCount = totalCount; + return this; + } + + @java.lang.Override + public _FinalStage pages(CursorPages pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + @java.lang.Override + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public _FinalStage pages(Optional pages) { + this.pages = pages; + return this; + } + + @java.lang.Override + public _FinalStage addAllConversations(List conversations) { + this.conversations.addAll(conversations); + return this; + } + + @java.lang.Override + public _FinalStage addConversations(Conversation conversations) { + this.conversations.add(conversations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "conversations", nulls = Nulls.SKIP) + public _FinalStage conversations(List conversations) { + this.conversations.clear(); + this.conversations.addAll(conversations); + return this; + } + + @java.lang.Override + public PaginatedConversationResponse build() { + return new PaginatedConversationResponse(conversations, pages, totalCount, additionalProperties); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SearchRequest.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SearchRequest.java new file mode 100644 index 00000000000..fcb83d4f9c2 --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SearchRequest.java @@ -0,0 +1,135 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SearchRequest.Builder.class) +public final class SearchRequest { + private final Optional pagination; + + private final SearchRequestQuery query; + + private final Map additionalProperties; + + private SearchRequest( + Optional pagination, + SearchRequestQuery query, + Map additionalProperties) { + this.pagination = pagination; + this.query = query; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("pagination") + public Optional getPagination() { + return pagination; + } + + @JsonProperty("query") + public SearchRequestQuery getQuery() { + return query; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SearchRequest && equalTo((SearchRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SearchRequest other) { + return pagination.equals(other.pagination) && query.equals(other.query); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pagination, this.query); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static QueryStage builder() { + return new Builder(); + } + + public interface QueryStage { + _FinalStage query(@NotNull SearchRequestQuery query); + + Builder from(SearchRequest other); + } + + public interface _FinalStage { + SearchRequest build(); + + _FinalStage pagination(Optional pagination); + + _FinalStage pagination(StartingAfterPaging pagination); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements QueryStage, _FinalStage { + private SearchRequestQuery query; + + private Optional pagination = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SearchRequest other) { + pagination(other.getPagination()); + query(other.getQuery()); + return this; + } + + @java.lang.Override + @JsonSetter("query") + public _FinalStage query(@NotNull SearchRequestQuery query) { + this.query = Objects.requireNonNull(query, "query must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage pagination(StartingAfterPaging pagination) { + this.pagination = Optional.ofNullable(pagination); + return this; + } + + @java.lang.Override + @JsonSetter(value = "pagination", nulls = Nulls.SKIP) + public _FinalStage pagination(Optional pagination) { + this.pagination = pagination; + return this; + } + + @java.lang.Override + public SearchRequest build() { + return new SearchRequest(pagination, query, additionalProperties); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SearchRequestQuery.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SearchRequestQuery.java new file mode 100644 index 00000000000..377b44a74dd --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SearchRequestQuery.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.seed.pagination.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = SearchRequestQuery.Deserializer.class) +public final class SearchRequestQuery { + private final Object value; + + private final int type; + + private SearchRequestQuery(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((SingleFilterSearchRequest) this.value); + } else if (this.type == 1) { + return visitor.visit((MultipleFilterSearchRequest) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SearchRequestQuery && equalTo((SearchRequestQuery) other); + } + + private boolean equalTo(SearchRequestQuery other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static SearchRequestQuery of(SingleFilterSearchRequest value) { + return new SearchRequestQuery(value, 0); + } + + public static SearchRequestQuery of(MultipleFilterSearchRequest value) { + return new SearchRequestQuery(value, 1); + } + + public interface Visitor { + T visit(SingleFilterSearchRequest value); + + T visit(MultipleFilterSearchRequest value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(SearchRequestQuery.class); + } + + @java.lang.Override + public SearchRequestQuery deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, SingleFilterSearchRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, MultipleFilterSearchRequest.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SingleFilterSearchRequest.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SingleFilterSearchRequest.java new file mode 100644 index 00000000000..b88bbfbe250 --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SingleFilterSearchRequest.java @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SingleFilterSearchRequest.Builder.class) +public final class SingleFilterSearchRequest { + private final Optional field; + + private final Optional operator; + + private final Optional value; + + private final Map additionalProperties; + + private SingleFilterSearchRequest( + Optional field, + Optional operator, + Optional value, + Map additionalProperties) { + this.field = field; + this.operator = operator; + this.value = value; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("field") + public Optional getField() { + return field; + } + + @JsonProperty("operator") + public Optional getOperator() { + return operator; + } + + @JsonProperty("value") + public Optional getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SingleFilterSearchRequest && equalTo((SingleFilterSearchRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SingleFilterSearchRequest other) { + return field.equals(other.field) && operator.equals(other.operator) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.field, this.operator, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional field = Optional.empty(); + + private Optional operator = Optional.empty(); + + private Optional value = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SingleFilterSearchRequest other) { + field(other.getField()); + operator(other.getOperator()); + value(other.getValue()); + return this; + } + + @JsonSetter(value = "field", nulls = Nulls.SKIP) + public Builder field(Optional field) { + this.field = field; + return this; + } + + public Builder field(String field) { + this.field = Optional.ofNullable(field); + return this; + } + + @JsonSetter(value = "operator", nulls = Nulls.SKIP) + public Builder operator(Optional operator) { + this.operator = operator; + return this; + } + + public Builder operator(SingleFilterSearchRequestOperator operator) { + this.operator = Optional.ofNullable(operator); + return this; + } + + @JsonSetter(value = "value", nulls = Nulls.SKIP) + public Builder value(Optional value) { + this.value = value; + return this; + } + + public Builder value(String value) { + this.value = Optional.ofNullable(value); + return this; + } + + public SingleFilterSearchRequest build() { + return new SingleFilterSearchRequest(field, operator, value, additionalProperties); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SingleFilterSearchRequestOperator.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SingleFilterSearchRequestOperator.java new file mode 100644 index 00000000000..845437cda7b --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/SingleFilterSearchRequestOperator.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum SingleFilterSearchRequestOperator { + EQUALS("="), + + NOT_EQUALS("!="), + + IN("IN"), + + NOT_IN("NIN"), + + LESS_THAN("<"), + + GREATER_THAN(">"), + + CONTAINS("~"), + + DOES_NOT_CONTAIN("!~"), + + STARTS_WITH("^"), + + ENDS_WITH("$"); + + private final String value; + + SingleFilterSearchRequestOperator(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/StartingAfterPaging.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/StartingAfterPaging.java new file mode 100644 index 00000000000..9047485dc62 --- /dev/null +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/complex/types/StartingAfterPaging.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.pagination.resources.complex.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.pagination.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = StartingAfterPaging.Builder.class) +public final class StartingAfterPaging { + private final int perPage; + + private final Optional startingAfter; + + private final Map additionalProperties; + + private StartingAfterPaging(int perPage, Optional startingAfter, Map additionalProperties) { + this.perPage = perPage; + this.startingAfter = startingAfter; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("per_page") + public int getPerPage() { + return perPage; + } + + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StartingAfterPaging && equalTo((StartingAfterPaging) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(StartingAfterPaging other) { + return perPage == other.perPage && startingAfter.equals(other.startingAfter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.perPage, this.startingAfter); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PerPageStage builder() { + return new Builder(); + } + + public interface PerPageStage { + _FinalStage perPage(int perPage); + + Builder from(StartingAfterPaging other); + } + + public interface _FinalStage { + StartingAfterPaging build(); + + _FinalStage startingAfter(Optional startingAfter); + + _FinalStage startingAfter(String startingAfter); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PerPageStage, _FinalStage { + private int perPage; + + private Optional startingAfter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(StartingAfterPaging other) { + perPage(other.getPerPage()); + startingAfter(other.getStartingAfter()); + return this; + } + + @java.lang.Override + @JsonSetter("per_page") + public _FinalStage perPage(int perPage) { + this.perPage = perPage; + return this; + } + + @java.lang.Override + public _FinalStage startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + @java.lang.Override + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public _FinalStage startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + @java.lang.Override + public StartingAfterPaging build() { + return new StartingAfterPaging(perPage, startingAfter, additionalProperties); + } + } +} diff --git a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/users/UsersClient.java b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/users/UsersClient.java index 922c08ea8d8..0023f116458 100644 --- a/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/users/UsersClient.java +++ b/seed/java-sdk/pagination/src/main/java/com/seed/pagination/resources/users/UsersClient.java @@ -31,6 +31,8 @@ import com.seed.pagination.resources.users.types.Page; import com.seed.pagination.resources.users.types.User; import com.seed.pagination.resources.users.types.UsernameContainer; +import com.seed.pagination.resources.users.types.WithCursor; +import com.seed.pagination.resources.users.types.WithPage; import com.seed.pagination.types.UsernameCursor; import java.io.IOException; import java.util.Collections; @@ -157,7 +159,7 @@ public SyncPagingIterable listWithMixedTypeCursorPagination( .build(); List result = parsedResponse.getData(); return new SyncPagingIterable<>( - startingAfter.isPresent(), + !startingAfter.isEmpty(), result, () -> listWithMixedTypeCursorPagination(nextRequest, requestOptions)); } @@ -171,16 +173,16 @@ public SyncPagingIterable listWithMixedTypeCursorPagination( } } - public void listWithBodyCursorPagination() { - listWithBodyCursorPagination( + public SyncPagingIterable listWithBodyCursorPagination() { + return listWithBodyCursorPagination( ListUsersBodyCursorPaginationRequest.builder().build()); } - public void listWithBodyCursorPagination(ListUsersBodyCursorPaginationRequest request) { - listWithBodyCursorPagination(request, null); + public SyncPagingIterable listWithBodyCursorPagination(ListUsersBodyCursorPaginationRequest request) { + return listWithBodyCursorPagination(request, null); } - public void listWithBodyCursorPagination( + public SyncPagingIterable listWithBodyCursorPagination( ListUsersBodyCursorPaginationRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -209,6 +211,21 @@ public void listWithBodyCursorPagination( if (response.isSuccessful()) { ListUsersPaginationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListUsersPaginationResponse.class); + Optional startingAfter = + parsedResponse.getPage().flatMap(Page::getNext).map(NextPage::getStartingAfter); + Optional pagination = request.getPagination().map(pagination_ -> WithCursor.builder() + .from(pagination_) + .cursor(startingAfter) + .build()); + ListUsersBodyCursorPaginationRequest nextRequest = ListUsersBodyCursorPaginationRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable<>( + startingAfter.isPresent(), + result, + () -> listWithBodyCursorPagination(nextRequest, requestOptions)); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; throw new SeedPaginationApiException( @@ -325,7 +342,7 @@ public SyncPagingIterable listWithDoubleOffsetPagination( if (response.isSuccessful()) { ListUsersPaginationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListUsersPaginationResponse.class); - double newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + double newPageNumber = request.getPage().map(page -> page + 1.0).orElse(1.0); ListUsersDoubleOffsetPaginationRequest nextRequest = ListUsersDoubleOffsetPaginationRequest.builder() .from(request) .page(newPageNumber) @@ -344,16 +361,16 @@ public SyncPagingIterable listWithDoubleOffsetPagination( } } - public void listWithBodyOffsetPagination() { - listWithBodyOffsetPagination( + public SyncPagingIterable listWithBodyOffsetPagination() { + return listWithBodyOffsetPagination( ListUsersBodyOffsetPaginationRequest.builder().build()); } - public void listWithBodyOffsetPagination(ListUsersBodyOffsetPaginationRequest request) { - listWithBodyOffsetPagination(request, null); + public SyncPagingIterable listWithBodyOffsetPagination(ListUsersBodyOffsetPaginationRequest request) { + return listWithBodyOffsetPagination(request, null); } - public void listWithBodyOffsetPagination( + public SyncPagingIterable listWithBodyOffsetPagination( ListUsersBodyOffsetPaginationRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -382,6 +399,21 @@ public void listWithBodyOffsetPagination( if (response.isSuccessful()) { ListUsersPaginationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListUsersPaginationResponse.class); + int newPageNumber = request.getPagination() + .flatMap(WithPage::getPage) + .map(page -> page + 1) + .orElse(1); + Optional pagination = request.getPagination().map(pagination_ -> WithPage.builder() + .from(pagination_) + .page(newPageNumber) + .build()); + ListUsersBodyOffsetPaginationRequest nextRequest = ListUsersBodyOffsetPaginationRequest.builder() + .from(request) + .pagination(pagination) + .build(); + List result = parsedResponse.getData(); + return new SyncPagingIterable<>( + true, result, () -> listWithBodyOffsetPagination(nextRequest, requestOptions)); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; throw new SeedPaginationApiException( diff --git a/seed/java-sdk/seed.yml b/seed/java-sdk/seed.yml index ae274ebec8e..e0d22b3ea88 100644 --- a/seed/java-sdk/seed.yml +++ b/seed/java-sdk/seed.yml @@ -108,6 +108,8 @@ fixtures: outputFolder: java-custom-package-prefix java-single-property-endpoint: - outputFolder: java-single-property-endpoint + java-pagination-deep-cursor-path: + - outputFolder: java-pagination-deep-cursor-path scripts: - docker: fernapi/java-seed commands: @@ -125,3 +127,4 @@ allowedFailures: - unions - streaming-parameter - literal + - java-pagination-deep-cursor-path diff --git a/test-definitions/fern/apis/java-pagination-deep-cursor-path/definition/api.yml b/test-definitions/fern/apis/java-pagination-deep-cursor-path/definition/api.yml new file mode 100644 index 00000000000..edd7278a9cb --- /dev/null +++ b/test-definitions/fern/apis/java-pagination-deep-cursor-path/definition/api.yml @@ -0,0 +1,2 @@ +name: deep-cursor-path + diff --git a/test-definitions/fern/apis/java-pagination-deep-cursor-path/definition/deep-cursor-path.yml b/test-definitions/fern/apis/java-pagination-deep-cursor-path/definition/deep-cursor-path.yml new file mode 100644 index 00000000000..ed77043545a --- /dev/null +++ b/test-definitions/fern/apis/java-pagination-deep-cursor-path/definition/deep-cursor-path.yml @@ -0,0 +1,87 @@ +types: + D: + properties: + starting_after: optional + C: + properties: + d: optional + B: + properties: + c: C + A: + properties: + b: optional + Response: + properties: + starting_after: optional + results: list + IndirectionRequired: + properties: + starting_after: optional + results: list + MainRequired: + properties: + indirection: IndirectionRequired + InlineD: + inline: true + properties: + starting_after: optional + InlineC: + inline: true + properties: + b: optional + InlineB: + inline: true + properties: + c: InlineC + InlineA: + inline: true + properties: + b: optional +service: + auth: false + base-path: '' + display-name: Long Path + endpoints: + do-thing: + display-name: Do Thing + method: POST + pagination: + cursor: $request.b.c.d.starting_after + next_cursor: $response.starting_after + results: $response.results + path: / + request: + body: + type: A + content-type: application/json + response: + type: Response + do-thing-required: + display-name: Do Thing + method: POST + pagination: + cursor: $request.indirection.starting_after + next_cursor: $response.starting_after + results: $response.results + path: / + request: + body: + type: MainRequired + content-type: application/json + response: + type: Response + do-thing-inline: + display-name: Do Thing + method: POST + pagination: + cursor: $request.b.c.b.starting_after + next_cursor: $response.starting_after + results: $response.results + path: / + request: + body: + type: InlineA + content-type: application/json + response: + type: Response diff --git a/test-definitions/fern/apis/java-pagination-deep-cursor-path/generators.yml b/test-definitions/fern/apis/java-pagination-deep-cursor-path/generators.yml new file mode 100644 index 00000000000..311847daa5a --- /dev/null +++ b/test-definitions/fern/apis/java-pagination-deep-cursor-path/generators.yml @@ -0,0 +1,2 @@ +{} + diff --git a/test-definitions/fern/apis/pagination/definition/complex.yml b/test-definitions/fern/apis/pagination/definition/complex.yml new file mode 100644 index 00000000000..538b1882df8 --- /dev/null +++ b/test-definitions/fern/apis/pagination/definition/complex.yml @@ -0,0 +1,112 @@ +types: + SearchRequestQuery: + discriminated: false + inline: true + union: + - type: SingleFilterSearchRequest + - type: MultipleFilterSearchRequest + MultipleFilterSearchRequest: + properties: + operator: + type: optional + value: + type: optional + MultipleFilterSearchRequestOperator: + enum: + - AND + - OR + inline: true + MultipleFilterSearchRequestValue: + discriminated: false + inline: true + union: + - type: list + - type: list + SingleFilterSearchRequest: + properties: + field: + type: optional + operator: + type: optional + value: + type: optional + SingleFilterSearchRequestOperator: + enum: + - name: Equals + value: '=' + - name: NotEquals + value: '!=' + - name: In + value: IN + - name: NotIn + value: NIN + - name: LessThan + value: < + - name: GreaterThan + value: '>' + - name: Contains + value: '~' + - name: DoesNotContain + value: '!~' + - name: StartsWith + value: ^ + - name: EndsWith + value: $ + inline: true + SearchRequest: + properties: + pagination: + type: optional + query: SearchRequestQuery + PaginatedConversationResponse: + properties: + conversations: + type: list + pages: + type: optional + total_count: + type: integer + type: + type: literal<"conversation.list"> + CursorPages: + properties: + next: + type: optional + page: + type: optional + per_page: + type: optional + total_pages: + type: optional + type: + type: literal<"pages"> + StartingAfterPaging: + properties: + per_page: + type: integer + starting_after: + type: optional + Conversation: + properties: + foo: string +service: + auth: false + base-path: '' + display-name: Conversations + endpoints: + search: + auth: true + display-name: Search conversations + method: POST + pagination: + cursor: $request.pagination.starting_after + next_cursor: $response.pages.next.starting_after + results: $response.conversations + path: /conversations/search + request: + body: + type: SearchRequest + content-type: application/json + response: + type: PaginatedConversationResponse +