-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hans Klunder
committed
Apr 30, 2018
1 parent
95eaf36
commit ecb8af1
Showing
9 changed files
with
2,523 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Fastify swagger code generator | ||
|
||
This repository contains an experiment to see if its possible to take a swagger file (v2) and autogenerate a configuration for fastify. | ||
|
||
The result is quite simple: | ||
|
||
* [index.js](index.js) loads the swagger file feeds it to the [parser](parserv2.js) and uses the result to generate the routes. | ||
|
||
* The `definitions` section of the swagger specification is loaded in AJV to be able to resolve `$ref` schema references. AJV itself misses some format handlers so [ajv-oai](https://www.npmjs.com/package/ajv-oai) is being used as it adds the missing OpenApi formats. | ||
|
||
* For each route the parser has determined an `operationId`, either taken from the swagger definition or generated by the parser. | ||
|
||
* The `Service` class in [service.js](service.js) holds the implementation of the service (e.g. the business logic). When generating the routes the service is checked for methods with the same name as the `operationId` which are then attached as handler. When not available, a "not implemented" handler is attached to the route. | ||
|
||
* [generator.js](generator.js) can be used to generate the `Service` class. The generator can be extended to add information about parameters, information in comments etc. |
Oops, something went wrong.