<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.holunda.c7._</groupId>
    <artifactId>c7-rest-client-spring-boot-parent</artifactId>
    <version>2026.04.1</version>
  </parent>

  <groupId>io.holunda.c7</groupId>
  <artifactId>c7-rest-client-spring-boot-openapi</artifactId>

  <name>support: c7-rest-client-spring-boot - openapi-client</name>

  <properties>
    <openapi-generator-version>7.21.0</openapi-generator-version>
    <camunda.openapi.package>org.camunda.community.rest.client</camunda.openapi.package>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>jakarta.validation</groupId>
      <artifactId>jakarta.validation-api</artifactId>
    </dependency>

    <!-- Feign -->
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-openfeign</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Jackson -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jdk8</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.module</groupId>
      <artifactId>jackson-module-kotlin</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Camunda Open API -->
    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine-rest-openapi</artifactId>
      <version>${camunda.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeArtifactIds>camunda-engine-rest-openapi</includeArtifactIds>
              <outputDirectory>${project.build.directory}/camunda-openapi</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.bobpaulin.maven.jsonp</groupId>
        <artifactId>jsonp-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>merge</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>merge</goal>
            </goals>
            <configuration>
              <sourceFile>${project.build.directory}/camunda-openapi/openapi.json</sourceFile>
              <overrideSourceFile>src/main/resources/override-camunda-openapi.json</overrideSourceFile>
              <outputFile>${project.build.directory}/camunda-openapi/openapi-merged.json</outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>${openapi-generator-version}</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.build.directory}/camunda-openapi/openapi-merged.json</inputSpec>
              <generatorName>spring</generatorName>
              <generateApiTests>false</generateApiTests>
              <generateModelTests>false</generateModelTests>
              <generateApiDocumentation>false</generateApiDocumentation>
              <generateModelDocumentation>false</generateModelDocumentation>
              <templateDirectory>openapi-templates</templateDirectory>
              <configOptions>
                <library>spring-cloud</library>
                <dateLibrary>java8</dateLibrary>
                <invokerPackage>${camunda.openapi.package}</invokerPackage>
                <apiPackage>${camunda.openapi.package}.api</apiPackage>
                <modelPackage>${camunda.openapi.package}.model</modelPackage>
                <configPackage>${camunda.openapi.package}.config</configPackage>
                <useBeanValidation>false</useBeanValidation>
                <useSpringBoot3>true</useSpringBoot3>
                <openApiNullable>false</openApiNullable>
                <useFeignClient>true</useFeignClient>
              </configOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>maven-replacer-plugin</artifactId>
        <executions>
          <execution>
            <id>changeDeploymentMultipartToArray</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>replace</goal>
            </goals>
            <configuration>
              <basedir>${project.basedir}</basedir>
              <includes>
                <include>target/generated-sources/openapi/**/DeploymentApi.java</include>
              </includes>
              <regex>false</regex>
              <replacements>
                <!-- RequestPart is needed to activate correct encoding, further array is needed to allow multiple files -->
                <replacement>
                  <token>@RequestPart(value = "data", required = false) MultipartFile data</token>
                  <value>@RequestPart(value = "data", required = false) MultipartFile[] data</value>
                </replacement>
                <replacement>
                  <token>@RequestParam(value = "tenant-id"</token>
                  <value>@RequestPart(value = "tenant-id"</value>
                </replacement>
                <replacement>
                  <token>@RequestParam(value = "deployment-source"</token>
                  <value>@RequestPart(value = "deployment-source"</value>
                </replacement>
                <replacement>
                  <token>@RequestParam(value = "deploy-changed-only"</token>
                  <value>@RequestPart(value = "deploy-changed-only"</value>
                </replacement>
                <replacement>
                  <token>@RequestParam(value = "enable-duplicate-filtering"</token>
                  <value>@RequestPart(value = "enable-duplicate-filtering"</value>
                </replacement>
                <replacement>
                  <token>@RequestParam(value = "deployment-name"</token>
                  <value>@RequestPart(value = "deployment-name"</value>
                </replacement>
                <replacement>
                  <token>@RequestParam(value = "deployment-activation-time"</token>
                  <value>@RequestPart(value = "deployment-activation-time"</value>
                </replacement>
              </replacements>
            </configuration>
          </execution>
          <execution>
            <id>changeEmptyRequestParamValue</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>replace</goal>
            </goals>
            <configuration>
              <basedir>${project.basedir}</basedir>
              <includes>
                <include>target/generated-sources/openapi/**/HistoryApi.java</include>
              </includes>
              <regex>false</regex>
              <replacements>
                <!-- RequestParam in HistoryApi is generated with value = "" for variableValue as this is specified with type object in openapi.json -->
                <replacement>
                  <token>@RequestParam(value = "",</token>
                  <value>@RequestParam(value = "variableValue",</value>
                </replacement>
              </replacements>
            </configuration>
          </execution>
          <execution>
            <id>changeProducesForExternalTask</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>replace</goal>
            </goals>
            <configuration>
              <basedir>${project.basedir}</basedir>
              <includes>
                <include>target/generated-sources/openapi/**/ExternalTaskApi.java</include>
              </includes>
              <regex>false</regex>
              <replacements>
                <!-- Produces should only contain text/plain for error details -->
                <replacement>
                  <token>produces = { "application/json", "text/plain" }</token>
                  <value>produces = { "text/plain" }</value>
                </replacement>
              </replacements>
            </configuration>
          </execution>
          <execution>
            <id>changeWronglyGeneratedExamples</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>replace</goal>
            </goals>
            <configuration>
              <basedir>${project.basedir}</basedir>
              <includes>
                <include>target/generated-sources/openapi/**/*Api.java</include>
              </includes>
              <regex>false</regex>
              <replacements>
                <!-- Examples have problems with double backslashes -->
                <replacement>
                  <token>\\"</token>
                  <value>\"</value>
                </replacement>
              </replacements>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
