Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {{javaxPackage}}.annotation.Generated;
public interface {{classname}} {
{{#operation}}

String PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}} = "{{{path}}}";
Comment thread
Natarajan717 marked this conversation as resolved.
/**
* {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}}
{{#notes}}
Expand Down Expand Up @@ -74,7 +75,7 @@ public interface {{classname}} {
{{/useResponseEntity}}
@HttpExchange(
method = "{{{httpMethod}}}",
value = "{{{path}}}",
value = {{classname}}.PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}},
accept = { {{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}} }{{#vendorExtensions.x-content-type}},
contentType = "{{{vendorExtensions.x-content-type}}}"{{/vendorExtensions.x-content-type}}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6865,6 +6865,24 @@ public void testClientRegistrationIdAnnotation() throws IOException {
.containsWithNameAndAttributes("ClientRegistrationId", ImmutableMap.of("value", "\"my-oauth-client\""));
}

@Test
public void testPathConstantGeneratedForSpringHttpInterfaceLibrary() throws IOException {
final SpringCodegen codegen = new SpringCodegen();
codegen.setLibrary("spring-http-interface");

final Map<String, File> files = generateFiles(codegen, "src/test/resources/3_0/petstore.yaml");

// Check that the path constant field is generated
JavaFileAssert.assertThat(files.get("PetApi.java"))
.fileContains("String PATH_GET_PET_BY_ID = \"/pet/{petId}\";");

// Check that @HttpExchange's value attribute reuses the constant instead of a hardcoded path
JavaFileAssert.assertThat(files.get("PetApi.java"))
.assertMethod("getPetById")
.assertMethodAnnotations()
.containsWithNameAndAttributes("HttpExchange", ImmutableMap.of("value", "PetApi.PATH_GET_PET_BY_ID"));
}

@Test
public void testClientRegistrationIdAnnotationNotPresentWhenNotConfigured() throws IOException {
final SpringCodegen codegen = new SpringCodegen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.26.0-SNAPSHOT")
public interface AnotherFakeApi {

String PATH_CALL123TEST_SPECIAL_TAGS = "/another-fake/dummy";
/**
* PATCH /another-fake/dummy : To test special tags
* To test special tags and operation ID starting with number
Expand All @@ -33,7 +34,7 @@ public interface AnotherFakeApi {
*/
@HttpExchange(
method = "PATCH",
value = "/another-fake/dummy",
value = AnotherFakeApi.PATH_CALL123TEST_SPECIAL_TAGS,
accept = { "application/json" },
contentType = "application/json"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.26.0-SNAPSHOT")
public interface FakeApi {

String PATH_CREATE_XML_ITEM = "/fake/create_xml_item";
/**
* POST /fake/create_xml_item : creates an XmlItem
* this route creates an XmlItem
Expand All @@ -44,7 +45,7 @@ public interface FakeApi {
*/
@HttpExchange(
method = "POST",
value = "/fake/create_xml_item",
value = FakeApi.PATH_CREATE_XML_ITEM,
accept = { "application/json" },
contentType = "application/xml"
)
Expand All @@ -53,6 +54,7 @@ ResponseEntity<Void> createXmlItem(
);


String PATH_FAKE_OUTER_BOOLEAN_SERIALIZE = "/fake/outer/boolean";
/**
* POST /fake/outer/boolean
* Test serialization of outer boolean types
Expand All @@ -62,7 +64,7 @@ ResponseEntity<Void> createXmlItem(
*/
@HttpExchange(
method = "POST",
value = "/fake/outer/boolean",
value = FakeApi.PATH_FAKE_OUTER_BOOLEAN_SERIALIZE,
accept = { "*/*" },
contentType = "application/json"
)
Expand All @@ -71,6 +73,7 @@ ResponseEntity<Boolean> fakeOuterBooleanSerialize(
);


String PATH_FAKE_OUTER_COMPOSITE_SERIALIZE = "/fake/outer/composite";
/**
* POST /fake/outer/composite
* Test serialization of object with outer number type
Expand All @@ -80,7 +83,7 @@ ResponseEntity<Boolean> fakeOuterBooleanSerialize(
*/
@HttpExchange(
method = "POST",
value = "/fake/outer/composite",
value = FakeApi.PATH_FAKE_OUTER_COMPOSITE_SERIALIZE,
accept = { "*/*" },
contentType = "application/json"
)
Expand All @@ -89,6 +92,7 @@ ResponseEntity<OuterCompositeDto> fakeOuterCompositeSerialize(
);


String PATH_FAKE_OUTER_NUMBER_SERIALIZE = "/fake/outer/number";
/**
* POST /fake/outer/number
* Test serialization of outer number types
Expand All @@ -98,7 +102,7 @@ ResponseEntity<OuterCompositeDto> fakeOuterCompositeSerialize(
*/
@HttpExchange(
method = "POST",
value = "/fake/outer/number",
value = FakeApi.PATH_FAKE_OUTER_NUMBER_SERIALIZE,
accept = { "*/*" },
contentType = "application/json"
)
Expand All @@ -107,6 +111,7 @@ ResponseEntity<BigDecimal> fakeOuterNumberSerialize(
);


String PATH_FAKE_OUTER_STRING_SERIALIZE = "/fake/outer/string";
/**
* POST /fake/outer/string
* Test serialization of outer string types
Expand All @@ -116,7 +121,7 @@ ResponseEntity<BigDecimal> fakeOuterNumberSerialize(
*/
@HttpExchange(
method = "POST",
value = "/fake/outer/string",
value = FakeApi.PATH_FAKE_OUTER_STRING_SERIALIZE,
accept = { "*/*" },
contentType = "application/json"
)
Expand All @@ -125,6 +130,7 @@ ResponseEntity<String> fakeOuterStringSerialize(
);


String PATH_TEST_BODY_WITH_FILE_SCHEMA = "/fake/body-with-file-schema";
/**
* PUT /fake/body-with-file-schema
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.
Expand All @@ -134,7 +140,7 @@ ResponseEntity<String> fakeOuterStringSerialize(
*/
@HttpExchange(
method = "PUT",
value = "/fake/body-with-file-schema",
value = FakeApi.PATH_TEST_BODY_WITH_FILE_SCHEMA,
accept = { "application/json" },
contentType = "application/json"
)
Expand All @@ -143,6 +149,7 @@ ResponseEntity<Void> testBodyWithFileSchema(
);


String PATH_TEST_BODY_WITH_QUERY_PARAMS = "/fake/body-with-query-params";
/**
* PUT /fake/body-with-query-params
*
Expand All @@ -152,7 +159,7 @@ ResponseEntity<Void> testBodyWithFileSchema(
*/
@HttpExchange(
method = "PUT",
value = "/fake/body-with-query-params",
value = FakeApi.PATH_TEST_BODY_WITH_QUERY_PARAMS,
accept = { "application/json" },
contentType = "application/json"
)
Expand All @@ -162,6 +169,7 @@ ResponseEntity<Void> testBodyWithQueryParams(
);


String PATH_TEST_CLIENT_MODEL = "/fake";
/**
* PATCH /fake : To test \&quot;client\&quot; model
* To test \&quot;client\&quot; model
Expand All @@ -171,7 +179,7 @@ ResponseEntity<Void> testBodyWithQueryParams(
*/
@HttpExchange(
method = "PATCH",
value = "/fake",
value = FakeApi.PATH_TEST_CLIENT_MODEL,
accept = { "application/json" },
contentType = "application/json"
)
Expand All @@ -180,6 +188,7 @@ ResponseEntity<ClientDto> testClientModel(
);


String PATH_TEST_ENDPOINT_PARAMETERS = "/fake";
/**
* POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Expand All @@ -203,7 +212,7 @@ ResponseEntity<ClientDto> testClientModel(
*/
@HttpExchange(
method = "POST",
value = "/fake",
value = FakeApi.PATH_TEST_ENDPOINT_PARAMETERS,
accept = { "application/json" },
contentType = "application/x-www-form-urlencoded"
)
Expand All @@ -225,6 +234,7 @@ ResponseEntity<Void> testEndpointParameters(
);


String PATH_TEST_ENUM_PARAMETERS = "/fake";
/**
* GET /fake : To test enum parameters
* To test enum parameters
Expand All @@ -242,7 +252,7 @@ ResponseEntity<Void> testEndpointParameters(
*/
@HttpExchange(
method = "GET",
value = "/fake",
value = FakeApi.PATH_TEST_ENUM_PARAMETERS,
accept = { "application/json" },
contentType = "application/x-www-form-urlencoded"
)
Expand All @@ -258,6 +268,7 @@ ResponseEntity<Void> testEnumParameters(
);


String PATH_TEST_GROUP_PARAMETERS = "/fake";
/**
* DELETE /fake : Fake endpoint to test group parameters (optional)
* Fake endpoint to test group parameters (optional)
Expand All @@ -272,7 +283,7 @@ ResponseEntity<Void> testEnumParameters(
*/
@HttpExchange(
method = "DELETE",
value = "/fake",
value = FakeApi.PATH_TEST_GROUP_PARAMETERS,
accept = { "application/json" }
)
ResponseEntity<Void> testGroupParameters(
Expand All @@ -285,6 +296,7 @@ ResponseEntity<Void> testGroupParameters(
);


String PATH_TEST_INLINE_ADDITIONAL_PROPERTIES = "/fake/inline-additionalProperties";
/**
* POST /fake/inline-additionalProperties : test inline additionalProperties
*
Expand All @@ -294,7 +306,7 @@ ResponseEntity<Void> testGroupParameters(
*/
@HttpExchange(
method = "POST",
value = "/fake/inline-additionalProperties",
value = FakeApi.PATH_TEST_INLINE_ADDITIONAL_PROPERTIES,
accept = { "application/json" },
contentType = "application/json"
)
Expand All @@ -303,6 +315,7 @@ ResponseEntity<Void> testInlineAdditionalProperties(
);


String PATH_TEST_JSON_FORM_DATA = "/fake/jsonFormData";
/**
* GET /fake/jsonFormData : test json serialization of form data
*
Expand All @@ -313,7 +326,7 @@ ResponseEntity<Void> testInlineAdditionalProperties(
*/
@HttpExchange(
method = "GET",
value = "/fake/jsonFormData",
value = FakeApi.PATH_TEST_JSON_FORM_DATA,
accept = { "application/json" },
contentType = "application/x-www-form-urlencoded"
)
Expand All @@ -323,6 +336,7 @@ ResponseEntity<Void> testJsonFormData(
);


String PATH_TEST_NULLABLE = "/fake/nullable";
/**
* POST /fake/nullable : test nullable parent property
*
Expand All @@ -332,7 +346,7 @@ ResponseEntity<Void> testJsonFormData(
*/
@HttpExchange(
method = "POST",
value = "/fake/nullable",
value = FakeApi.PATH_TEST_NULLABLE,
accept = { "application/json" },
contentType = "application/json"
)
Expand All @@ -341,6 +355,7 @@ ResponseEntity<Void> testNullable(
);


String PATH_TEST_QUERY_PARAMETER_COLLECTION_FORMAT = "/fake/test-query-parameters";
/**
* PUT /fake/test-query-parameters
* To test the collection format in query parameters
Expand All @@ -353,7 +368,7 @@ ResponseEntity<Void> testNullable(
*/
@HttpExchange(
method = "PUT",
value = "/fake/test-query-parameters",
value = FakeApi.PATH_TEST_QUERY_PARAMETER_COLLECTION_FORMAT,
accept = { "application/json" }
)
ResponseEntity<Void> testQueryParameterCollectionFormat(
Expand All @@ -364,6 +379,7 @@ ResponseEntity<Void> testQueryParameterCollectionFormat(
);


String PATH_TEST_WITH_RESULT_EXAMPLE = "/fake/response-with-example";
/**
* GET /fake/response-with-example
* This endpoint defines an example value for its response schema.
Expand All @@ -372,7 +388,7 @@ ResponseEntity<Void> testQueryParameterCollectionFormat(
*/
@HttpExchange(
method = "GET",
value = "/fake/response-with-example",
value = FakeApi.PATH_TEST_WITH_RESULT_EXAMPLE,
accept = { "application/json" }
)
ResponseEntity<Integer> testWithResultExample(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.26.0-SNAPSHOT")
public interface FakeClassnameTags123Api {

String PATH_TEST_CLASSNAME = "/fake_classname_test";
/**
* PATCH /fake_classname_test : To test class name in snake case
* To test class name in snake case
Expand All @@ -33,7 +34,7 @@ public interface FakeClassnameTags123Api {
*/
@HttpExchange(
method = "PATCH",
value = "/fake_classname_test",
value = FakeClassnameTags123Api.PATH_TEST_CLASSNAME,
accept = { "application/json" },
contentType = "application/json"
)
Expand Down
Loading
Loading