Skip to content

Commit

Permalink
Add x-ignored flag
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierapivideo committed Jun 4, 2024
1 parent 2fe98c0 commit 1425363
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<CodegenOperation> getCodegenOperationComparator() {
Map<String, Integer> operationIndexes = new HashMap<>();
operationIndexes.put("create", 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Common.replaceDescriptionsAndSamples(objs, "go");
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Object> allModels, CodegenOperation operation) {
Optional<Map> map = allModels.stream().filter(m -> ((CodegenModel) ((Map) m).get("model")).classname.equals(operation.returnType)).map(a -> (Map) a).findFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ public void processOpts() {

}


/**
* Filter the OpenAPI description file entries in order to keep only stuff related to video upload & authentication
* @param openAPI
*/
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
super.preprocessOpenAPI(openAPI);
Common.preprocessOpenAPI(openAPI);

Set<String> pathsToRemove = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ public String getHelp() {
return "Generates a PHP client library.";
}



public void preprocessOpenAPI(OpenAPI openAPI) {
Common.preprocessOpenAPI(openAPI);
Map<String, PathItem> pathItems = openAPI.getPaths();
io.swagger.v3.oas.models.Paths newPaths = new io.swagger.v3.oas.models.Paths();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public CodegenProperty fromProperty(String name, Schema p) {
}

public void preprocessOpenAPI(OpenAPI openAPI) {
Common.preprocessOpenAPI(openAPI);
Map<String, PathItem> pathItems = openAPI.getPaths();
io.swagger.v3.oas.models.Paths newPaths = new io.swagger.v3.oas.models.Paths();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,6 +25,11 @@ public class Swift5 extends Swift5ClientCodegen {
public static final String VENDOR_X_CLIENT_HIDDEN = "x-client-hidden";
public static final List<String> 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<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Common.replaceDescriptionsAndSamples(objs, "swift5");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Swift5Uploader extends Swift5 {
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
super.preprocessOpenAPI(openAPI);
Common.preprocessOpenAPI(openAPI);

Set<String> pathsToRemove = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 18 additions & 2 deletions oas_apivideo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -11791,6 +11792,7 @@ paths:
x-doctave:
code-samples:
'/data/buckets/{metric}/{breakdown}':
x-ignored: true
get:
tags:
- Analytics v2.0 beta
Expand Down Expand Up @@ -12037,6 +12039,7 @@ paths:
x-doctave:
code-samples:
'/data/timeseries/{metric}':
x-ignored: true
get:
tags:
- Analytics v2.0 beta
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

This file was deleted.

0 comments on commit 1425363

Please sign in to comment.