From 4313c13f57108c8066968e9740bd654ec35a2b61 Mon Sep 17 00:00:00 2001 From: Tom Simmons Date: Wed, 8 Feb 2023 20:10:46 -0500 Subject: [PATCH] Name parameter setters set* to avoid conflicts (#62) --- .../java/io/github/tomboyo/lily/example/ExampleTest.java | 2 +- .../tomboyo/lily/compiler/cg/AstOperationCodeGen.java | 2 +- .../github/tomboyo/lily/compiler/feature/FluentApiTest.java | 6 +++--- .../lily/compiler/feature/HttpRequestBuildersTest.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/example/src/test/java/io/github/tomboyo/lily/example/ExampleTest.java b/modules/example/src/test/java/io/github/tomboyo/lily/example/ExampleTest.java index 1b39808..6b4b283 100644 --- a/modules/example/src/test/java/io/github/tomboyo/lily/example/ExampleTest.java +++ b/modules/example/src/test/java/io/github/tomboyo/lily/example/ExampleTest.java @@ -49,7 +49,7 @@ void happyPath(WireMockRuntimeInfo info) throws Exception { var response = api.petsOperations() // All operations with the `pets` tag. (see also: everyOperation) .showPetById() // The GET /pets/{petId} operation - .petId("1234") // bind "1234" to the {petId} parameter of the OAS operation + .setPetId("1234") // bind "1234" to the {petId} parameter of the OAS operation .sendSync(); // execute the request synchronously and get a ShowPetByIdResponse object. /* The response object is a sealed interface based on what the OAS says the API can return. In this case, the diff --git a/modules/lily-compiler/src/main/java/io/github/tomboyo/lily/compiler/cg/AstOperationCodeGen.java b/modules/lily-compiler/src/main/java/io/github/tomboyo/lily/compiler/cg/AstOperationCodeGen.java index 573a9bb..1b1aba4 100644 --- a/modules/lily-compiler/src/main/java/io/github/tomboyo/lily/compiler/cg/AstOperationCodeGen.java +++ b/modules/lily-compiler/src/main/java/io/github/tomboyo/lily/compiler/cg/AstOperationCodeGen.java @@ -104,7 +104,7 @@ public java.net.http.HttpRequest httpRequest() { parameter -> Map.of( "fqpt", parameter.typeName().toFqpString(), - "name", parameter.name().lowerCamelCase(), + "name", "set" + parameter.name().upperCamelCase(), "apiName", parameter.apiName(), "encoder", getEncoder(parameter.encoding()))) .collect(toList()), diff --git a/modules/lily-compiler/src/test/java/io/github/tomboyo/lily/compiler/feature/FluentApiTest.java b/modules/lily-compiler/src/test/java/io/github/tomboyo/lily/compiler/feature/FluentApiTest.java index a0b2673..2be9d39 100644 --- a/modules/lily-compiler/src/test/java/io/github/tomboyo/lily/compiler/feature/FluentApiTest.java +++ b/modules/lily-compiler/src/test/java/io/github/tomboyo/lily/compiler/feature/FluentApiTest.java @@ -101,7 +101,7 @@ void hasPathParameterSetters() { .build() .everyOperation() .getPetById() - .id("1234") + .setId("1234") .uriTemplate() .toURI(); """ @@ -159,8 +159,8 @@ void hasQueryParameterSetters() { .build() .everyOperation() .listPets() - .limit(5) - .include(java.util.List.of("name", "age")) + .setLimit(5) + .setInclude(java.util.List.of("name", "age")) .uriTemplate() .toURI(); """ diff --git a/modules/lily-compiler/src/test/java/io/github/tomboyo/lily/compiler/feature/HttpRequestBuildersTest.java b/modules/lily-compiler/src/test/java/io/github/tomboyo/lily/compiler/feature/HttpRequestBuildersTest.java index c2fed79..eab997b 100644 --- a/modules/lily-compiler/src/test/java/io/github/tomboyo/lily/compiler/feature/HttpRequestBuildersTest.java +++ b/modules/lily-compiler/src/test/java/io/github/tomboyo/lily/compiler/feature/HttpRequestBuildersTest.java @@ -50,8 +50,8 @@ static void beforeAll() throws Exception { .build() .everyOperation() .postFoo() - .id("1234") - .color("red") + .setId("1234") + .setColor("red") .httpRequest(); """ .formatted(packageName),