Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java): correct url for monitoring client #2569

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion generators/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ repositories {

dependencies {
compileOnly 'org.openapitools:openapi-generator:7.2.0'
compileOnly 'org.yaml:snakeyaml:2.2'
}

tasks.withType(JavaCompile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.algolia.codegen.exceptions.*;
import com.algolia.codegen.utils.*;
import com.algolia.codegen.utils.OneOf;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.io.IOException;
Expand Down Expand Up @@ -121,13 +122,12 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("netcore_project.mustache", "Algolia.Search.csproj"));
supportingFiles.add(new SupportingFile("AbstractOpenAPISchema.mustache", "Models", "AbstractSchema.cs"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "../", ".gitignore"));
}

try {
Helpers.generateServer(CLIENT, additionalProperties);
} catch (GeneratorException e) {
e.printStackTrace();
System.exit(1);
}
@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.apache.commons.lang3.StringUtils.*;

import com.algolia.codegen.utils.*;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.util.*;
Expand Down Expand Up @@ -102,9 +103,12 @@ public void processOpts() {
// Search config
additionalProperties.put("isSearchClient", client.equals("search"));
additionalProperties.put("packageVersion", version);
}

// Generate server info
Helpers.generateServer(client, additionalProperties);
@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.algolia.codegen.exceptions.*;
import com.algolia.codegen.utils.*;
import com.algolia.codegen.utils.OneOf;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.io.File;
Expand Down Expand Up @@ -53,14 +54,19 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("client.mustache", "", "client.go"));

try {
Helpers.generateServer(client, additionalProperties);
additionalProperties.put("packageVersion", Helpers.getClientConfigField("go", "packageVersion"));
} catch (GeneratorException e) {
e.printStackTrace();
System.exit(1);
}
}

@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
return Helpers.specifyCustomRequest(super.fromOperation(path, httpMethod, operation, servers));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.algolia.codegen.utils.*;
import com.algolia.codegen.utils.OneOf;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.servers.Server;
Expand Down Expand Up @@ -52,15 +53,19 @@ public void processOpts() {
additionalProperties.put("lambda.type-to-name", (Mustache.Lambda) (fragment, writer) -> writer.write(typeToName(fragment.execute())));

try {
Helpers.generateServer(client, additionalProperties);

additionalProperties.put("packageVersion", Helpers.getClientConfigField("java", "packageVersion"));
} catch (GeneratorException e) {
e.printStackTrace();
System.exit(1);
}
}

@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
// this is needed to preserve additionalProperties: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.algolia.codegen.exceptions.*;
import com.algolia.codegen.utils.*;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.util.List;
Expand Down Expand Up @@ -160,6 +161,12 @@ private void setDefaultGeneratorOptions() {
}
}

@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
Map<String, ModelsMap> models = super.postProcessAllModels(objs);
Expand All @@ -174,7 +181,6 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo

setDefaultGeneratorOptions();
try {
Helpers.generateServer((String) additionalProperties.get("client"), additionalProperties);
additionalProperties.put("utilsPackageVersion", Helpers.getPackageJsonVersion("client-common"));
additionalProperties.put("npmNamespace", Helpers.getClientConfigField("javascript", "npmNamespace"));
} catch (GeneratorException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.algolia.codegen;

import com.algolia.codegen.exceptions.GeneratorException;
import com.algolia.codegen.utils.*;
import com.algolia.codegen.utils.OneOf;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.io.File;
Expand Down Expand Up @@ -114,22 +114,18 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("README_BOM.mustache", "client-bom", "README.md"));

additionalProperties.put("packageVersion", Helpers.getClientConfigField("kotlin", "packageVersion"));

try {
Helpers.generateServer(client, additionalProperties);
hostForKotlin();
} catch (GeneratorException e) {
e.printStackTrace();
System.exit(1);
}
}

/** Convert a Seq type to a valid class name. */
private String typeToName(String content) {
return content.trim().replace("<", "Of").replace(">", "").replace(", ", "").replace(".", "");
}

private void hostForKotlin() {
@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);

String host = (String) additionalProperties.get("regionalHost");
if (host != null) {
String hostForKotlin = host.replaceAll("\\{([^}]+)}", "\\$$1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.algolia.codegen.exceptions.*;
import com.algolia.codegen.utils.*;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.util.List;
Expand Down Expand Up @@ -49,14 +50,19 @@ public void processOpts() {

setDefaultGeneratorOptions(client);
try {
Helpers.generateServer(client, additionalProperties);
additionalProperties.put("packageVersion", Helpers.getClientConfigField("php", "packageVersion"));
} catch (GeneratorException e) {
e.printStackTrace();
System.exit(1);
}
}

@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
return Helpers.specifyCustomRequest(super.fromOperation(path, httpMethod, operation, servers));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.algolia.codegen.exceptions.*;
import com.algolia.codegen.utils.*;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.util.*;
Expand Down Expand Up @@ -83,13 +84,12 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("__init__.mustache", packageName + "/models", "__init__.py"));
supportingFiles.add(new SupportingFile("__init__.mustache", "http", "__init__.py"));
supportingFiles.add(new SupportingFile("config.mustache", packageName, "config.py"));
}

try {
Helpers.generateServer(CLIENT, additionalProperties);
} catch (GeneratorException e) {
e.printStackTrace();
System.exit(1);
}
@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.algolia.codegen.exceptions.*;
import com.algolia.codegen.utils.*;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.util.*;
Expand Down Expand Up @@ -60,15 +61,12 @@ public void processOpts() {
file.getTemplateFile().equals("spec_helper.mustache") ||
file.getTemplateFile().equals("rubocop.mustache")
);
}

// repository

try {
Helpers.generateServer(CLIENT, additionalProperties);
} catch (GeneratorException e) {
e.printStackTrace();
System.exit(1);
}
@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.algolia.codegen.exceptions.GeneratorException;
import com.algolia.codegen.utils.*;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import java.io.File;
Expand Down Expand Up @@ -77,7 +78,6 @@ public void processOpts() {
nameMapping.putAll(NAME_MAPPING);

try {
Helpers.generateServer(client, additionalProperties);
additionalProperties.put("packageVersion", Helpers.getClientConfigField("scala", "packageVersion"));
} catch (GeneratorException e) {
logger.severe(e.getMessage());
Expand All @@ -90,6 +90,12 @@ private String typeToName(String content) {
return content.trim().replace("[", "Of").replace("]", "").replace(".", "").replace(", ", "");
}

@Override
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did the client worked without this ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was called line 80 before, I just changed the way the function work so I had to move it here

public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
CodegenOperation ope = super.fromOperation(path, httpMethod, operation, servers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.algolia.codegen.utils.Helpers;
import com.algolia.codegen.utils.OneOf;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Schema;
Expand Down Expand Up @@ -116,7 +117,6 @@ public void processOpts() {
Helpers.setGenerationBanner(additionalProperties);

try {
Helpers.generateServer(CLIENT, additionalProperties);
additionalProperties.put("packageVersion", Helpers.getClientConfigField("swift", "packageVersion"));
additionalProperties.put("packageList", Helpers.getClientListForLanguage("swift"));
} catch (GeneratorException e) {
Expand Down Expand Up @@ -187,6 +187,12 @@ private void updateModelsOneOfForSwift(Map<String, ModelsMap> models, String mod
}
}

@Override
public void processOpenAPI(OpenAPI openAPI) {
super.processOpenAPI(openAPI);
Helpers.generateServers(super.fromServers(openAPI.getServers()), additionalProperties);
}

@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
Map<String, ModelsMap> models = super.postProcessAllModels(objs);
Expand Down
Loading
Loading