Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bamboo Swagger generated library has problems

George Lindholm December 28, 2022

Hi,
   I'm trying to use the bamboo openAPI with Swagger to generate a java library, but I'm not having problems with the generated code. It's having problems with "parsing" children of the root.

I'm generating the library using:

{code:xml}

<jackson-version>2.14.1</jackson-version>

...

<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.2.1</version>
<configuration>
<generatorName>java</generatorName>
<logToStderr>true</logToStderr>
<verbose>false</verbose>
<configOptions>
<openApiNullable>true</openApiNullable>
<asyncNative>true</asyncNative>
<sourceFolder>src/gen/java/main</sourceFolder>
<dateLibrary>java11</dateLibrary>
<developerName>George Lindholm</developerName>
<developerEmail>javadev@glindholm.me</developerEmail>
<developerOrganization>self</developerOrganization>
<serializableModel>false</serializableModel>
</configOptions>
<httpUserAgent>Jira Cloud Java Client ${project.version}</httpUserAgent>
<packageName>me.glindholm.jira.jjc</packageName>
<modelPackage>me.glindholm.jira.jjc.model</modelPackage>
<invokerPackage>me.glindholm.jira.jjc.invoker</invokerPackage>
<library>native</library>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<artifactVersion>${project.version}</artifactVersion>
<skip>false</skip>
<skipValidateSpec>true</skipValidateSpec>
<withXml>false</withXml>
<generateModelDocumentation>false</generateModelDocumentation>
<addCompileSourceRoot>true</addCompileSourceRoot>
</configuration>
<executions>
<execution>
<id>bamboo</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/json/bamboo.json</inputSpec>
<apiPackage>me.glindholm.bamboo.api</apiPackage>
<invokerPackage>me.glindholm.bamboo.invoker</invokerPackage>
<modelPackage>me.glindholm.bamboo.model</modelPackage>
<modelNamePrefix></modelNamePrefix>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
{code:xml}

I'm testing the code like this:
{code:java}

ApiClient apiClient;

@BeforeEach
public void connect() {
apiClient = new ApiClient();
apiClient.updateBaseUri("https://192.168.0.208:9383/rest");
apiClient.setRequestInterceptor(authorize -> authorize.header("Authorization", basicAuth("xxx", "yyy")));

}

private static String basicAuth(final String username, final String password) {
return "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
}

@TEST
public void testServer() throws InterruptedException, ExecutionException, ApiException {
final DefaultApi def = new DefaultApi(apiClient);

final RestInfo serverInfo = def.getInfo().get();
log.info("{}", serverInfo);
}

@TEST
public void testAllPlans() throws InterruptedException, ExecutionException, ApiException {
final BuildApi build = new BuildApi(apiClient);

final RestPlans plans = build.getAllPlanList(null).get();
log.info("{}", plans);
}

{code:java}

I get this from the server in a browser:
{code:json}
{
"expand": "plans",
"link": {
"href": "http://192.168.0.208:9680/rest/api/latest/plan",
"rel": "self"
},
"plans": {
"size": 1,
"expand": "plan",
"start-index": 0,
"max-result": 1,
"plan": [
{
"shortName": "Connector",
"shortKey": "CON",
"type": "chain",
"enabled": false,
"link": {
"href": "http://192.168.0.208:9680/rest/api/latest/plan/AP-CON",
"rel": "self"
},
"key": "AP-CON",
"name": "API Plan - Connector",
"planKey": {
"key": "AP-CON"
}
}
]
}
}
{code:json}

But what I get back from the library is:

2022-12-28 11:02:38 INFO me.glindholm.TestBamboo9:66 - class RestPlans {
link: class Link {
href: http://192.168.0.208:9680/rest/api/latest/plan
rel: self
}
plans: class RestPlanList {
startIndex: null
maxResult: null
size: 1
callback: JsonNullable[null]
plans: null
allElements: null
}
}
2022-12-28 11:02:38 TRACE me.glindholm.TestBamboo9:52 - class RestInfo {
version: 9.1.0
edition:
buildDate: Wed Dec 14 07:39:00 PST 2022
buildNumber: 90100
state: RUNNING
}

 

I also get an Exception when  i call BuildApi.getPlan("AP-CON", "", ""):

Caused by: me.glindholm.bamboo.invoker.ApiException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
at [Source: (String)"{"expand":"actions,stages,branches,variableContext","projectKey":"AP","projectName":"API Plan","project":{"key":"AP","name":"API Plan","description":"Connector testing","link":{"href":"https://192.168.0.208:9383/rest/api/latest/project/AP","rel":"self"}},"shortName":"Connector","buildName":"Connector","shortKey":"CON","type":"chain","enabled":true,"link":{"href":"https://192.168.0.208:9383/rest/api/latest/plan/AP-CON","rel":"self"},"isFavourite":false,"isActive":false,"isBuilding":false,"average"[truncated 298 chars]; line: 1, column: 782] (through reference chain: me.glindholm.bamboo.model.RestPlan["planKey"])
at me.glindholm.bamboo.api.BuildApi.lambda$29(BuildApi.java:1393)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
at [Source: (String)"{"expand":"actions,stages,branches,variableContext","projectKey":"AP","projectName":"API Plan","project":{"key":"AP","name":"API Plan","description":"Connector testing","link":{"href":"https://192.168.0.208:9383/rest/api/latest/project/AP","rel":"self"}},"shortName":"Connector","buildName":"Connector","shortKey":"CON","type":"chain","enabled":true,"link":{"href":"https://192.168.0.208:9383/rest/api/latest/plan/AP-CON","rel":"self"},"isFavourite":false,"isActive":false,"isBuilding":false,"average"[truncated 298 chars]; line: 1, column: 782] (through reference chain: me.glindholm.bamboo.model.RestPlan["planKey"])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1746)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1520)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1425)
at com.fasterxml.jackson.databind.DeserializationContext.extractScalarFromObject(DeserializationContext.java:937)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseString(StdDeserializer.java:1421)
at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:48)
at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4697)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3652)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3635)
at me.glindholm.bamboo.api.BuildApi.lambda$29(BuildApi.java:1390)
... 7 more

 

Looking for ideas as to what is going wrong?

Thanks

    George

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events