Commit 6d9349b3 authored by David Foucher's avatar David Foucher

Add (openapi): add template for automate openapi specs

parent 652f25a9
......@@ -6,3 +6,4 @@ requests==2.19.1
roll==0.9.1
ujson==1.35
unidecode==1.0.22
jinja2==2.10
......@@ -13,6 +13,8 @@ VERSION = (0, 7, 0)
__author__ = "Yohan Boniface"
__contact__ = "yohan.boniface@data.gouv.fr"
__maintainer__ = "David Foucher"
__maintainer_contact__ = "david.foucher@pole-emploi.fr"
__homepage__ = "https://framagit.org/ybon/trefle"
__version__ = ".".join(map(str, VERSION))
......@@ -24,6 +26,8 @@ setup(
url=__homepage__,
author=__author__,
author_email=__contact__,
maintainer=__maintainer__,
maintainer_email=__maintainer_contact__,
license="MIT",
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
......
......@@ -2,13 +2,15 @@ openapi: 3.0.0
info:
title: Api moteur de financement formation professionnelle
description: Obtenir la liste des financements possibles (coûts et rémunération) en fonction du profil du bénéficiaire et des caractéristiques de la formation.
version: 1.0.0
version: {{ version }}
contact:
email: david.foucher@pole-emploi.fr
email: {{ contact }}
servers:
- url: http://trefle.pole-emploi.fr
- url: http://trefle.pole-emploi.fr/
description: serveur de production
- url: http://trefle.beta.pole-emploi.fr
- url: http://trefle.pole-emploi.fr/api-moteur/{{ shortversion }}
description: serveur de production
- url: http://trefle.beta.pole-emploi.fr/api-moteur/{{ shortversion }}
description: serveur de recette
tags:
- name: financement
......
from jinja2 import Environment, DictLoader
from pathlib import Path
import yaml
from . import VERSION
def render_schema(openapitemplate):
env = Environment(loader=DictLoader({'openapi.yml': openapitemplate}))
template = env.get_template('openapi.yml')
return template.render(version=VERSION, shortversion=VERSION[:3],
contact='david.foucher@pole-emploi.fr')
with (Path(__file__).parent / "config/openapis.yml").open() as f:
OPENAPI = yaml.safe_load(f.read())
OPENAPI = yaml.safe_load(render_schema(f.read()))
with (Path(__file__).parent / "config/schema.yml").open() as f:
SCHEMA = yaml.safe_load(f.read())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment