2

Here is the pom.xml:

      <plugin>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <executions>
          
          <execution>
            <configuration>


              <configOptions>
                <apiPackage>com.core.client</apiPackage>
                <dateLibrary>java8</dateLibrary>
                <modelPackage>com.core.client.model</modelPackage>
                <packageName>co.core</packageName>
                <sourceFolder>restclient</sourceFolder>
                <useLombok>true</useLombok>
                <useOptional>true</useOptional>
                <useTags>true</useTags>
              </configOptions>
              <generateApiDocumentation>false</generateApiDocumentation>
              <generateApiTests>false</generateApiTests>
              <generateModelDocumentation>false</generateModelDocumentation>
              <generateModelTests>false</generateModelTests>
              <generatorName>java</generatorName>
              <inputSpec>
                GitHub link
              </inputSpec>
              <library>jersey2</library>
            </configuration>
            <goals>
              <goal>generate</goal>
            </goals>
            <id>Generate client</id>
          </execution>
        </executions>
        <groupId>org.openapitools</groupId>
        <version>6.2.1</version>
      </plugin>

I am using 6.2.1 version of the OpenAPI Generator Maven plugin.

I want to pull the <inputSpec> from a private GitHub repo and without giving the password/token in my pom.xml. Is there a way to pick it from settings.xml?

Helen
  • 87,344
  • 17
  • 243
  • 314
Nitish Agarwal
  • 692
  • 1
  • 6
  • 16

1 Answers1

0

I wouldn't try to do this via the input spec. I think the best way would be to download the file separately, and put it in a defined location. Then, use that location and file name as your input spec.

This post describes how to execute a curl command to download a single file from a private repo.

curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path

The key here is adding the Authorization to the header of the request. The -O flag saves the file in the current location.

You can use the exec-maven-plugin to download your file via a maven command. Here's an example from another stackoverflow post explaining how to use it with a curl command.


Edit:

If you want to use an external properties file in gradle, you can reference it input Stream. for example:

def props = new Properties()
file("setting.yml").withInputStream { props.load(it) }

Now, in your exec-maven-plugin, you can set the header to use the token as follow

 <argument>-H 'Authorization: token ${props.getProperty("access.token")}'</argument>
tbatch
  • 1,398
  • 10
  • 21