Comments (8)
This is must for making using for Restful documentation and lamba services need quick documentation
from rapidoid.
This would be a really cool feature to add
I imagine you are really busy.
I would be open to contribute this PR following your guidelines/suggestions on how to tackle this.
from rapidoid.
Hi @picaron, that sounds great! Thanks for taking initiative on this.
For easy illustration of the requirements, let's start with the following example:
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: An paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
(source: https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml)
For the info
and servers
sections we could introduce a new configuration section openapi
.
Of course, the paths
section will be more challenging. The paths can be automatically generated from the routes, but some information is missing: summary
, description
, tags
, operationId
, parameters
(partially) etc.
As a first step I propose a simple bootstrap of OpenAPI from the information already available in the routes (e.g. generating basic paths
from Rapidoid's routes (the parameters
and responses
will be missing, until we find a proper way of modelling them). Some suggestions:
- the OpenAPI / Swagger integration should ideally be implemented in a separate module
rapidoid-openapi
, similar to how it's done for theOAuth
support, - for the bootstrap:
App.bootstrap(args).openapi()
, - basic configuration:
openapi
section (with correspondingConf.OPENAPI
) - useful for theinfo
andservers
elements of the spec.
I will try to find a proper way to model the parameters and responses...
Any feedback, questions and suggestions are welcome! :) Thanks again for helping with this one!
from rapidoid.
Any (fastest) library that does something like https://marshmallow.readthedocs.io and can be connected to both swagger/rapidoid/routes so it validates request/response and also builds the api-specification. Like you can integrate python(flask+marshmallow+webargs+swagger+apispec).
In this case I think only the routes would be from rapidoid and the other stuff from external modules (no need to reinvent request parsing + validation?).
Make sense ?
from rapidoid.
Hi @nmihajlovski,
How to get paths, methods and parameters?
Thanks
from rapidoid.
@danielbraga Thanks for the PR! I merged it into a new branch: openapi
.
The routes can be accessed using On.setup().routes().allNonAdmin()
.
The tricky part would be accessing the parameters. I am going to add support for a generic (JSON-style) "schema" property that can be configured per route.
from rapidoid.
@danielbraga @picaron FYI:
- I added meta-data model for the routes (
RouteMeta
), - I removed the template-based YAML generation (@danielbraga sorry for that). Instead, I implemented dynamic docs construction from
RouteMeta
into Java collections, which are then rendered as JSON or YAML.
Also, I merged the openapi
branch into master
. This is still work in progress, but the next release of Rapidoid will have early-access/experimental OpenAPI support.
Open issues:
- smart construction of request/response data schema from Java types,
- support for response headers.
from rapidoid.
Any possibility to actually make swagger the route definition holder? A DRY top down approach would ideally declare all of the below in swagger and only in swagger:
- Route definitions with references to endpoint executable code
- Validation of request payload against defined schema
- Validation of response payload [optional for those that favor response time over spec-conformity]
from rapidoid.
Related Issues (20)
- soapMessage.WriteTo
- Metrics takes too much memory by default
- Is it possible to change http.timeout per route or per request? HOT 2
- Using session() in org.rapidoid:rapidoid-http-server:5.5.5
- Enabling CORS on a view with no access to Resp
- How to start a new Web Server Instance with Rapidoid ?
- running Rapidoid from JUnit - exception when handling async response
- How to start only JPA?
- Allow configuring Controller's routes.
- Allow declaring a common root for routes. HOT 1
- New release for updated dependencies? HOT 1
- Please Support HTTP/2 Server Push
- More setup details are required for https HOT 1
- On.page().mvc() error HOT 1
- Add additional documentation and examples for HTML rendering HOT 1
- Video/Media Upgrade
- Dependency org.hibernate:hibernate-core, leading to CVE problem HOT 1
- Why no longer fastest in the world?
- Plz fix bug for java 11
- set configuration https with tcpnodelay error
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 rapidoid.