I've tried to generate project out of sample petstore openapi.json supplied. I used light-codegen to generate endpoints and model.
I did install light-codegen:
git clone https://github.com/networknt/light-codegen.git
cd light-codegen
mvn clean install
Then I run codegen from my project folder:
java -jar ../../networknt/light-codegen/codegen-cli/target/codegen-cli.jar -f openapi -o /tmp/petstore -m openapi.json -c config.json
I see the following error in the output:
openapi openapi.json config.json /tmp/petstore
19:16:00.766 [main] INFO com.networknt.config.Config - daily config cache refresh
19:16:00.772 [main] INFO com.networknt.config.Config - Unable to load config from externalized folder for service.yml in
19:16:00.772 [main] INFO com.networknt.config.Config - Trying to load config from classpath directory for file service.yml
19:16:00.774 [main] INFO com.networknt.config.Config - Config loaded from default folder for service.yml
19:16:04.799 [main] INFO com.fizzed.rocker.runtime.RockerRuntime - Rocker version 0.22.0
19:16:04.801 [main] INFO com.fizzed.rocker.runtime.RockerRuntime - Rocker template reloading not activated
java.nio.file.NoSuchFileException: /tmp/petstore/src/test/resources/config/client.keystore
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
at java.nio.file.Files.newOutputStream(Files.java:216)
at java.nio.file.Files.copy(Files.java:3016)
at com.networknt.codegen.rest.OpenApiGenerator.generate(OpenApiGenerator.java:367)
at com.networknt.codegen.Cli.run(Cli.java:98)
at com.networknt.codegen.Cli.main(Cli.java:50)
Do I need to supply client.keystore somehow?
config.json
{
"name": "petstore",
"version": "3.0.1",
"groupId": "com.networknt",
"artifactId": "petstore",
"rootPackage": "com.networknt.petstore",
"handlerPackage":"com.networknt.petstore.handler",
"modelPackage":"com.networknt.petstore.model",
"overwriteHandler": true,
"overwriteHandlerTest": true,
"overwriteModel": true,
"httpPort": 8080,
"enableHttp": false,
"httpsPort": 8443,
"enableHttps": true,
"enableHttp2": true,
"enableRegistry": false,
"supportDb": false,
"supportH2ForTest": false,
"supportClient": false,
"specChangeCodeReGenOnly": true,
"dockerOrganization": "networknt"
}
openapi.json: https://github.com/networknt/light-example-4j/blob/master/rest/perstore-with-codegen/petstore-spec/config/openapi.json
In the configuration, the supportClient is set as false. In this case, there is no need to have client.keystore to be generated. I am guessing this is the directory issue.
If you want to generate the petstore project in openapi, then the best way is to run the generator from your workspace with both light-codegen and model-config as subfolders in it.
java -jar light-codegen/codegen-cli/target/codegen-cli.jar -f openapi -o /tmp/petstore -m model-config/rest/openapi/petstore/1.0.0/openapi.json -c model-config/rest/openapi/petstore/1.0.0/config.json
The configuration in light-example-4j/rest/petstore-with-maven/petstore-spec/config is not for the code generation from command line but from maven plugin.If you want to generate code from that folder, here is the command line.
java -jar light-codegen/codegen-cli/target/codegen-cli.jar -f openapi -o /tmp/petstore -m light-example-4j/rest/perstore-with-codegen/petstore-spec/config/openapi.yaml -c light-example-4j/rest/perstore-with-codegen/petstore-spec/config/config.json
I have tried both commands and they are all working fine on my desktop. Let me know your steps in detail so that I can replicate the issue. Thanks.