diff --git a/apivideo-generator/src/main/java/video/api/client/generator/Java.java b/apivideo-generator/src/main/java/video/api/client/generator/Java.java index 56b21984..6444d637 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/Java.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/Java.java @@ -154,7 +154,11 @@ private void handlePagination(List allModels, CodegenOperation operation System.out.println(model); model.allVars.stream().filter(v -> v.name.equals("data")).findFirst().ifPresent(codegenProperty -> { Map paginationProperties = new HashMap<>(); - paginationProperties.put("type", codegenProperty.dataType.substring(codegenProperty.dataType.indexOf("<") + 1, codegenProperty.dataType.indexOf(">"))); + if(codegenProperty.dataType.contains("<") && codegenProperty.dataType.contains(">")) { + paginationProperties.put("type", codegenProperty.dataType.substring(codegenProperty.dataType.indexOf("<") + 1, codegenProperty.dataType.indexOf(">"))); + } else { + paginationProperties.put("type", codegenProperty.dataType); + } paginationProperties.put("getter", codegenProperty.getter); operation.vendorExtensions.put("x-pagination", paginationProperties); }); diff --git a/oas_apivideo.yaml b/oas_apivideo.yaml index 87668f2e..389a7df9 100644 --- a/oas_apivideo.yaml +++ b/oas_apivideo.yaml @@ -11663,8 +11663,6 @@ paths: schema: type: string example: filterBy[continent]=EU&filterBy[country]=FR&filterBy[browser]=Safari&filterBy[browser]=Firefox - - $ref: '#/components/parameters/current-page' - - $ref: '#/components/parameters/page-size' responses: '200': headers: @@ -11786,7 +11784,6 @@ paths: - apiKey: [] x-client-action: getAggregatedMetrics x-group-parameters: true - x-client-paginated: true x-doctave: code-samples: '/data/buckets/{metric}/{breakdown}': @@ -14613,12 +14610,9 @@ components: format: date-time example: '2024-05-29T11:15:07+00:00' data: - items: - type: number - format: float - example: '356.2' - pagination: - $ref: '#/components/schemas/pagination' + type: number + format: float + example: '356.2' required: - context - data diff --git a/templates/java/statics/android/src/test/java/video/api/client/api/clients/WebhooksApiTest.java b/templates/java/statics/android/src/test/java/video/api/client/api/clients/WebhooksApiTest.java index be82da8e..2fe5074d 100644 --- a/templates/java/statics/android/src/test/java/video/api/client/api/clients/WebhooksApiTest.java +++ b/templates/java/statics/android/src/test/java/video/api/client/api/clients/WebhooksApiTest.java @@ -176,11 +176,11 @@ public void responseWithStatus400Test() throws ApiException { ApiException e = assertThrows(ApiException.class, () -> api.create(new WebhooksCreationPayload().url("url"))); assertThat(e.getCode()).isEqualTo(400); assertThat(e.getProblems()).containsExactlyElementsIn(Arrays.asList( - new ApiException.ApiProblem("https://docs.api.video/docs/attributerequired", + new ApiException.ApiProblem("https://docs.api.video/reference/attribute-required", "This attribute is required.", "events"), - new ApiException.ApiProblem("https://docs.api.video/docs/attributerequired", + new ApiException.ApiProblem("https://docs.api.video/reference/attribute-required", "This attribute is required.", "url"), - new ApiException.ApiProblem("https://docs.api.video/docs/attributeinvalid", + new ApiException.ApiProblem("https://docs.api.video/reference/invalid-attribute", "This attribute must be an array.", "events"))) .inOrder(); assertThat(e).hasMessageThat().contains("This attribute is required."); diff --git a/templates/java/statics/java/src/test/java/video/api/client/api/clients/AnalyticsApiTest.java b/templates/java/statics/java/src/test/java/video/api/client/api/clients/AnalyticsApiTest.java index 176fb7a3..3117fd7b 100644 --- a/templates/java/statics/java/src/test/java/video/api/client/api/clients/AnalyticsApiTest.java +++ b/templates/java/statics/java/src/test/java/video/api/client/api/clients/AnalyticsApiTest.java @@ -47,7 +47,8 @@ public void requiredParametersTest() { answerOnAnyRequest(201, "{}"); assertThatNoException().isThrownBy(() -> api.getAggregatedMetrics("play", "count").execute()); - //String metric, String aggregation, OffsetDateTime from, OffsetDateTime to, String filterBy, Integer currentPage, Integer pageSize + // String metric, String aggregation, OffsetDateTime from, OffsetDateTime to, String filterBy, Integer + // currentPage, Integer pageSize } @Test @@ -55,42 +56,29 @@ public void requiredParametersTest() { public void responseWithStatus200Test() throws ApiException { answerOnAnyRequest(200, readResourceFile(PAYLOADS_PATH + "responses/200.json")); - Page res = api.getAggregatedMetrics("play", "count").execute(); - - /* sample response: - { - "context" : { - "metric" : "impression", - "aggregation" : "count", - "timeframe" : { - "from" : "2024-05-28T11:15:07+00:00", - "to" : "2024-05-29T11:15:07+00:00" - } - }, - "data" : 346.5 - } - */ + AnalyticsAggregatedMetricsResponse res = api.getAggregatedMetrics("play", "count").execute(); + + /* + * sample response: { "context" : { "metric" : "impression", "aggregation" : "count", "timeframe" : { "from" + * : "2024-05-28T11:15:07+00:00", "to" : "2024-05-29T11:15:07+00:00" } }, "data" : 346.5 } + */ } @Test @DisplayName("400 response") public void responseWithStatus400Test() throws ApiException { - answerOnAnyRequest(400, readResourceFile(PAYLOADS_PATH + "responses/400.json")); + answerOnAnyRequest(400, readResourceFile(PAYLOADS_PATH + "responses/400-0.json")); assertThatThrownBy(() -> api.getAggregatedMetrics("play", "count").execute()) - .isInstanceOf(ApiException.class) - .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(400)) - .hasMessage("A query parameter is invalid."); - - /* sample response: - { - "type" : "https://docs.api.video/reference/request-invalid-query-parameter", - "title" : "A query parameter is invalid.", - "status" : 400, - "detail" : "This field was not expected.", - "name" : "from:2024-05-20T09:15:05+02:00" - } - */ + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(400)) + .hasMessage("An attribute is invalid."); + + /* + * sample response: { "type" : "https://docs.api.video/reference/request-invalid-query-parameter", "title" : + * "A query parameter is invalid.", "status" : 400, "detail" : "This field was not expected.", "name" : + * "from:2024-05-20T09:15:05+02:00" } + */ } @Test @@ -99,17 +87,14 @@ public void responseWithStatus404Test() throws ApiException { answerOnAnyRequest(404, readResourceFile(PAYLOADS_PATH + "responses/404.json")); assertThatThrownBy(() -> api.getAggregatedMetrics("play", "count").execute()) - .isInstanceOf(ApiException.class) - .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(404)) - .hasMessage("Unrecognized request URL."); - - /* sample response: - { - "type" : "https://docs.api.video/reference/unrecognized-request-url", - "title" : "Unrecognized request URL.", - "status" : 404 - } - */ + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(404)) + .hasMessage("Unrecognized request URL."); + + /* + * sample response: { "type" : "https://docs.api.video/reference/unrecognized-request-url", "title" : + * "Unrecognized request URL.", "status" : 404 } + */ } @Test @@ -117,18 +102,15 @@ public void responseWithStatus404Test() throws ApiException { public void responseWithStatus429Test() throws ApiException { answerOnAnyRequest(429, readResourceFile(PAYLOADS_PATH + "responses/429.json")); - assertThatThrownBy(() -> api.getAggregatedMetrics("play" ,"count").execute()) - .isInstanceOf(ApiException.class) - .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(429)) - .hasMessage("Too many requests."); - - /* sample response: - { - "type" : "https://docs.api.video/reference/too-many-requests", - "title" : "Too many requests.", - "status" : 429 - } - */ + assertThatThrownBy(() -> api.getAggregatedMetrics("play", "count").execute()) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(429)) + .hasMessage("Too many requests."); + + /* + * sample response: { "type" : "https://docs.api.video/reference/too-many-requests", "title" : + * "Too many requests.", "status" : 429 } + */ } } @@ -143,7 +125,8 @@ public void requiredParametersTest() { answerOnAnyRequest(201, "{}"); assertThatNoException().isThrownBy(() -> api.getMetricsBreakdown("play", "media-id").execute()); - //String metric, String breakdown, OffsetDateTime from, OffsetDateTime to, String filterBy, Integer currentPage, Integer pageSize + // String metric, String breakdown, OffsetDateTime from, OffsetDateTime to, String filterBy, Integer + // currentPage, Integer pageSize } @Test @@ -153,60 +136,35 @@ public void responseWithStatus200Test() throws ApiException { Page res = api.getMetricsBreakdown("play", "media-id").execute(); - /* sample response: - { - "context" : { - "metric" : "play", - "breakdown" : "country", - "timeframe" : { - "from" : "2024-04-28T07:15:05+00:00", - "to" : "2024-05-29T11:25:37+00:00" - } - }, - "data" : [ { - "metricValue" : 7, - "dimensionValue" : "FR" - } ], - "pagination" : { - "currentPage" : 1, - "currentPageItems" : 1, - "pageSize" : 25, - "pagesTotal" : 1, - "itemsTotal" : 1, - "links" : [ { - "rel" : "self", - "uri" : "/data/buckets/play/country?from=2024-04-28T09%3A15%3A05%2B02%3A00&currentPage=1&pageSize=25" - }, { - "rel" : "first", - "uri" : "/data/buckets/play/country?from=2024-04-28T09%3A15%3A05%2B02%3A00&currentPage=1&pageSize=25" - }, { - "rel" : "last", - "uri" : "/data/buckets/play/country?from=2024-04-28T09%3A15%3A05%2B02%3A00&currentPage=1&pageSize=25" - } ] - } - } - */ + /* + * sample response: { "context" : { "metric" : "play", "breakdown" : "country", "timeframe" : { "from" : + * "2024-04-28T07:15:05+00:00", "to" : "2024-05-29T11:25:37+00:00" } }, "data" : [ { "metricValue" : 7, + * "dimensionValue" : "FR" } ], "pagination" : { "currentPage" : 1, "currentPageItems" : 1, "pageSize" : 25, + * "pagesTotal" : 1, "itemsTotal" : 1, "links" : [ { "rel" : "self", "uri" : + * "/data/buckets/play/country?from=2024-04-28T09%3A15%3A05%2B02%3A00&currentPage=1&pageSize=25" }, + * { "rel" : "first", "uri" : + * "/data/buckets/play/country?from=2024-04-28T09%3A15%3A05%2B02%3A00&currentPage=1&pageSize=25" }, + * { "rel" : "last", "uri" : + * "/data/buckets/play/country?from=2024-04-28T09%3A15%3A05%2B02%3A00&currentPage=1&pageSize=25" } ] + * } } + */ } @Test @DisplayName("400 response") public void responseWithStatus400Test() throws ApiException { - answerOnAnyRequest(400, readResourceFile(PAYLOADS_PATH + "responses/400.json")); + answerOnAnyRequest(400, readResourceFile(PAYLOADS_PATH + "responses/400-0.json")); assertThatThrownBy(() -> api.getMetricsBreakdown("play", "media-id").execute()) - .isInstanceOf(ApiException.class) - .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(400)) - .hasMessage("A query parameter is invalid."); - - /* sample response: - { - "type" : "https://docs.api.video/reference/request-invalid-query-parameter", - "title" : "A query parameter is invalid.", - "status" : 400, - "detail" : "This field was not expected.", - "name" : "from:2024-05-20T09:15:05+02:00" - } - */ + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(400)) + .hasMessage("An attribute is invalid."); + + /* + * sample response: { "type" : "https://docs.api.video/reference/request-invalid-query-parameter", "title" : + * "A query parameter is invalid.", "status" : 400, "detail" : "This field was not expected.", "name" : + * "from:2024-05-20T09:15:05+02:00" } + */ } @Test @@ -215,17 +173,14 @@ public void responseWithStatus404Test() throws ApiException { answerOnAnyRequest(404, readResourceFile(PAYLOADS_PATH + "responses/404.json")); assertThatThrownBy(() -> api.getMetricsBreakdown("play", "media-id").execute()) - .isInstanceOf(ApiException.class) - .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(404)) - .hasMessage("Unrecognized request URL."); - - /* sample response: - { - "type" : "https://docs.api.video/reference/unrecognized-request-url", - "title" : "Unrecognized request URL.", - "status" : 404 - } - */ + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(404)) + .hasMessage("Unrecognized request URL."); + + /* + * sample response: { "type" : "https://docs.api.video/reference/unrecognized-request-url", "title" : + * "Unrecognized request URL.", "status" : 404 } + */ } @Test @@ -234,17 +189,14 @@ public void responseWithStatus429Test() throws ApiException { answerOnAnyRequest(429, readResourceFile(PAYLOADS_PATH + "responses/429.json")); assertThatThrownBy(() -> api.getMetricsBreakdown("play", "media-id").execute()) - .isInstanceOf(ApiException.class) - .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(429)) - .hasMessage("Too many requests."); - - /* sample response: - { - "type" : "https://docs.api.video/reference/too-many-requests", - "title" : "Too many requests.", - "status" : 429 - } - */ + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(429)) + .hasMessage("Too many requests."); + + /* + * sample response: { "type" : "https://docs.api.video/reference/too-many-requests", "title" : + * "Too many requests.", "status" : 429 } + */ } } @@ -285,11 +237,11 @@ public void responseWithStatus200Test() throws ApiException { @Test @DisplayName("400 response") public void responseWithStatus400Test() throws ApiException { - answerOnAnyRequest(400, readResourceFile(PAYLOADS_PATH + "responses/400.json")); + answerOnAnyRequest(400, readResourceFile(PAYLOADS_PATH + "responses/400-0.json")); assertThatThrownBy(() -> api.getMetricsOverTime("play").execute()).isInstanceOf(ApiException.class) .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(400)) - .hasMessage("A query parameter is invalid."); + .hasMessage("An attribute is invalid."); /* * sample response: { "type" : "https://docs.api.video/reference/request-invalid-query-parameter", "title" : diff --git a/templates/java/statics/java/src/test/java/video/api/client/api/clients/WebhooksApiTest.java b/templates/java/statics/java/src/test/java/video/api/client/api/clients/WebhooksApiTest.java index b675bede..8deead53 100644 --- a/templates/java/statics/java/src/test/java/video/api/client/api/clients/WebhooksApiTest.java +++ b/templates/java/statics/java/src/test/java/video/api/client/api/clients/WebhooksApiTest.java @@ -174,11 +174,11 @@ public void responseWithStatus400Test() throws ApiException { .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(400)).satisfies(e -> { ApiException apiException = (ApiException) e; assertThat(apiException.getProblems()).containsExactlyInAnyOrder( - new ApiException.ApiProblem("https://docs.api.video/docs/attributerequired", + new ApiException.ApiProblem("https://docs.api.video/reference/attribute-required", "This attribute is required.", "events"), - new ApiException.ApiProblem("https://docs.api.video/docs/attributerequired", + new ApiException.ApiProblem("https://docs.api.video/reference/attribute-required", "This attribute is required.", "url"), - new ApiException.ApiProblem("https://docs.api.video/docs/attributeinvalid", + new ApiException.ApiProblem("https://docs.api.video/reference/invalid-attribute", "This attribute must be an array.", "events")); }).hasMessage("This attribute is required."); }