|
21 | 21 | import io.swagger.v3.oas.models.Components;
|
22 | 22 | import io.swagger.v3.oas.models.OpenAPI;
|
23 | 23 | import io.swagger.v3.oas.models.Operation;
|
| 24 | +import io.swagger.v3.oas.models.PathItem; |
24 | 25 | import io.swagger.v3.oas.models.media.ArraySchema;
|
25 | 26 | import io.swagger.v3.oas.models.media.Content;
|
26 | 27 | import io.swagger.v3.oas.models.media.MediaType;
|
|
37 | 38 | import org.testng.Assert;
|
38 | 39 | import org.testng.annotations.Test;
|
39 | 40 |
|
40 |
| -import java.lang.reflect.Method; |
41 | 41 | import java.util.*;
|
42 | 42 | import java.util.stream.Collectors;
|
43 | 43 |
|
@@ -500,6 +500,21 @@ public void testCallbacks() {
|
500 | 500 | });
|
501 | 501 | }
|
502 | 502 |
|
| 503 | + @Test |
| 504 | + public void testLeadingSlashIsAddedIfMissing() { |
| 505 | + OpenAPI openAPI = TestUtils.createOpenAPI(); |
| 506 | + Operation operation1 = new Operation().operationId("op1").responses(new ApiResponses().addApiResponse("201", new ApiResponse().description("OK"))); |
| 507 | + openAPI.path("/here", new PathItem().get(operation1)); |
| 508 | + Operation operation2 = new Operation().operationId("op2").responses(new ApiResponses().addApiResponse("201", new ApiResponse().description("OK"))); |
| 509 | + openAPI.path("some/path", new PathItem().get(operation2)); |
| 510 | + final DefaultCodegen codegen = new DefaultCodegen(); |
| 511 | + |
| 512 | + CodegenOperation co1 = codegen.fromOperation("/here", "get", operation2, ModelUtils.getSchemas(openAPI), openAPI); |
| 513 | + Assert.assertEquals(co1.path, "/here"); |
| 514 | + CodegenOperation co2 = codegen.fromOperation("some/path", "get", operation2, ModelUtils.getSchemas(openAPI), openAPI); |
| 515 | + Assert.assertEquals(co2.path, "/some/path"); |
| 516 | + } |
| 517 | + |
503 | 518 | private void verifyPersonDiscriminator(CodegenDiscriminator discriminator) {
|
504 | 519 | CodegenDiscriminator test = new CodegenDiscriminator();
|
505 | 520 | test.setPropertyName("$_type");
|
|
0 commit comments