Closed tarurar closed 6 months ago
Steps to reproduce:
- install swagger-codegen client
- clone the selling partner api models repository
- run the code generation for example, for Sellers API:
swagger-codegen generate -i ../selling-partner-api-models/models/sellers-api-model/sellers.json -l csharp-dotnet2 -t ../selling-partner-api-models/clients/sellingpartner-api-aa-csharp/src/Amazon.SellingPartnerAPIAA/resources/swagger-codegen/templates
Output:
i.s.codegen.v3.AbstractGenerator - writing file /Users/atarutin/RiderProjects/selling-partner-api-client-library/./docs/Participation.md Exception in thread "Thread-0" java.lang.RuntimeException: Could not generate api file for 'Sellers' at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:579) at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:782) at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:388) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: com.github.jknack.handlebars.HandlebarsException: /handlebars/csharp-dotnet2/Users/atarutin/RiderProjects/selling-partner-api-client-library/../selling-partner-api-models/clients/sellingpartner-api-aa-csharp/src/Amazon.SellingPartnerAPIAA/resources/swagger-codegen/templates/api.mustache:1:3: The partial '/handlebars/csharp-dotnet2/partial_header.mustache' at '/handlebars/csharp-dotnet2/partial_header.mustache' could not be found at com.github.jknack.handlebars.internal.Partial.merge(Partial.java:236) at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130) at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95) at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130) at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:118) at com.github.jknack.handlebars.internal.ForwardingTemplate.apply(ForwardingTemplate.java:72) at io.swagger.codegen.v3.templates.HandlebarTemplateEngine.getRendered(HandlebarTemplateEngine.java:25) at io.swagger.codegen.v3.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:795) at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:538) ... 3 more
did this ever work for you?
@tarurar If you don't specify and output it will try to output the results on the folder you are executing this command. So it might be a permissions issue. I would suggest to use the "-o" option in order to specify an output.
I'm having a similar issue with the templates. When I try to generate using -t and the folder with the templates, I get the following error: ERROR io.swagger.codegen.AbstractGenerator - csharp-dotnet2\partial_header.mustache (The system cannot find the path specified) java.lang.RuntimeException: can't load template csharp-dotnet2\partial_header.mustache
@smargoli2 can you post the entire string that you are trying to execute?
I ended up creating empty partial_header.mustache and visibility.mustache files and the templates processed correctly. Now I have an error that 'The type or namespace name 'IApiAccessor' could not be found (are you missing a using directive or an assembly reference?)' in each API. Where is this interface defined? Also, how can I generate one API Client to use for all the models, instead of having an API client generated for each model?
There are many issues with the code generated from the templates. The IReadableConfiguration interface which is implemented by the configuration is not generated when using the mustache templates - there is no such interface. It is also missing the ExceptionFactory and GlobalConfiguration classes. Please advise!
@smargoli2 I haven't run into any issues with the code generation. If you post the full generation string you are using I might be able to help you troubleshoot.
java -jar swagger-codegen-cli.jar generate -i "AmazonAPIJsonModels\models\fba-small-and-light-api-model\fbaSmallandLight.json" -l csharp-dotnet2 -o "AmazonGeneratedModels\FBASmallLight" -t "AmazonAPIJsonModels\clients\sellingpartner-api-aa-csharp\src\Amazon.SellingPartnerAPIAA\resources\swagger-codegen\templates" --api-package FBASmallLightApi -DpackageName=FBASmallLightModel
The json file and templates are downloaded to my machine.
I found my issue, I was using the wrong language version in my generation string. It should be -l csharp, not csharp-dotnet2. I am still having an issue though when I try using the build.bat to create a dll.
ApiClient.cs(24,7): error CS0246: The type or namespace name 'RateLimiter' could not be found (are you missing a using directive or an assembly reference?)
ApiClient.cs(37,17): error CS0246: The type or namespace name 'TimeLimiter' could not be found (are you missing a using directive or an assembly reference?)
Is there a package reference that is missing?
@smargoli2 we use Java and I don't remember if we ran into this issue. But I do remember that how the swagger json was made the namespace of various classes were set to swagger.io. I manually fixed all of them to a more sensical namespace before generating anything from that.
Right, I did customize those namespaces.
The Java ApiClient.mustache has this import statement:
import com.google.common.util.concurrent.RateLimiter;
while the C# version says using RateLimiter;
but the Nuget package is not included. Do you have the package in your generated Java code...?
We do have have that package imported and had no issues using it. But again this is in Java and I did have some issues with dependencies but I don't remember if it was specific to import com.google.common.util.concurrent.RateLimiter. I'm not sure if you run into these types of issues in C# but when we do in Java I end up removing all of the downloaded dependencies and force the application to redownload them.
This is a very old issue that is probably not getting as much attention as it deserves. We encourage you to check if this is still an issue after the latest release and if you find that this is still a problem, please feel free to open a new issue and make a reference to this one.
closed for inactivity
Steps to reproduce:
swagger-codegen generate -i ../selling-partner-api-models/models/sellers-api-model/sellers.json -l csharp-dotnet2 -t ../selling-partner-api-models/clients/sellingpartner-api-aa-csharp/src/Amazon.SellingPartnerAPIAA/resources/swagger-codegen/templates
Output: