Comments (8)
I added the support for Pistache on swagger-codegen.
It generates a server stub using Pistache as C++ server library and Json for Modern C++ for JSON serialization/deserialization.
An example of the automatically generated code can be found here.
from pistache.
Yes, you have to build with rapidJSON installed.
Try the rest description example. There is a hard coded path to oktal's swagger installation. If you replace that with your local swagger distribution, the example builds a banking API stub and serves an API json and a swagger doc page.
from pistache.
I had two issues with this codegen support:
-
The library name changed from Net to Pistache, so the generated code will not compile. This issue was already mentioned in 6278d88
-
The simple swagger example below generates code that will not compile. I don't see any errors/warning coming from codegen.
swagger: '2.0'
info:
version: "1.0"
title: Testing
definitions:
versionInfo:
type: object
properties:
timestamp:
type: string
paths:
/version:
get:
operationId: versionInfo
responses:
200:
description: OK
schema:
$ref: '#definitions/versionInfo'
The problem is the the generated code has an include of the form #include "#definitions/versionInfo.h"
. It should be #include "VersionInfo.h"
. Here's the commands I used after saving the above snippet as /tmp/tst.yml. Examine /tmp/swagger/DefaultApi.h to see the bad include.
sudo docker run -v /tmp:/tmp swaggerapi/swagger-codegen-cli generate -l pistache-server -o /tmp/swagger -i /tmp/tst.yml
[main] INFO io.swagger.parser.Swagger20Parser - reading from /tmp/tst.yml
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/model/VersionInfo.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/model/VersionInfo.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/api/DefaultApi.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/DefaultApiMainServer.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/api/DefaultApi.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/impl/DefaultApiImpl.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/impl/DefaultApiImpl.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/model/ModelBase.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/model/ModelBase.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/CMakeLists.txt
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/README.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/swagger/.swagger-codegen/VERSION
from pistache.
@jwmonaco you missed a /
in the $ref.
The right version is $ref: '#/definitions/versionInfo'
instead of $ref: '#definitions/versionInfo'
.
If you run swagger-codegen with this updated yaml file it works as expected.
Regarding the first issue, I have updated codegen with the new library name. I'll submit a PR soon.
from pistache.
D'oh. Thanks! Out of curiosity did you see that mistake by inspection or did you use a tool to validate the example? I thought it was OK since I didn't get any errors from code gen or editor saying my reference was bad. Seems like a tool should have pointed me towards my mistake.
from pistache.
@jwmonaco you're welcome :)
I didn't use any tool to validate it. Btw, the example you provided is compliant with the swagger syntax.
The $ref: '#definitions/versionInfo'
is still a valid path but it doesn't reference the versionInfo
object available under definitions
since the full path should start with the /
.
from pistache.
Hello all... I truing to get more info about the pistache description.
Is it generated the OAS specification based on the pistache endpoint?
Is it possible request the specification using the pistache endpoint? How should be the request?
Any information will be great!
from pistache.
Examine "examples/rest_description.cc"
In one terminal:
$ ./build/examples/run_rest_description 9999
Cores = 4
Using 2 threads
In other terminal:
$ curl -s http://localhost:9999/banker-api.json | head
{
"swagger": "2.0",
"info": {
"title": "Banking API",
"version": "0.1"
},
"basePath": "/v1",
"schemes": [
"http"
],
from pistache.
Related Issues (20)
- WriteEntry Constructor called with Incorrect Parameters in Transport::asyncWriteImpl
- [BUG] ResponseWriter::setCompression() chokes on identity encoding
- [BUG] Fails to fetch build dependencies in autopkgtest HOT 7
- [BUG] All PPA builds failing due to missing zlib headers
- [BUG] New compression code fails to build on armhf HOT 5
- decode uri
- Complete BSD support HOT 4
- "Stack smashing detected" error in ubuntu docker container HOT 17
- New release to conan HOT 1
- keep alive timeout doesn't add to response header
- Pistache very poor performance when POST size exceeds `Endpoint::options().maxRequestSize()`, and `maxRequestSize` is large. HOT 4
- Out of bound read in std::strtol while parsing HTTP requests HOT 4
- Endpoint::Options::backlog_ is not used HOT 2
- What's up with the logging? HOT 3
- [FEATURE REQUEST] Add support for zstd compression
- ci: coverage fails on debian:testing runners HOT 3
- Cant stream MJPEG with multipart/x-mixed-replace HOT 2
- releasing / tagging HOT 1
- Pistacheio support for QNX
- “stack smashing detected” error when processing Get requests via generated-cpp-pistache-server HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pistache.