Open H21lab opened 4 years ago
Please use the jersey2
library, which has better support for oneOf, anyOf.
I have tested it by using
<generatorName>java</generatorName>
<library>jersey2</library>
After it was not possible to compile the project and I have to modify AbstractOpenApiSchema.java:
//package com.h21lab.TS29573_N32_Handshake.handler.model;
package com.h21lab.TS29573_N32_Handshake.handler;
And also the ApiClient.java:
//import com.h21lab.TS29573_N32_Handshake.handler.model.AbstractOpenApiSchema;
import com.h21lab.TS29573_N32_Handshake.handler.AbstractOpenApiSchema;
Then the client worked. (with jersey2, the difference is, there are no async method).
Now there was method generated from anyOf type and possible to set value by securityCapability.setActualInstance("some string");
After also the response from the server was correctly processed and deserialized into SecNegotiateRspData.
My issue might be related.
My schema has:
fields:
type: array
items:
anyOf:
- $ref: '#/components/schemas/CircularField'
- $ref: '#/components/schemas/Field'
And I both Field
and CircularField
get generated (java
and resttemplate
lib). But CircularField
tries to import AnyOfCircularFieldField
- but there is no such class.
Will https://github.com/OpenAPITools/openapi-generator/pull/7263 fix this?
I hate to report that this behaviour is also found in version7.9.0
I generate with
java -jar openapi-generator-cli-7.7.0.jar \
generate \
--input-spec TS29510_Nnrf_NFDiscovery.yaml \
--generator-name jaxrs-jersey \
--output temp/java \
--config TS29510_Nnrf_NFDiscovery.json
With these options in the json file
{
"apiPackage": "com.telefonica.iot.nrf.service.openapi.rel17.discovery.api",
"modelPackage": "com.telefonica.iot.nrf.service.openapi.rel17.discovery.model",
"dateLibrary": "java8",
"generateBuilders": true,
"generateConstructorWithAllArgs": true
}
And this data definition in the specs
NFType:
description: NF types known to NRF
anyOf:
- type: string
enum:
- NRF
- UDM
[...]
- SMS_ROUTER
- type: string
It generates a class without properties/internal_variables like this
The server launch an error if I try to run it
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response com.telefonica.iot.nrf.service.openapi.rel17.management.api.NfInstancesApi.getNFInstances(com.telefonica.iot.nrf.service.openapi.rel17.management.model.NFType,java.lang.Integer
Bug Report Checklist
Description
While generating the TS29573_N32_Handshake.yaml to create java client, the java class SecurityCapability is generated with no relevant methods and it looks empty (there are no method to be able to passing values inside). However in yaml file the object is defined in the following way:
openapi-generator version
5.0.0-SNAPSHOT
OpenAPI declaration file content or url
https://github.com/jdegre/5GC_APIs/blob/master/TS29573_N32_Handshake.yaml
Command line used for generation
Generated by openapi-generator-maven-plugin by using following options:
Steps to reproduce
Generator will produce the following class with no relevant methods or variables:
Related issues/PRs
Suggest a fix