Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed May 11, 2020
1 parent 1dca9f5 commit 32d1be7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 58 deletions.
64 changes: 40 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
# swagger2x

## Description

swagger2x is a python tool that generate implementations based on templates from json files.
It uses the [jinja2](https://jinja.palletsprojects.com/en/2.11.x/) templates engine.


## Table of Contents

- [swagger2x](#swagger2x)
- [Description](#description)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Usage](#usage)
- [Templates](#templates)
- [Template directory structure](#template-directory-structure)
- [Available Templates](#available-templates)
- [IoTivity Lite Server](#iotivity-lite-server)
- [C++IotivityServer](#ciotivityserver)
- [PythonFlask](#pythonflask)
- [one-data-model](#one-data-model)
- [SDF2OAS](#sdf2oas)
- [Jinja2 template information](#jinja2-template-information)

## Installation
This tool is python3 based.

run ```src\install.py``` to install the dependencies.

This tool is python3 based.

Installation of the tool is creating a clone of the repository and
Installation of the tool is makin a clone of the repository and
use the tool relative of where the repository is located on your system.
To install the dependencies:

run ```pip3 install -U -r requirements.txt``` to install the dependencies.

## Usage

swagger2x is an command line tool.
To run the tool enter this on the (bash) command line:

```python3 swagger2x.py <options>```

use -h to see all the options.


__note: see/use [DeviceBuilder](https://openconnectivityfoundation.github.io/DeviceBuilder/) for usage of this tool in the development chain.__


To run the tooling on windows, install [git-bash](https://gitforwindows.org/).


# Templates
### Templates

The code generator is using jinja2 templates.
Using templates decouples the generated code from looping over the JSON hierarchy.
Expand All @@ -54,8 +70,8 @@ The code that can be generated should take into account:
Therefore a template is an mix of the library calls, the supported operating system in the used language mixed with the jinja2 template language to generate the code.
jinja2 takes the JSON swagger information and make it iteratable by looping over the end points, methods etc. and uses then the info to fill in the library/os calls in the used language.

#### Template directory structure

## Template directory structure
The templates can be found at [/src/templates](https://github.com/openconnectivityfoundation/swagger2x/tree/master/src/templates)
the following structure is defined:

Expand All @@ -68,51 +84,51 @@ the following structure is defined:
|--- <template file>.jinja2
|--- other files (will be copied to output)


New templates can be added by:

- adding a new folder
- adding file(s) with the jinja2 extension that contains the template.

#### Available Templates

## Available Templates
##### IoTivity Lite Server

### IoTivity Lite Server
- generates an C server for the IoTivity-Lite stack.
- [IoTivity](https://iotivity.org/)
- [more details on the template](/swagger2x/src/templates/IOTivity-lite)
- [folder](https://github.com/openconnectivityfoundation/swagger2x/tree/master/src/templates/IOTivity-lite)

##### C++IotivityServer

### C++IotivityServer
- generates an C++ server for the v1.3.1 IoTivity stack.
- [more details](https://github.com/openconnectivityfoundation/swagger2x/tree/master/src/templates/C%2B%2BIotivityServer)

##### PythonFlask

### PythonFlask
- generates an python Flask server.
- this is an HTTP server based on [FLASK](https://flask.palletsprojects.com/en/1.1.x/)
- generates a python Flask server.
- this is an HTTP server based on [FLASK](https://flask.palletsprojects.com/en/1.1.x/)
- __NO OCF implemenation__
- [more details on the template](/swagger2x/src/templates/PythonFlask)
- [folder](https://github.com/openconnectivityfoundation/swagger2x/tree/master/src/templates/PythonFlask)


### one-data-model
##### one-data-model

- generates schemas files for One Data Model in Simple Data Format (SDF) language.
- __NO OCF implemenation__
- [more details on the template](/swagger2x/src/templates/one-data-model)
- [folder](https://github.com/openconnectivityfoundation/swagger2x/tree/master/src/templates/one-data-model)
- [folder](https://github.com/openconnectivityfoundation/swagger2x/tree/master/src/templates/one-data-model)
- more details on [One Data Model SDF Format](https://github.com/one-data-model/language)

##### SDF2OAS

### SDF2OAS
- generates Open API Specification (2.0) files from SDF language (One Data Model).
- __NO OCF implemenation__
- [more details on the template](/swagger2x/src/templates/SDF2OAS)
- [folder](https://github.com/openconnectivityfoundation/swagger2x/tree/master/src/templates/SDF2OAS)
- [more details on the template](/swagger2x/src/templates/SDF2OAS)
- [folder](https://github.com/openconnectivityfoundation/swagger2x/tree/master/src/templates/SDF2OAS)
- more details on [One Data Model SDF Format](https://github.com/one-data-model/language)

### Jinja2 template information

## Jinja2 template information
The template contents is an mix of the target syntax and jinja2 commands.

Information on implemented commands can be found [here.](https://github.com/openconnectivityfoundation/swagger2x/blob/master/constructs.txt)
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

jinja2
34 changes: 0 additions & 34 deletions src/install.py

This file was deleted.

0 comments on commit 32d1be7

Please sign in to comment.