示例#1
0
 async def test(self, content_negotiation: str):
     with open(path.join(path.dirname(__file__), 'test_openapi_assets', 'schema.json')) as f:
         schema = stdjson.load(f)
     with TemporaryDirectory() as output_directory_path:
         configuration = Configuration(
             output_directory_path, 'https://example.com')
         configuration.content_negotiation = content_negotiation
         async with Site(configuration) as site:
             specification = build_specification(site)
     jsonschema.validate(specification, schema)
示例#2
0
 async def test(self, content_negotiation: str):
     with open(
             Path(__file__).parent / 'test_openapi_assets' /
             'schema.json') as f:
         schema = stdjson.load(f)
     with TemporaryDirectory() as output_directory_path:
         configuration = Configuration(output_directory_path,
                                       'https://example.com')
         configuration.content_negotiation = content_negotiation
         async with App(configuration) as app:
             specification = build_specification(app)
     jsonschema.validate(specification, schema)
示例#3
0
def _generate_openapi(www_directory_path: str, site: Site) -> None:
    with open(join(www_directory_path, 'api', 'index.json'), 'w') as f:
        dump(build_specification(site), f)
示例#4
0
def _generate_openapi(www_directory_path: str, app: App) -> None:
    api_directory_path = join(www_directory_path, 'api')
    makedirs(api_directory_path)
    with open(join(api_directory_path, 'index.json'), 'w') as f:
        dump(build_specification(app), f)
示例#5
0
async def _generate_openapi(www_directory_path: Path, app: App) -> None:
    api_directory_path = www_directory_path / 'api'
    api_directory_path.mkdir(exist_ok=True, parents=True)
    rendered_json = json.dumps(build_specification(app))
    async with _create_json_resource(api_directory_path) as f:
        await f.write(rendered_json)