Я сгенерировал API в Swagger (API 3.0.0):
Предложение-Апи:
openapi: 3.0.0
[…]
paths:
/offers:
get:
summary: get all offers
operationId: allOffers
description: return ALL offers
responses:
'200':
description: search results matching criteria
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ApiOffer'
links:
GetOffererById:
$ref: 'https://api.swaggerhub.com/apis/comp/offers/1.0.0#/components/links/GetSingleOffererById'
GetOfferById:
$ref: '#/components/links/GetSingleOfferById'
'400':
description: something went terribly wrong
[…]
Я скопировал этот контент в свой проект как «Offers.yaml» и попытался скомпилировать его через «openapi-generator-maven-plugin»
[…]
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
[…]
<execution>
<id>Offers</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/Offers.yaml</inputSpec>
<modelPackage>${project.modelpackage}</modelPackage>
<apiPackage>${project.apipackage}</apiPackage>
<generateApis>false</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>true</generateModelTests>
<withXml>true</withXml>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>false</generateSupportingFiles>
<generatorName>java</generatorName>
<library>jersey2</library>
<validateSpec>false</validateSpec>
<configOptions>
<sourceFolder>src/gen/java/</sourceFolder>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<useBeanValidation>true</useBeanValidation>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
[…]
Во время maven-compile возникает следующая ошибка:
[INFO]
[INFO] --- openapi-generator-maven-plugin:3.3.0:generate (Offers) @ server ---
[ERROR] unable to read
java.io.FileNotFoundException: https://api.swaggerhub.com/apis/comp/offerers/1.0.0
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1890)
Конечно, https://api.swaggerhub.com/apis/comp/offerers/1.0.0 является ЧАСТНЫМ API. Но есть ли способ сообщить плагину maven правильные учетные данные, чтобы он мог в любом случае получить доступ к этому API?