Increase OAS description

Parce docstring of http handlers to increase OAS
Remove the not expected definitions key in the OAS
This commit is contained in:
Vincent Maillol
2020-12-20 11:05:24 +01:00
parent 25fcac18ec
commit 070d7e7259
12 changed files with 470 additions and 116 deletions

View File

@@ -0,0 +1 @@
{"info": {"title": "MyApp", "version": "1.0.0"}}

View File

@@ -1,10 +1,13 @@
import argparse
from textwrap import dedent
from io import StringIO
from pathlib import Path
import pytest
from aiohttp_pydantic.oas import cmd
PATH_TO_BASE_JSON_FILE = str(Path(__file__).parent / "oas_base.json")
@pytest.fixture
def cmd_line():
@@ -13,10 +16,11 @@ def cmd_line():
return parser
def test_show_oad_of_app(cmd_line, capfd):
def test_show_oas_of_app(cmd_line):
args = cmd_line.parse_args(["tests.test_oas.test_cmd.sample"])
args.output = StringIO()
args.func(args)
captured = capfd.readouterr()
expected = dedent(
"""
{
@@ -57,13 +61,13 @@ def test_show_oad_of_app(cmd_line, capfd):
"""
)
assert captured.out.strip() == expected.strip()
assert args.output.getvalue().strip() == expected.strip()
def test_show_oad_of_sub_app(cmd_line, capfd):
def test_show_oas_of_sub_app(cmd_line):
args = cmd_line.parse_args(["tests.test_oas.test_cmd.sample:sub_app"])
args.output = StringIO()
args.func(args)
captured = capfd.readouterr()
expected = dedent(
"""
{
@@ -89,16 +93,26 @@ def test_show_oad_of_sub_app(cmd_line, capfd):
"""
)
assert captured.out.strip() == expected.strip()
assert args.output.getvalue().strip() == expected.strip()
def test_show_oad_of_a_callable(cmd_line, capfd):
args = cmd_line.parse_args(["tests.test_oas.test_cmd.sample:make_app()"])
def test_show_oas_of_a_callable(cmd_line):
args = cmd_line.parse_args(
[
"tests.test_oas.test_cmd.sample:make_app()",
"--base-oas-file",
PATH_TO_BASE_JSON_FILE,
]
)
args.output = StringIO()
args.func(args)
captured = capfd.readouterr()
expected = dedent(
"""
{
"info": {
"title": "MyApp",
"version": "1.0.0"
},
"openapi": "3.0.0",
"paths": {
"/route-3/{a}": {
@@ -121,4 +135,4 @@ def test_show_oad_of_a_callable(cmd_line, capfd):
"""
)
assert captured.out.strip() == expected.strip()
assert args.output.getvalue().strip() == expected.strip()