Bug 250 - Converting ETSI NFV OpenApi SOL003 VNF Lifecycle management JSON to swagger spring code results in errors
Summary: Converting ETSI NFV OpenApi SOL003 VNF Lifecycle management JSON to swagger s...
Status: RESOLVED FIXED
Alias: None
Product: NFV
Classification: Unclassified
Component: Nfv-Openapis (show other bugs)
Version: unspecified
Hardware: PC Windows
Assignee: Bruno Chatras
 
Reported: 2019-08-28 22:57 CEST by sivaprasath busa
Modified: 2019-09-02 11:56 CEST (History)
4 users (show)

See Also:
Version number of the related document:
OpenAPI issue category: ---


Attachments
Errors from the command line tool (145.20 KB, text/rtf)
2019-08-28 22:57 CEST, sivaprasath busa
Details
SOL003-VNFLifecycleManagement-API.json (74.87 KB, application/json)
2019-08-28 22:58 CEST, sivaprasath busa
Details
Jenkins script dump (15.34 KB, text/rtf)
2019-08-28 23:05 CEST, sivaprasath busa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sivaprasath busa 2019-08-28 22:57:56 CEST
Created attachment 14 [details]
Errors from the command line tool

Hi,

When I try to generate spring JAVA openApi annotations for ETSI NFV SOL003 LifecycleManagement API json file, it results in errors.

Attached both the command line conversion dump with errors and also the json input file I used.

Command I used for conversion is as below:

swagger-codegen generate -i build/SOL-003/json/SOL003-VNFLifecycleManagement-API.json -l spring -o springCodeSamples/ -c myOptions.json
Comment 1 sivaprasath busa 2019-08-28 22:58:31 CEST
Created attachment 15 [details]
SOL003-VNFLifecycleManagement-API.json
Comment 2 sivaprasath busa 2019-08-28 23:01:34 CEST
Also, when I tried to access json file from NFV Solutions wiki, its null.

https://forge.etsi.org/jenkins/job/NFV%20-%20Network%20Functions%20Virtualisation/job/sol002-sol003-master/lastSuccessfulBuild/artifact/build/SOL003-VNFLifecycleManagement-API.json/*view*/


Could you please share the working version of SOL003-VNFLifecycleManagement-API.json, the file thats present in the https://forge.etsi.org/rep/nfv/SOL002-SOL003/tree/master seems to have errors.
Comment 3 sivaprasath busa 2019-08-28 23:05:24 CEST
I also tried generating json files as suggested in https://forge.etsi.org/rep/nfv/SOL002-SOL003/tree/master with the command - "sudo bash .jenkins.sh", which is  also resulting in some errors.

Attached jenkins script dump to the bug.

yaml file is empty
cat SOL003-VNFLifecycleManagement-API.yaml

JSON file generated is null
cat SOL003-VNFIndicator-API.json
Comment 4 sivaprasath busa 2019-08-28 23:05:44 CEST
Created attachment 16 [details]
Jenkins script dump
Comment 5 Giacomo Bernini 2019-08-30 15:56:22 CEST
(In reply to sivaprasath busa from comment #0)

Are you sure you're using the codegen for Swagger 2.0?
It seems from the logs you're using the one for OpenAPI 3.0

> Created attachment 14 [details]
> Errors from the command line tool
> 
> Hi,
> 
> When I try to generate spring JAVA openApi annotations for ETSI NFV SOL003
> LifecycleManagement API json file, it results in errors.
> 
> Attached both the command line conversion dump with errors and also the json
> input file I used.
> 
> Command I used for conversion is as below:
> 
> swagger-codegen generate -i
> build/SOL-003/json/SOL003-VNFLifecycleManagement-API.json -l spring -o
> springCodeSamples/ -c myOptions.json
Comment 6 Giacomo Bernini 2019-08-30 15:58:01 CEST
(In reply to sivaprasath busa from comment #2)

The full list of available OpenAPI representations for the different SOL specs versions is available here:

https://nfvwiki.etsi.org/index.php?title=SOL_OpenAPI_Representations

Please mind that for v2.5.1 there are few issues to be fixed with the hyperlinks.

The v2.6.1 draft should anyway be already stable.


> Also, when I tried to access json file from NFV Solutions wiki, its null.
> 
> https://forge.etsi.org/jenkins/job/NFV%20-
> %20Network%20Functions%20Virtualisation/job/sol002-sol003-master/
> lastSuccessfulBuild/artifact/build/SOL003-VNFLifecycleManagement-API.json/
> *view*/
> 
> 
> Could you please share the working version of
> SOL003-VNFLifecycleManagement-API.json, the file thats present in the
> https://forge.etsi.org/rep/nfv/SOL002-SOL003/tree/master seems to have
> errors.
Comment 7 sivaprasath busa 2019-08-30 20:19:25 CEST
Yes, thanks for the observation. swagger-codegen I'm on is the published version which I installed through brew in my mac. It's pointing to 3.0 as below.

$ swagger-codegen version
11:01:34.631 [main] DEBUG io.swagger.codegen.v3.cli.SwaggerCodegen - there are not options for command 'langs'
11:01:34.633 [main] DEBUG io.swagger.codegen.v3.cli.SwaggerCodegen - there are not options for command 'version'

3.0.10

I moved to swagger-codegen@2 just now with brew. 

When I run this command as below:
$ swagger-codegen generate -i src/SOL003/VNFLifecycleManagement/VNFLifecycleManagement.yaml -l spring -o sol003-codegen-autogeneratedSpringBootSwaggerCode/ -c myOptions.json
[main] INFO io.swagger.parser.Swagger20Parser - reading from src/SOL003/VNFLifecycleManagement/VNFLifecycleManagement.yaml
Exception in thread "main" java.lang.RuntimeException: Unable to load RELATIVE ref: ../definitions/SOL002SOL003_def.yaml path: /Users/sbusa/workspace/SOL002-SOL003-master-swagger-autogen/src/SOL003/VNFLifecycleManagement
	at io.swagger.parser.util.RefUtils.readExternalRef(RefUtils.java:162)
	at io.swagger.parser.ResolverCache.loadRef(ResolverCache.java:118)
	at io.swagger.parser.processors.ExternalRefProcessor.processRefToExternalDefinition(ExternalRefProcessor.java:47)
	at io.swagger.parser.processors.ModelProcessor.processRefModel(ModelProcessor.java:95)
	at io.swagger.parser.processors.ModelProcessor.processModel(ModelProcessor.java:34)
	at io.swagger.parser.processors.ResponseProcessor.processResponse(ResponseProcessor.java:34)
	at io.swagger.parser.processors.OperationProcessor.processOperation(OperationProcessor.java:47)
	at io.swagger.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:102)
	at io.swagger.parser.SwaggerResolver.resolve(SwaggerResolver.java:66)
	at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:72)
	at io.swagger.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:431)
	at io.swagger.codegen.cmd.Generate.run(Generate.java:283)
	at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.RuntimeException: Could not find ../definitions/SOL002SOL003_def.yaml on the classpath
	at io.swagger.parser.util.ClasspathHelper.loadFileFromClasspath(ClasspathHelper.java:31)
	at io.swagger.parser.util.RefUtils.readExternalRef(RefUtils.java:156)
	... 12 more


I'm hitting relative path issues, could you please suggest how to run codegen on lifecylemanagement module, for other interfaces, it worked fine with just using the json file itself.
Comment 8 sivaprasath busa 2019-08-30 20:23:30 CEST
Thanks, I will try the openApi yaml file from here for vnf lifecycle managment: https://nfvwiki.etsi.org/index.php?title=SOL_OpenAPI_Representations
Comment 9 sivaprasath busa 2019-08-30 21:03:18 CEST
Hi,

Thanks for link, it works fine, I could autogenerate specs for all the openApi yaml files shared in the v2.6.1 draft version
Comment 10 sivaprasath busa 2019-08-30 21:04:25 CEST
Please resolve and close this bug as it works fine for me. Thanks for the help.
Comment 11 Vlademir Brusse 2019-09-02 11:56:53 CEST
After sharing the link with the full list of available OpenAPI representations for the different SOL specs versions (v2.5.1, v2.6.1) and the confirmation of the usage of the swagger-codegen tool utilities for OpenAPI v2.0 the issue was solved, as can be checked in the previous comments.