Skip to content

Commit

Permalink
Bump Quarkus to 3.14 (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP authored Oct 16, 2024
1 parent 265be58 commit a87c9cf
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 123 deletions.
104 changes: 4 additions & 100 deletions deployment/src/main/java/io/kiota/quarkus/KiotaCodeGenConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,14 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.Optional;

import org.eclipse.microprofile.config.Config;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.quarkus.logging.Log;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;

// This configuration is read in codegen phase (before build time), the annotation is for
// documentation
// purposes and to avoid quarkus warnings
@ConfigRoot(name = "kiota", phase = ConfigPhase.BUILD_TIME)
public class KiotaCodeGenConfig {
static final String KIOTA_CONFIG_PREFIX = "quarkus.kiota";
// overwrite the automatically detected Operating System
Expand All @@ -33,19 +24,19 @@ public class KiotaCodeGenConfig {
// Path to a kiota executable file to be used
private static final String PROVIDED = KIOTA_CONFIG_PREFIX + ".provided";
// Kiota release url
private static final String DEFAULT_RELEASE_URL = "https://github.com/microsoft/kiota/releases";
static final String DEFAULT_RELEASE_URL = "https://github.com/microsoft/kiota/releases";
private static final String RELEASE_URL = KIOTA_CONFIG_PREFIX + ".release.url";
// Kiota version, will try to resolve latest if not provided
private static final String VERSION = KIOTA_CONFIG_PREFIX + ".version";
// Timout, in seconds, used when executing the Kiota CLI
private static final int DEFAULT_TIMEOUT = 30;
static final int DEFAULT_TIMEOUT = 30;
private static final String TIMEOUT = KIOTA_CONFIG_PREFIX + ".timeout";

// Kiota generate parameters
private static final String DEFAULT_CLIENT_NAME = "ApiClient";
static final String DEFAULT_CLIENT_NAME = "ApiClient";
private static final String CLIENT_CLASS_NAME = ".class-name";

private static final String DEFAULT_CLIENT_PACKAGE = "io.apisdk";
static final String DEFAULT_CLIENT_PACKAGE = "io.apisdk";
private static final String CLIENT_PACKAGE_NAME = ".package-name";
private static final String INCLUDE_PATH = ".include-path";
private static final String EXCLUDE_PATH = ".exclude-path";
Expand All @@ -62,12 +53,6 @@ public class KiotaCodeGenConfig {
"com.microsoft.kiota.serialization.FormParseNodeFactory");
private static final String DESERIALIZER = ".deserializer";

/**
* Overrides the detected Operating System
*/
@ConfigItem(name = "os")
public Optional<String> os;

public static io.quarkus.utilities.OS getOs(final Config config) {
String os = config.getConfigValue(OS).getValue();
if (os == null) {
Expand All @@ -76,12 +61,6 @@ public static io.quarkus.utilities.OS getOs(final Config config) {
return io.quarkus.utilities.OS.valueOf(os);
}

/**
* Overrides the detected Architecture
*/
@ConfigItem(name = "arch")
public Optional<String> arch;

public static String getArch(final Config config) {
String arch = config.getConfigValue(ARCH).getValue();
if (arch == null) {
Expand All @@ -90,23 +69,10 @@ public static String getArch(final Config config) {
return arch;
}

/**
* The path to a kiota executable location to be used.
* When set, the kiota version is not going to be checked/used.
*/
@ConfigItem(name = "provided")
public Optional<String> provided;

public static String getProvided(final Config config) {
return config.getConfigValue(PROVIDED).getValue();
}

/**
* The path to a kiota executable location to be used
*/
@ConfigItem(name = "release.url", defaultValue = DEFAULT_RELEASE_URL)
public Optional<String> releaseUrl;

public static String getReleaseUrl(final Config config) {
String releaseUrl = config.getConfigValue(RELEASE_URL).getValue();
if (releaseUrl != null) {
Expand All @@ -115,14 +81,6 @@ public static String getReleaseUrl(final Config config) {
return DEFAULT_RELEASE_URL;
}

/**
* The kiota version to be used.
* If not provided we are going to try to resolve "latest" from the GitHub API.
* Please, set this property in any production grade project.
*/
@ConfigItem(name = "version")
public Optional<String> version;

public static String getVersion(final Config config) {
String version = config.getConfigValue(VERSION).getValue();
if (version == null) {
Expand Down Expand Up @@ -179,12 +137,6 @@ public static String getVersion(final Config config) {
return version;
}

/**
* The timeout to be used when running the kiota CLI.
*/
@ConfigItem(name = "timeout", defaultValue = "" + DEFAULT_TIMEOUT)
public Optional<String> timeout;

public static int getTimeout(final Config config) {
String timeout = config.getConfigValue(TIMEOUT).getValue();
if (timeout != null) {
Expand All @@ -193,54 +145,6 @@ public static int getTimeout(final Config config) {
return DEFAULT_TIMEOUT;
}

/**
* Configuration resolved based on the OpenAPI description file name
*/
@ConfigItem(name = "spec-name")
public Optional<SpecConfig> specName;

@ConfigGroup
public static final class SpecConfig {

/**
* The generated API client class name.
*/
@ConfigItem(name = "class-name", defaultValue = DEFAULT_CLIENT_NAME)
public Optional<String> className;

/**
* The generated API client package name.
*/
@ConfigItem(name = "package-name", defaultValue = DEFAULT_CLIENT_PACKAGE)
public Optional<String> packageName;

/**
* The glob expression to be used to identify the endpoints to be included in the generation.
*/
@ConfigItem(name = "include-path")
public Optional<String> includePath;

/**
* The glob expression to be used to identify the endpoints to be excluded from the generation.
*/
@ConfigItem(name = "exclude-path")
public Optional<String> excludePath;

/**
* ADVANCED:
* The serializers to be used in the generated code.
*/
@ConfigItem(name = "serializer")
public Optional<List<String>> serializer;

/**
* ADVANCED:
* The deserializers to be used in the generated code.
*/
@ConfigItem(name = "deserializer")
public Optional<List<String>> deserializer;
}

public static String getClientClassName(final Config config, String filename) {
String clientName = config.getConfigValue(KIOTA_CONFIG_PREFIX + "." + filename + CLIENT_CLASS_NAME)
.getValue();
Expand Down
111 changes: 111 additions & 0 deletions deployment/src/main/java/io/kiota/quarkus/KiotaCodeGenConfigApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package io.kiota.quarkus;

import static io.kiota.quarkus.KiotaCodeGenConfig.DEFAULT_CLIENT_NAME;
import static io.kiota.quarkus.KiotaCodeGenConfig.DEFAULT_CLIENT_PACKAGE;
import static io.kiota.quarkus.KiotaCodeGenConfig.DEFAULT_RELEASE_URL;
import static io.kiota.quarkus.KiotaCodeGenConfig.DEFAULT_TIMEOUT;

import java.util.List;
import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithName;

@ConfigMapping(prefix = "quarkus.kiota")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface KiotaCodeGenConfigApi {
/**
* Overrides the detected Operating System
*/
@WithName("os")
Optional<String> os();

/**
* Overrides the detected Architecture
*/
@WithName("arch")
Optional<String> arch();

/**
* The path to a kiota executable location to be used.
* When set, the kiota version is not going to be checked/used.
*/
@WithName("provided")
Optional<String> provided();

/**
* The path to a kiota executable location to be used
*/
@WithName("release.url")
@WithDefault(DEFAULT_RELEASE_URL)
Optional<String> releaseUrl();

/**
* The kiota version to be used.
* If not provided we are going to try to resolve "latest" from the GitHub API.
* Please, set this property in any production grade project.
*/
@WithName("version")
Optional<String> version();

/**
* The timeout to be used when running the kiota CLI.
*/
@WithName("timeout")
@WithDefault("" + DEFAULT_TIMEOUT)
Optional<String> timeout();

/**
* Configuration resolved based on the OpenAPI description file name
*/
@WithName("spec-name")
Optional<SpecConfig> specName();

@ConfigGroup
public static interface SpecConfig {

/**
* The generated API client class name.
*/
@WithName("class-name")
@WithDefault(DEFAULT_CLIENT_NAME)
Optional<String> className();

/**
* The generated API client package name.
*/
@WithName("package-name")
@WithDefault(DEFAULT_CLIENT_PACKAGE)
Optional<String> packageName();

/**
* The glob expression to be used to identify the endpoints to be included in the generation.
*/
@WithName("include-path")
Optional<String> includePath();

/**
* The glob expression to be used to identify the endpoints to be excluded from the generation.
*/
@WithName("exclude-path")
Optional<String> excludePath();

/**
* ADVANCED:
* The serializers to be used in the generated code.
*/
@WithName("serializer")
Optional<List<String>> serializer();

/**
* ADVANCED:
* The deserializers to be used in the generated code.
*/
@WithName("deserializer")
Optional<List<String>> deserializer();
}
}
Loading

0 comments on commit a87c9cf

Please sign in to comment.