From 3a016d1da7cf5112545da55e8343e3092424adc7 Mon Sep 17 00:00:00 2001 From: Olivier Lando Date: Tue, 4 Jun 2024 16:48:39 +0200 Subject: [PATCH] Add x-ignored flag --- .../video/api/client/generator/Common.java | 7 ++++++ .../video/api/client/generator/Csharp.java | 8 +++++++ .../java/video/api/client/generator/Go.java | 8 +++++++ .../java/video/api/client/generator/Java.java | 7 +++++- .../api/client/generator/JavaUploader.java | 2 ++ .../java/video/api/client/generator/Php.java | 3 +++ .../video/api/client/generator/Python.java | 1 + .../video/api/client/generator/Swift5.java | 6 +++++ .../api/client/generator/Swift5Uploader.java | 1 + .../api/client/generator/TypeScript.java | 2 ++ oas_apivideo.yaml | 20 +++++++++++++++-- .../api/clients/AnalyticsV20BetaApiTest.java | 22 ------------------- 12 files changed, 62 insertions(+), 25 deletions(-) delete mode 100644 templates/java/statics/java/src/test/java/video/api/client/api/clients/AnalyticsV20BetaApiTest.java diff --git a/apivideo-generator/src/main/java/video/api/client/generator/Common.java b/apivideo-generator/src/main/java/video/api/client/generator/Common.java index 39f802ec..35b56a4b 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/Common.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/Common.java @@ -18,6 +18,13 @@ public class Common { + public static void preprocessOpenAPI(OpenAPI openAPI) { + // remove paths that have the x-ignored flag + openAPI.getPaths().keySet().removeIf(path -> openAPI.getPaths().get(path).getExtensions() != null && openAPI.getPaths().get(path).getExtensions().containsKey("x-ignored")); + // remove models that have the x-ignored flag + openAPI.getComponents().getSchemas().keySet().removeIf(schema -> openAPI.getComponents().getSchemas().get(schema).getExtensions() != null && openAPI.getComponents().getSchemas().get(schema).getExtensions().containsKey("x-ignored")); + } + public static Comparator getCodegenOperationComparator() { Map operationIndexes = new HashMap<>(); operationIndexes.put("create", 1); diff --git a/apivideo-generator/src/main/java/video/api/client/generator/Csharp.java b/apivideo-generator/src/main/java/video/api/client/generator/Csharp.java index f70026f6..38470689 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/Csharp.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/Csharp.java @@ -3,6 +3,7 @@ import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Template; import io.swagger.util.Json; +import io.swagger.v3.oas.models.OpenAPI; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenOperation; @@ -37,6 +38,13 @@ public Csharp() { packageGuid = "{" + java.util.UUID.nameUUIDFromBytes(this.packageVersion.getBytes()).toString().toUpperCase(Locale.ROOT) + "}"; } + + @Override + public void preprocessOpenAPI(OpenAPI openAPI) { + super.preprocessOpenAPI(openAPI); + Common.preprocessOpenAPI(openAPI); + } + @Override public void postProcessParameter(CodegenParameter parameter) { super.postProcessParameter(parameter); diff --git a/apivideo-generator/src/main/java/video/api/client/generator/Go.java b/apivideo-generator/src/main/java/video/api/client/generator/Go.java index 4ccf216f..d077b99a 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/Go.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/Go.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.collect.Maps; import io.swagger.util.Json; +import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; @@ -40,6 +41,13 @@ public CodegenProperty fromProperty(String name, Schema p) { return super.fromProperty(name, p); } + + @Override + public void preprocessOpenAPI(OpenAPI openAPI) { + super.preprocessOpenAPI(openAPI); + Common.preprocessOpenAPI(openAPI); + } + @Override public Map postProcessOperationsWithModels(Map objs, List allModels) { Common.replaceDescriptionsAndSamples(objs, "go"); 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 90f0f778..56b21984 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 @@ -1,5 +1,6 @@ package video.api.client.generator; +import io.swagger.v3.oas.models.OpenAPI; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenOperation; @@ -140,7 +141,11 @@ public void processOpts() { supportingFiles.removeIf(e -> skippedFiles.contains(e.getTemplateFile())); } - + @Override + public void preprocessOpenAPI(OpenAPI openAPI) { + super.preprocessOpenAPI(openAPI); + Common.preprocessOpenAPI(openAPI); + } private void handlePagination(List allModels, CodegenOperation operation) { Optional map = allModels.stream().filter(m -> ((CodegenModel) ((Map) m).get("model")).classname.equals(operation.returnType)).map(a -> (Map) a).findFirst(); diff --git a/apivideo-generator/src/main/java/video/api/client/generator/JavaUploader.java b/apivideo-generator/src/main/java/video/api/client/generator/JavaUploader.java index a9c6f919..2d1821c4 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/JavaUploader.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/JavaUploader.java @@ -25,6 +25,7 @@ public void processOpts() { } + /** * Filter the OpenAPI description file entries in order to keep only stuff related to video upload & authentication * @param openAPI @@ -32,6 +33,7 @@ public void processOpts() { @Override public void preprocessOpenAPI(OpenAPI openAPI) { super.preprocessOpenAPI(openAPI); + Common.preprocessOpenAPI(openAPI); Set pathsToRemove = new HashSet<>(); diff --git a/apivideo-generator/src/main/java/video/api/client/generator/Php.java b/apivideo-generator/src/main/java/video/api/client/generator/Php.java index 1551334a..875b9055 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/Php.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/Php.java @@ -97,7 +97,10 @@ public String getHelp() { return "Generates a PHP client library."; } + + public void preprocessOpenAPI(OpenAPI openAPI) { + Common.preprocessOpenAPI(openAPI); Map pathItems = openAPI.getPaths(); io.swagger.v3.oas.models.Paths newPaths = new io.swagger.v3.oas.models.Paths(); diff --git a/apivideo-generator/src/main/java/video/api/client/generator/Python.java b/apivideo-generator/src/main/java/video/api/client/generator/Python.java index a83473af..238daa02 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/Python.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/Python.java @@ -85,6 +85,7 @@ public CodegenProperty fromProperty(String name, Schema p) { } public void preprocessOpenAPI(OpenAPI openAPI) { + Common.preprocessOpenAPI(openAPI); Map pathItems = openAPI.getPaths(); io.swagger.v3.oas.models.Paths newPaths = new io.swagger.v3.oas.models.Paths(); diff --git a/apivideo-generator/src/main/java/video/api/client/generator/Swift5.java b/apivideo-generator/src/main/java/video/api/client/generator/Swift5.java index 0df11cb6..9e365a21 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/Swift5.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/Swift5.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.util.Json; +import io.swagger.v3.oas.models.OpenAPI; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.languages.Swift5ClientCodegen; @@ -24,6 +25,11 @@ public class Swift5 extends Swift5ClientCodegen { public static final String VENDOR_X_CLIENT_HIDDEN = "x-client-hidden"; public static final List PARAMETERS_TO_HIDE_IN_CLIENT_DOC = Arrays.asList("currentPage", "pageSize"); + @Override + public void preprocessOpenAPI(OpenAPI openAPI) { + super.preprocessOpenAPI(openAPI); + Common.preprocessOpenAPI(openAPI); + } @Override public Map postProcessOperationsWithModels(Map objs, List allModels) { Common.replaceDescriptionsAndSamples(objs, "swift5"); diff --git a/apivideo-generator/src/main/java/video/api/client/generator/Swift5Uploader.java b/apivideo-generator/src/main/java/video/api/client/generator/Swift5Uploader.java index e01c2ccf..82dac8ab 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/Swift5Uploader.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/Swift5Uploader.java @@ -22,6 +22,7 @@ public class Swift5Uploader extends Swift5 { @Override public void preprocessOpenAPI(OpenAPI openAPI) { super.preprocessOpenAPI(openAPI); + Common.preprocessOpenAPI(openAPI); Set pathsToRemove = new HashSet<>(); diff --git a/apivideo-generator/src/main/java/video/api/client/generator/TypeScript.java b/apivideo-generator/src/main/java/video/api/client/generator/TypeScript.java index 2a871bb8..475be613 100644 --- a/apivideo-generator/src/main/java/video/api/client/generator/TypeScript.java +++ b/apivideo-generator/src/main/java/video/api/client/generator/TypeScript.java @@ -475,6 +475,8 @@ public CodegenType getTag() { @Override public void preprocessOpenAPI(OpenAPI openAPI) { + Common.preprocessOpenAPI(openAPI); + if (additionalProperties.containsKey(NPM_NAME)) { // If no npmVersion is provided in additional properties, version from API specification is used. // If none of them is provided then fallbacks to default version diff --git a/oas_apivideo.yaml b/oas_apivideo.yaml index 532ff5c0..5c99fb0b 100644 --- a/oas_apivideo.yaml +++ b/oas_apivideo.yaml @@ -11561,6 +11561,7 @@ paths: // First install the api client: https://github.com/apivideo/api.video-swift-client#getting-started // Documentation: https://github.com/apivideo/api.video-swift-client/blob/main/docs/PlayerThemesAPI.md#deleteLogo '/data/metrics/{metric}/{aggregation}': + x-ignored: true get: tags: - Analytics v2.0 beta @@ -11791,6 +11792,7 @@ paths: x-doctave: code-samples: '/data/buckets/{metric}/{breakdown}': + x-ignored: true get: tags: - Analytics v2.0 beta @@ -12037,6 +12039,7 @@ paths: x-doctave: code-samples: '/data/timeseries/{metric}': + x-ignored: true get: tags: - Analytics v2.0 beta @@ -15619,10 +15622,12 @@ components: description: The name of the parameter that caused the error. type: string analytics-aggregated-metrics-response: + x-ignored: true title: AggregatedMetrics type: object properties: context: + x-ignored: true type: object properties: metric: @@ -15647,6 +15652,7 @@ components: - sum example: count timeframe: + x-ignored: true description: Returns the starting and ending date-times of the period you want analytics for. type: object properties: @@ -15673,10 +15679,12 @@ components: - data - pagination analytics-metrics-breakdown-response: + x-ignored: true title: Analytics v2.0 response for metrics breakdown by dimension type: object properties: context: + x-ignored: true type: object properties: metric: @@ -15702,6 +15710,7 @@ components: - browser example: country timeframe: + x-ignored: true description: Returns the starting and ending date-times of the period you want analytics for. type: object properties: @@ -15716,9 +15725,11 @@ components: format: date-time example: '2024-05-29T11:15:07+00:00' data: + x-ignored: true description: Returns an array of dimensions and their respective metrics. type: array - items: + items: + x-ignored: true type: object properties: dimensionValue: @@ -15735,10 +15746,12 @@ components: - data - pagination analytics-metrics-over-time-response: + x-ignored: true title: Analytics v2.0 response for metrics over time type: object properties: context: + x-ignored: true type: object properties: metric: @@ -15759,6 +15772,7 @@ components: - day example: day timeframe: + x-ignored: true description: Returns the starting and ending date-times of the period you want analytics for. type: object properties: @@ -15773,9 +15787,11 @@ components: format: date-time example: '2024-05-29T11:15:07+00:00' data: + x-ignored: true description: Returns an array of metrics and the timestamps . type: array - items: + items: + x-ignored: true type: object properties: emittedAt: diff --git a/templates/java/statics/java/src/test/java/video/api/client/api/clients/AnalyticsV20BetaApiTest.java b/templates/java/statics/java/src/test/java/video/api/client/api/clients/AnalyticsV20BetaApiTest.java deleted file mode 100644 index 73312ed1..00000000 --- a/templates/java/statics/java/src/test/java/video/api/client/api/clients/AnalyticsV20BetaApiTest.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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 org.junit.jupiter.api.DisplayName; - -/** - * API tests for AnalyticsV20BetaApi - */ -@DisplayName("AnalyticsV20BetaApi") -public class AnalyticsV20BetaApiTest extends AbstractApiTest { - -}