swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.91k stars 6.03k forks source link

C/C++ generator #283

Closed arschles closed 7 years ago

arschles commented 9 years ago

Does anyone know if there are plans to add support in this repo? Otherwise, is there a C/C++ generator elsewhere?

fehguy commented 9 years ago

I expect we'll have support shortly...

arschles commented 9 years ago

@fehguy thanks. can you point me to some in-progress code?

DougSchmidt-AI commented 9 years ago

@fehguy @arschles Any ETA or updates on the C++ generator? My team is looking for exactly this feature.

fehguy commented 9 years ago

One flavor should release next weds and should be easily adaptable. What flavor are you working with? What JSON libs, etc?

DougSchmidt-AI commented 9 years ago

We are just in the process of selecting appropriate http and JSON libraries (which was surprisingly non obvious). We've made no firm decision yet, and we'd likely go with whatever swagger-codegen supports. Our REST back end is implemented in ServiceStack, and its JSON serializer is very configurable.

rasmusstorjohann-AI commented 9 years ago

I work with @schmidt4brains . boost::property_tree looks pretty good for JSON, but I think JsonCpp would also be OK. boost::network::http looks like it might be the best option for networking, which means boost::future and friends for concurrency.

fehguy commented 9 years ago

OK, I'm pretty sure you can port what we've done to use those.

fehguy commented 9 years ago

Hi, the C++ templates are now available here:

https://github.com/swagger-api/swagger-codegen/tree/develop_2.0/src/main/resources/tizen

They were generously sponsored by Samsung and should be a good basis for any C++ implementation.

J-cztery commented 9 years ago

Hi, the link https://github.com/swagger-api/swagger-codegen/tree/develop_2.0/src/main/resources/tizen does not seem to work (404).

wing328 commented 9 years ago

Moved to https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/tizen

On Thu, Apr 9, 2015 at 2:31 PM, J-cztery notifications@github.com wrote:

Hi, the link https://github.com/swagger-api/swagger-codegen/tree/develop_2.0/src/main/resources/tizen does not seem to work (404).

— Reply to this email directly or view it on GitHub https://github.com/swagger-api/swagger-codegen/issues/283#issuecomment-91126986 .

webron commented 9 years ago

@fehguy - are we going to have a specific C++ implementation or stick with the Tizen one?

fehguy commented 9 years ago

@webron after spending time on this, I'm guessing we'll have many different c++ generators based on the frameworks, etc.

webron commented 9 years ago

If anyone on this thread wants to jump in and donate a template, that would be great.

Should be relatively easy now, for those who know C/C++ - https://github.com/swagger-api/swagger-codegen#making-your-own-codegen-modules.

MathiasWasAlreadyTaken commented 8 years ago

I have started to implement a C++ generator for Casablanca/cpprest. It is still in its early stages, meaning there are lots of implementation and verification left. But for the not so faint of heart who wants to test things out, it does creates something that is usable...in labs...check the readme for this fork. https://github.com/MathiasWasAlreadyTaken/swagger-codegen/tree/development

wing328 commented 8 years ago

@MathiasWasAlreadyTaken thanks for the contribution. Would you have time to submit a PR for the Casablanca/cpprest C++ generator? Let me know if you need any help.

MathiasWasAlreadyTaken commented 8 years ago

Hi @wing328! As soon as I have something that have been tested and I know works I will create a pull request. Right now I know that it lack lots of functionality that should not go into the main repo.

/Mathias

wing328 commented 8 years ago

@MathiasWasAlreadyTaken OK. Please take your time and let us know if you need any assistance.

KrishnaPG commented 8 years ago

+1 for cpprest generator. C/C++ strongly needs wider REST base and swagger is the best way

stunney commented 8 years ago

Another +1 for the cpprest sdk generator. PLEASE!!!!

wing328 commented 8 years ago

@MathiasWasAlreadyTaken if you've something ready for beta (a partially working C++ client), I would suggest you to submit a PR so that the community can start looking into it and file PRs for improvement.

MathiasWasAlreadyTaken commented 8 years ago

I would love to be able to work more on this, and the future is looking brighter. I might be able to do some work with it soon, so as soon as I have something that is runnable I'll submit a PR.

stunney commented 8 years ago

Do you have any more work done on it at all? You might get some assistance from others like myself :)

wing328 commented 8 years ago

@MathiasWasAlreadyTaken thanks for the update. Please take your time.

(My suggestion is that even though you've partially-finished c++ generator that's not runnable yet, it's still good to submit a PR to let the community helps improve it to make it runnable)

arschles commented 8 years ago

@schmidt4brains you asked above (a long time ago) if I have any updates or have made any progress. Just FYI that I don't and am not currently planning on working on the C++ generator anymore

DougSchmidt-AI commented 8 years ago

@arschles Thanks for the update. My team has taken an alternative approach to C++ code generation (they are basically hand-coding a wrapper layer for each REST endpoint they consume). It still feels like boilerplate work to me, but they are happy with it.

fehguy commented 8 years ago

I'd be happy to tackle the templates, providing a good example client + build instructions were provided.

wing328 commented 8 years ago

Here is another update related to C++ generator:

https://github.com/swagger-api/swagger-codegen/issues/2704#issuecomment-225537925

fehguy commented 7 years ago

We have C++ for QT + CPPRest so time to close this.

itschrono commented 6 years ago

Am I wrong or there is no server version for this two ? (qt5cpp-server, cpprest-server ?)

wing328 commented 6 years ago

@itschrono there are C++ server generators for Pistache and Restbed. Would that meet your requirement?

itschrono commented 6 years ago

I guess it will for my C++ (Qt5 standalone software). Now I may need a visual basic client (I known it's lame xD) see #6831

chrisinmtown commented 2 years ago

Forgive me for posting to a closed issue. The page https://github.com/swagger-api/swagger-codegen says "C++ is supported" as an API client. I consulted https://support.smartbear.com/swaggerhub/docs/apis/generating-code/index.html#generators where I see language names cpprest, qt5cpp and tizen. I downloaded swagger-codegen-cli.jar version 3.0.34 and ran it with argument generate -l cpprest (and the others) without luck. I see that https://editor.swagger.io/ has a Generate Client option cpprest but the standalone jar apparently does not. Is there an additional jar to download? Please guide me here. Thanks in advance.

% java -jar swagger-codegen-cli.jar version
3.0.34
% java -jar swagger-codegen-cli.jar generate -i openapi.yml -l c++ -o client
Exception in thread "main" java.lang.RuntimeException: Can't load config class with name c++ Available: dart
aspnetcore
csharp
csharp-dotnet2
go
go-server
dynamic-html
html
html2
java
jaxrs-cxf-client
jaxrs-cxf
inflector
jaxrs-cxf-cdi
jaxrs-spec
jaxrs-jersey
jaxrs-di
jaxrs-resteasy-eap
jaxrs-resteasy
micronaut
spring
nodejs-server
openapi
openapi-yaml
kotlin-client
kotlin-server
php
python
python-flask
r
ruby
scala
scala-akka-http-server
swift3
swift4
swift5
typescript-angular
typescript-axios
typescript-fetch
javascript

    at io.swagger.codegen.v3.CodegenConfigLoader.forName(CodegenConfigLoader.java:31)
    at io.swagger.codegen.v3.cli.SwaggerCodegen.main(SwaggerCodegen.java:96)
Caused by: java.lang.ClassNotFoundException: c++
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at io.swagger.codegen.v3.CodegenConfigLoader.forName(CodegenConfigLoader.java:29)
    ... 1 more
MiroYld commented 12 months ago

Can anyone re-open the ticket? Because we have exactly the same problem as @chrisinmtown