diff --git a/oas_apivideo.yaml b/oas_apivideo.yaml index 57021143..666c0e3d 100644 --- a/oas_apivideo.yaml +++ b/oas_apivideo.yaml @@ -1059,24 +1059,9 @@ paths: requestBody: required: true content: - applictaion/json: + application/json: schema: - type: object - properties: - videoId: - type: string - description: Create a summary of a video using the video ID. - example: vi4k0jvEUuaTdRAEjQ4Jfrgz - origin: - type: string - enum: [auto] - description: |- - Use this parameter to define how the API generates the summary. The only allowed value is `auto`, which means that the API generates a summary automatically. - - If you do not set this parameter, **the API will not generate a summary automatically**. - - In this case, `sourceStatus` will return `missing`, and you have to manually add a summary using the `PATCH /summaries/{summaryId}/source` endpoint operation. - example: auto + $ref: '#/components/schemas/summary-creation-payload' responses: '201': headers: @@ -1096,7 +1081,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/summary-object' + $ref: '#/components/schemas/summary' examples: Summary created: value: @@ -1142,6 +1127,29 @@ paths: x-client-description: default: 'List all summarries for your videos in a project.' operationId: GET_summaries + parameters: + - name: sortBy + in: query + description: 'Allowed: createdAt. You can search by the time watermark were created at.' + required: false + style: form + explode: true + schema: + type: string + example: createdAt + - name: sortOrder + in: query + description: 'Allowed: asc, desc. asc is ascending and sorts from A to Z. desc is descending and sorts from Z to A.' + required: false + style: form + explode: true + schema: + type: string + example: asc + - $ref: '#/components/parameters/current-page' + - $ref: '#/components/parameters/page-size' + x-group-parameters: true + x-client-paginated: true responses: '200': headers: @@ -1161,7 +1169,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/get-summaries' + $ref: '#/components/schemas/summaries-list-response' examples: List all summaries: value: @@ -1177,7 +1185,20 @@ paths: updatedAt: '2024-07-15T23:36:07+00:00' videoId: 'vibaBXK3N7yrRcxcMt95678' origin: auto - sourceStatus: waiting + sourceStatus: waiting + pagination: + currentPage: 1 + pageSize: 25 + pagesTotal: 1 + itemsTotal: 11 + currentPageItems: 11 + links: + - rel: self + uri: 'https://ws.api.video/summaries?currentPage=1' + - rel: first + uri: 'https://ws.api.video/summaries?currentPage=1' + - rel: last + uri: 'https://ws.api.video/summaries?currentPage=1' /summaries/{summaryId}: delete: tags: @@ -1222,7 +1243,7 @@ paths: - Summaries summary: Get summary details description: Get all details for a summary - x-client-action: get + x-client-action: getSummarySource x-client-description: default: 'Get all details for a summary.' operationId: GET_summaries-summaryId-source @@ -1308,7 +1329,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/update-summary-request' + $ref: '#/components/schemas/summary-update-payload' responses: '201': headers: @@ -15817,7 +15838,26 @@ components: - If you define a video language using the `language` parameter, the API uses that language to summarize the video. If you do not define a language, the API detects it based on the video. required: - title - update-summary-request: + summary-creation-payload: + required: + - videoId + type: object + properties: + videoId: + type: string + description: Create a summary of a video using the video ID. + example: vi4k0jvEUuaTdRAEjQ4Jfrgz + origin: + type: string + enum: [auto] + description: |- + Use this parameter to define how the API generates the summary. The only allowed value is `auto`, which means that the API generates a summary automatically. + + If you do not set this parameter, **the API will not generate a summary automatically**. + + In this case, `sourceStatus` will return `missing`, and you have to manually add a summary using the `PATCH /summaries/{summaryId}/source` endpoint operation. + example: auto + summary-update-payload: type: object properties: title: @@ -15877,15 +15917,21 @@ components: - Quantum theory is complicated. - Schrödinger's cat is neither dead, nor alive. - Quantum computers are super cool. - get-summaries: + summaries-list-response: type: object + title: Summaries properties: data: - description: An array of summary objects. type: array + description: An array of summary objects. items: - $ref: '#/components/schemas/summary-object' - summary-object: + $ref: '#/components/schemas/summary' + pagination: + $ref: '#/components/schemas/pagination' + required: + - data + - pagination + summary: type: object properties: summaryId: @@ -15907,6 +15953,10 @@ components: description: The unique identifier of the video object. example: 'vi4k0jvEUuaTdRAEjQ4Prklg' origin: + type: string + enum: + - api + - auto description: |- Returns the origin of how the summary was created. diff --git a/templates/java/statics/android/src/test/java/video/api/client/api/clients/SummariesApiTest.java b/templates/java/statics/android/src/test/java/video/api/client/api/clients/SummariesApiTest.java new file mode 100644 index 00000000..505dee6c --- /dev/null +++ b/templates/java/statics/android/src/test/java/video/api/client/api/clients/SummariesApiTest.java @@ -0,0 +1,163 @@ +/* + * api.video Java API client + * api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes. + * + * The version of the OpenAPI document: 1 + * Contact: ecosystem@api.video + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + +package video.api.client.api.clients; + +import video.api.client.api.ApiException; +import video.api.client.api.models.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** + * API tests for SummariesApi + */ +@DisplayName("SummariesApi") +public class SummariesApiTest extends AbstractApiTest { + + private final SummariesApi api = apiClientMock.summaries(); + + @Nested + @DisplayName("create") + class create { + private static final String PAYLOADS_PATH = "/payloads/summaries/create/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatThrownBy(() -> api.create(new SummaryCreationPayload())) + .hasMessage("Missing the required parameter 'summaryCreationPayload.videoId' when calling create"); + + assertThatThrownBy(() -> api.create(null)) + .hasMessage("Missing the required parameter 'summaryCreationPayload' when calling create"); + + assertThatNoException().isThrownBy(() -> api.create(new SummaryCreationPayload().videoId("123"))); + } + + @Test + @DisplayName("409 response") + public void responseWithStatus409Test() throws ApiException { + answerOnAnyRequest(409, readResourceFile(PAYLOADS_PATH + "responses/409.json")); + + assertThatThrownBy(() -> api.create(new SummaryCreationPayload().videoId("123"))) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(409)) + .hasMessage("A summary already exists or is being created on this video."); + + } + } + + @Nested + @DisplayName("get") + class get { + private static final String PAYLOADS_PATH = "/payloads/summaries/getSummarySource/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.getSummarySource("summary_1CGHWuXjhxmeH4WiZ51234")); + + assertThatThrownBy(() -> api.getSummarySource(null)) + .hasMessage("Missing the required parameter 'summaryId' when calling getSummarySource"); + } + + @Test + @DisplayName("404 response") + public void responseWithStatus404Test() throws ApiException { + answerOnAnyRequest(404, readResourceFile(PAYLOADS_PATH + "responses/404.json")); + + assertThatThrownBy(() -> api.getSummarySource("summary_1CGHWuXjhxmeH4WiZ51234")) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(404)) + .hasMessage("The requested resource was not found."); + + } + } + + @Nested + @DisplayName("update") + class update { + private static final String PAYLOADS_PATH = "/payloads/summaries/update/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException() + .isThrownBy(() -> api.update("summary_1CGHWuXjhxmeH4WiZ51234", new SummaryUpdatePayload())); + assertThatThrownBy(() -> api.update(null, null)) + .hasMessage("Missing the required parameter 'summaryId' when calling update"); + } + + @Test + @DisplayName("409 response") + public void responseWithStatus409Test() throws ApiException { + answerOnAnyRequest(409, readResourceFile(PAYLOADS_PATH + "responses/409.json")); + + assertThatThrownBy(() -> api.update("summary_1CGHWuXjhxmeH4WiZ51234", new SummaryUpdatePayload())) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(409)) + .hasMessage("A summary already exists or is being created on this video."); + } + } + + @Nested + @DisplayName("delete") + class delete { + private static final String PAYLOADS_PATH = "/payloads/summaries/delete/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.delete("summary_1CGHWuXjhxmeH4WiZ51234")); + assertThatThrownBy(() -> api.delete(null)) + .hasMessage("Missing the required parameter 'summaryId' when calling delete"); + } + } + + @Nested + @DisplayName("list") + class list { + private static final String PAYLOADS_PATH = "/payloads/summaries/list/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.list()); + assertThatNoException().isThrownBy(() -> api.list()); + // + } + + @Test + @DisplayName("200 response") + public void responseWithStatus200Test() throws ApiException { + answerOnAnyRequest(200, readResourceFile(PAYLOADS_PATH + "responses/200.json")); + + Page execute = api.list().execute(); + + } + } + +} diff --git a/templates/java/statics/java/src/test/java/video/api/client/api/clients/SummariesApiTest.java b/templates/java/statics/java/src/test/java/video/api/client/api/clients/SummariesApiTest.java new file mode 100644 index 00000000..c602ff1d --- /dev/null +++ b/templates/java/statics/java/src/test/java/video/api/client/api/clients/SummariesApiTest.java @@ -0,0 +1,162 @@ +/* + * api.video Java API client + * api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes. + * + * The version of the OpenAPI document: 1 + * Contact: ecosystem@api.video + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + +package video.api.client.api.clients; + +import video.api.client.api.ApiException; +import video.api.client.api.models.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** + * API tests for SummariesApi + */ +@DisplayName("SummariesApi") +public class SummariesApiTest extends AbstractApiTest { + + private final SummariesApi api = apiClientMock.summaries(); + + @Nested + @DisplayName("create") + class create { + private static final String PAYLOADS_PATH = "/payloads/summaries/create/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatThrownBy(() -> api.create(new SummaryCreationPayload())) + .hasMessage("Missing the required parameter 'summaryCreationPayload.videoId' when calling create"); + + assertThatThrownBy(() -> api.create(null)) + .hasMessage("Missing the required parameter 'summaryCreationPayload' when calling create"); + + assertThatNoException().isThrownBy(() -> api.create(new SummaryCreationPayload().videoId("123"))); + } + + @Test + @DisplayName("409 response") + public void responseWithStatus409Test() throws ApiException { + answerOnAnyRequest(409, readResourceFile(PAYLOADS_PATH + "responses/409.json")); + + assertThatThrownBy(() -> api.create(new SummaryCreationPayload().videoId("123"))) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(409)) + .hasMessage("A summary already exists or is being created on this video."); + + } + } + + @Nested + @DisplayName("get") + class get { + private static final String PAYLOADS_PATH = "/payloads/summaries/getSummarySource/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.getSummarySource("summary_1CGHWuXjhxmeH4WiZ51234")); + + assertThatThrownBy(() -> api.getSummarySource(null)) + .hasMessage("Missing the required parameter 'summaryId' when calling getSummarySource"); + } + + @Test + @DisplayName("404 response") + public void responseWithStatus404Test() throws ApiException { + answerOnAnyRequest(404, readResourceFile(PAYLOADS_PATH + "responses/404.json")); + + assertThatThrownBy(() -> api.getSummarySource("summary_1CGHWuXjhxmeH4WiZ51234")).isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(404)) + .hasMessage("The requested resource was not found."); + + } + } + + @Nested + @DisplayName("update") + class update { + private static final String PAYLOADS_PATH = "/payloads/summaries/update/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException() + .isThrownBy(() -> api.update("summary_1CGHWuXjhxmeH4WiZ51234", new SummaryUpdatePayload())); + assertThatThrownBy(() -> api.update(null, null)) + .hasMessage("Missing the required parameter 'summaryId' when calling update"); + } + + @Test + @DisplayName("409 response") + public void responseWithStatus409Test() throws ApiException { + answerOnAnyRequest(409, readResourceFile(PAYLOADS_PATH + "responses/409.json")); + + assertThatThrownBy(() -> api.update("summary_1CGHWuXjhxmeH4WiZ51234", new SummaryUpdatePayload())) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(409)) + .hasMessage("A summary already exists or is being created on this video."); + } + } + + @Nested + @DisplayName("delete") + class delete { + private static final String PAYLOADS_PATH = "/payloads/summaries/delete/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.delete("summary_1CGHWuXjhxmeH4WiZ51234")); + assertThatThrownBy(() -> api.delete(null)) + .hasMessage("Missing the required parameter 'summaryId' when calling delete"); + } + } + + @Nested + @DisplayName("list") + class list { + private static final String PAYLOADS_PATH = "/payloads/summaries/list/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.list()); + assertThatNoException().isThrownBy(() -> api.list()); + // + } + + @Test + @DisplayName("200 response") + public void responseWithStatus200Test() throws ApiException { + answerOnAnyRequest(200, readResourceFile(PAYLOADS_PATH + "responses/200.json")); + + Page execute = api.list().execute(); + + } + } + +} diff --git a/templates/swift5/libraries/alamofire/AlamofireImplementations.mustache b/templates/swift5/libraries/alamofire/AlamofireImplementations.mustache index 84eedea0..21c24cfe 100644 --- a/templates/swift5/libraries/alamofire/AlamofireImplementations.mustache +++ b/templates/swift5/libraries/alamofire/AlamofireImplementations.mustache @@ -413,6 +413,8 @@ extension JSONDataEncoding: ParameterEncoding { public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { let urlRequest = try urlRequest.asURLRequest() - return encode(urlRequest, with: parameters) + // Alamofire 5.10 changed type of Parameters so that it is no longer equivalent to [String: Any] + // cast this type so that the call to encode is not recursive + return encode(urlRequest, with: parameters as [String: Any]?) } } diff --git a/templates/swift5/statics/client/.github/workflows/build.yml b/templates/swift5/statics/client/.github/workflows/build.yml index 65e710fd..e11cb2bb 100644 --- a/templates/swift5/statics/client/.github/workflows/build.yml +++ b/templates/swift5/statics/client/.github/workflows/build.yml @@ -28,24 +28,10 @@ jobs: uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: latest-stable - - name: Set Default Scheme - run: | - scheme_list=$(xcodebuild -list -json | tr -d "\n") - default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['workspace']['schemes'][0]") - echo $default | cat >default - echo Using default scheme: $default - name: Build Package with xcodebuild - env: - scheme: ${{ 'default' }} - run: | - if [ $scheme = default ]; then scheme=$(cat default); fi - xcodebuild -scheme $scheme -destination 'platform=iOS Simulator,name=iPhone 16' + run: xcodebuild -scheme ApiVideoClient -destination 'platform=iOS Simulator,name=iPhone 16' - name: Build Example - env: - scheme: ${{ 'default' }} - run: | - if [ $scheme = default ]; then scheme=$(cat default); fi - xcodebuild clean build -project Example/Example.xcodeproj -scheme $scheme -sdk iphoneos + run: xcodebuild clean build -project Example/Example.xcodeproj -scheme ApiVideoClient -sdk iphoneos cocoapods: name: Verify cocopods podspec diff --git a/templates/swift5/statics/uploader/.github/workflows/build.yml b/templates/swift5/statics/uploader/.github/workflows/build.yml index 65e710fd..a584c86a 100644 --- a/templates/swift5/statics/uploader/.github/workflows/build.yml +++ b/templates/swift5/statics/uploader/.github/workflows/build.yml @@ -28,24 +28,10 @@ jobs: uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: latest-stable - - name: Set Default Scheme - run: | - scheme_list=$(xcodebuild -list -json | tr -d "\n") - default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['workspace']['schemes'][0]") - echo $default | cat >default - echo Using default scheme: $default - name: Build Package with xcodebuild - env: - scheme: ${{ 'default' }} - run: | - if [ $scheme = default ]; then scheme=$(cat default); fi - xcodebuild -scheme $scheme -destination 'platform=iOS Simulator,name=iPhone 16' + run: xcodebuild -scheme ApiVideoUploader -destination 'platform=iOS Simulator,name=iPhone 16' - name: Build Example - env: - scheme: ${{ 'default' }} - run: | - if [ $scheme = default ]; then scheme=$(cat default); fi - xcodebuild clean build -project Example/Example.xcodeproj -scheme $scheme -sdk iphoneos + run: xcodebuild clean build -project Example/Example.xcodeproj -scheme ApiVideoUploader -sdk iphoneos cocoapods: name: Verify cocopods podspec