Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java): Fix usage of cursor pagination causing endpoint return type to be void #5708

Merged
merged 24 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9ea0ce8
fix(java): Fix usage of cursor pagination causing endpoint return typ…
Jan 22, 2025
be93614
Add test case
Jan 23, 2025
3e73406
Run seed against new test case
Jan 23, 2025
13e2311
Allow objects with nonempty path to be used for cursor pagination
Jan 23, 2025
f76cfab
run seed
Jan 23, 2025
70fc921
Merge branch 'main' into alberto/add-pagination-test-case
fern-api[bot] Jan 23, 2025
126b007
Add a utility to find the property type of the desired property withi…
fern-api[bot] Jan 24, 2025
7e2e405
Add new test case just for deep cursor path
fern-api[bot] Jan 24, 2025
6865c46
run new fixture
fern-api[bot] Jan 24, 2025
47b8ca8
run the fixture
fern-api[bot] Jan 25, 2025
e46df5b
Refactor next page number offset pagination for easier overriding
fern-api[bot] Jan 26, 2025
165553c
Fix fixture
fern-api[bot] Jan 26, 2025
a4f7b3b
fix merge conflict
fern-api[bot] Jan 26, 2025
926b006
Add more test cases
fern-api[bot] Jan 26, 2025
fa9f6fb
Add test case as expected failure
fern-api[bot] Jan 28, 2025
bb90ac5
Merge branch 'main' into alberto/add-pagination-test-case
fern-api[bot] Jan 28, 2025
151e699
test udpate
fern-api[bot] Jan 28, 2025
d2fd95e
Handle different zero value possibilities for next snippet
fern-api[bot] Jan 29, 2025
8d87cfa
Fix nits
fern-api[bot] Jan 29, 2025
c32dfe2
Change test definition
fern-api[bot] Jan 29, 2025
a4a72e4
Delete pagination gens
fern-api[bot] Jan 29, 2025
4a489fd
delete long snapshots
fern-api[bot] Jan 29, 2025
b1b326c
Delete all complex
fern-api[bot] Jan 29, 2025
546c04a
Rerun pagination tests
fern-api[bot] Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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<EnrichedCursorPathGetter> previous();

@Value.Default
default boolean optional() {
return false;
}

default String propertyName() {
return pathItem().name().getCamelCase().getSafeName();
}

static ImmutableEnrichedCursorPathGetter.Builder builder() {
return ImmutableEnrichedCursorPathGetter.builder();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading
Loading