Skip to content

Extra tools for working with Kiota in Maven Java projects

License

Notifications You must be signed in to change notification settings

kiota-community/kiota-java-extra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kiota Java Extra

Release

Integrations, utilities and alternative implementations to work with Kiota in Java.

Maven Plugin

The Kiota Maven plugin eases the usage of the Kiota CLI from Maven projects. To use the plugin add this section to your pom.xml:

  <build>
    <plugins>
      <plugin>
        <artifactId>kiota-maven-plugin</artifactId>
        <groupId>io.kiota</groupId>
        <version>${version}</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <file>openapi.yaml</file>
            ... or ...
          <url>https://raw.githubusercontent.com/OpenAPITools/openapi-petstore/master/src/main/resources/openapi.yaml</url>
          ...
        </configuration>
      </plugin>
    </plugins>
  </build>

the available options, as of today, are (output of mvn help:describe -DgroupId=io.kiota -DartifactId=kiota-maven-plugin -Dversion=999-SNAPSHOT -Ddetail):

Available parameters:

    baseURL (Default:
    https://github.com/andreaTP/kiota-prerelease/releases/download)
      Base URL to be used for the download

    cleanOutput (Default: false)
      Clean output before generating

    clearCache (Default: false)
      Clear cache before generating

    clientClass (Default: ApiClient)
      The class name to use for the core client class. [default: ApiClient]

    deserializers (Default:
    io.kiota.serialization.json.JsonParseNodeFactory,com.microsoft.kiota.serialization.TextParseNodeFactory,com.microsoft.kiota.serialization.FormParseNodeFactory)
      The deserializers to be used by kiota

    downloadTarget (Default: ${basedir}/target/openapi-spec)
      The Download target folder for CRDs downloaded from remote URLs

    file
      The openapi specification to be used for generating code

    kiotaLogLevel (Default: Warning)
      The log level of Kiota to use when logging messages to the main output.
      [default: Warning]

    kiotaTimeout (Default: 30)
      Kiota timeout in seconds

    kiotaVersion (Default: 0.0.0-pre+microsoft.main.f84da5a)
      Version of Kiota to be used

    language (Default: Java)
      Language to generate the code for:

    namespace (Default: com.apisdk)
      The namespace to use for the core client class specified with the
      --class-name option. [default: ApiSdk]

    osName (Default: ${os.name})
      OS name

    serializers (Default:
    io.kiota.serialization.json.JsonSerializationWriterFactory,com.microsoft.kiota.serialization.TextSerializationWriterFactory,com.microsoft.kiota.serialization.FormSerializationWriterFactory,com.microsoft.kiota.serialization.MultipartSerializationWriterFactory)
      The serializers to be used by kiota

    skip (Default: false)
      User property: kiota.skip
      Skip the execution of the goal

    targetBinaryFolder (Default:
    ${project.build.directory}/kiota/)
      Required: true
      Kiota executable target binary folder

    targetDirectory (Default:
    ${project.build.directory}/generated-sources/kiota)
      Location where to generate the Java code

    url
      The URL to be used to download an API spec from a remote location

    useSystemKiota (Default: false)
      User property: kiota.system
      Use system provided kiota executable (needs to be available on the PATH)

Quarkus extension

The Quarkus extension now lives in the Quarkiverse organization:

https://github.com/quarkiverse/quarkus-kiota

Libraries

In this project you have a few alternative implementations of the Kiota Core libraries

Serialization Jackson

This is a Jackson based implementation of the Json serialization/deserialization APIs exposed by the core libraries.

To use it, add the following dependency to your project:

<dependency>
  <groupId>io.kiota</groupId>
  <artifactId>kiota-serialization-jackson</artifactId>
  <version>VERSION</version>
</dependency>

and make sure to remove from the classpath the default implementation com.microsoft.kiota:microsoft-kiota-serialization-json. When generating the client code you need to change the defaults as well to use the provided implementations:

  • serializer: io.kiota.serialization.json.JsonSerializationWriterFactory
  • deserializer: io.kiota.serialization.json.JsonParseNodeFactory

Http Vert.X

This is a RequestAdapter implementation based on the Vert.X Web Client.

To use it, add the following dependency to your project:

<dependency>
  <groupId>io.kiota</groupId>
  <artifactId>kiota-http-vertx</artifactId>
  <version>VERSION</version>
</dependency>

and make sure to remove from the classpath the default implementation com.microsoft.kiota:microsoft-kiota-http-okHttp. You can now use it in your codebase:

var adapter = new VertXRequestAdapter(vertx);

To configure authorization we expect you to tweak the VertX.WebClient instance before passing it to the constructor. For example, using OIDC with Client Id and secret, your code might look like this:

OAuth2Options options =
        new OAuth2Options()
                .setFlow(OAuth2FlowType.CLIENT)
                .setClientId(CLIENT_ID)
                .setTokenPath(keycloakUrl + "token")
                .setClientSecret(CLIENT_SECRET);

OAuth2Auth oAuth2Auth = OAuth2Auth.create(vertx, options);

Oauth2Credentials oauth2Credentials = new Oauth2Credentials();

OAuth2WebClient oAuth2WebClient =
        OAuth2WebClient.create(WebClient.create(vertx), oAuth2Auth)
                .withCredentials(oauth2Credentials);

var adapter = new VertXRequestAdapter(oAuth2WebClient);

Http JDK

This is a RequestAdapter implementation based on the Java standard library Http Client.

To use it, add the dependency to your project:

<dependency>
  <groupId>io.kiota</groupId>
  <artifactId>kiota-http-jdk</artifactId>
  <version>VERSION</version>
</dependency>

and make sure to remove from the classpath the default implementation com.microsoft.kiota:microsoft-kiota-http-okHttp.

About

Extra tools for working with Kiota in Maven Java projects

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages