* Added a wrapper for get_oas to throw spec info (#12) * Added tests generate_oas * Moved params to Application Co-authored-by: Спиненко Иван ispinenko@ussc.ru <ispinenko@ussc.ru>
This commit is contained in:
@@ -5,10 +5,16 @@ from aiohttp_pydantic.oas.struct import OpenApiSpec3
|
||||
|
||||
def test_info_title():
|
||||
oas = OpenApiSpec3()
|
||||
assert oas.info.title is None
|
||||
assert oas.info.title == "Aiohttp pydantic application"
|
||||
oas.info.title = "Info Title"
|
||||
assert oas.info.title == "Info Title"
|
||||
assert oas.spec == {"info": {"title": "Info Title"}, "openapi": "3.0.0"}
|
||||
assert oas.spec == {
|
||||
"info": {
|
||||
"title": "Info Title",
|
||||
"version": "1.0.0",
|
||||
},
|
||||
"openapi": "3.0.0",
|
||||
}
|
||||
|
||||
|
||||
def test_info_description():
|
||||
@@ -16,15 +22,22 @@ def test_info_description():
|
||||
assert oas.info.description is None
|
||||
oas.info.description = "info description"
|
||||
assert oas.info.description == "info description"
|
||||
assert oas.spec == {"info": {"description": "info description"}, "openapi": "3.0.0"}
|
||||
assert oas.spec == {
|
||||
"info": {
|
||||
"description": "info description",
|
||||
"title": "Aiohttp pydantic application",
|
||||
"version": "1.0.0",
|
||||
},
|
||||
"openapi": "3.0.0",
|
||||
}
|
||||
|
||||
|
||||
def test_info_version():
|
||||
oas = OpenApiSpec3()
|
||||
assert oas.info.version is None
|
||||
assert oas.info.version == "1.0.0"
|
||||
oas.info.version = "3.14"
|
||||
assert oas.info.version == "3.14"
|
||||
assert oas.spec == {"info": {"version": "3.14"}, "openapi": "3.0.0"}
|
||||
assert oas.spec == {"info": {"version": "3.14", "title": "Aiohttp pydantic application"}, "openapi": "3.0.0"}
|
||||
|
||||
|
||||
def test_info_terms_of_service():
|
||||
@@ -33,7 +46,11 @@ def test_info_terms_of_service():
|
||||
oas.info.terms_of_service = "http://example.com/terms/"
|
||||
assert oas.info.terms_of_service == "http://example.com/terms/"
|
||||
assert oas.spec == {
|
||||
"info": {"termsOfService": "http://example.com/terms/"},
|
||||
"info": {
|
||||
"title": "Aiohttp pydantic application",
|
||||
"version": "1.0.0",
|
||||
"termsOfService": "http://example.com/terms/",
|
||||
},
|
||||
"openapi": "3.0.0",
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ def test_paths_description():
|
||||
oas.paths["/users/{id}"].description = "This route ..."
|
||||
assert oas.spec == {
|
||||
"openapi": "3.0.0",
|
||||
"info": {"title": "Aiohttp pydantic application", "version": "1.0.0"},
|
||||
"paths": {"/users/{id}": {"description": "This route ..."}},
|
||||
}
|
||||
|
||||
@@ -13,7 +14,11 @@ def test_paths_description():
|
||||
def test_paths_get():
|
||||
oas = OpenApiSpec3()
|
||||
oas.paths["/users/{id}"].get
|
||||
assert oas.spec == {"openapi": "3.0.0", "paths": {"/users/{id}": {"get": {}}}}
|
||||
assert oas.spec == {
|
||||
"openapi": "3.0.0",
|
||||
"info": {"title": "Aiohttp pydantic application", "version": "1.0.0"},
|
||||
"paths": {"/users/{id}": {"get": {}}},
|
||||
}
|
||||
|
||||
|
||||
def test_paths_operation_description():
|
||||
@@ -22,6 +27,7 @@ def test_paths_operation_description():
|
||||
operation.description = "Long descriptions ..."
|
||||
assert oas.spec == {
|
||||
"openapi": "3.0.0",
|
||||
"info": {"title": "Aiohttp pydantic application", "version": "1.0.0"},
|
||||
"paths": {"/users/{id}": {"get": {"description": "Long descriptions ..."}}},
|
||||
}
|
||||
|
||||
@@ -32,6 +38,7 @@ def test_paths_operation_summary():
|
||||
operation.summary = "Updates a pet in the store with form data"
|
||||
assert oas.spec == {
|
||||
"openapi": "3.0.0",
|
||||
"info": {"title": "Aiohttp pydantic application", "version": "1.0.0"},
|
||||
"paths": {
|
||||
"/users/{id}": {
|
||||
"get": {"summary": "Updates a pet in the store with form data"}
|
||||
@@ -51,6 +58,7 @@ def test_paths_operation_parameters():
|
||||
|
||||
assert oas.spec == {
|
||||
"openapi": "3.0.0",
|
||||
"info": {"title": "Aiohttp pydantic application", "version": "1.0.0"},
|
||||
"paths": {
|
||||
"/users/{petId}": {
|
||||
"get": {
|
||||
@@ -86,6 +94,7 @@ def test_paths_operation_requestBody():
|
||||
request_body.required = True
|
||||
assert oas.spec == {
|
||||
"openapi": "3.0.0",
|
||||
"info": {"title": "Aiohttp pydantic application", "version": "1.0.0"},
|
||||
"paths": {
|
||||
"/users/{petId}": {
|
||||
"get": {
|
||||
|
||||
@@ -9,6 +9,7 @@ def test_sever_url():
|
||||
oas.servers[1].url = "https://development.gigantic-server.com/v2"
|
||||
assert oas.spec == {
|
||||
"openapi": "3.0.0",
|
||||
"info": {"title": "Aiohttp pydantic application", "version": "1.0.0"},
|
||||
"servers": [
|
||||
{"url": "https://development.gigantic-server.com/v1"},
|
||||
{"url": "https://development.gigantic-server.com/v2"},
|
||||
@@ -22,6 +23,7 @@ def test_sever_description():
|
||||
oas.servers[0].description = "Development server"
|
||||
assert oas.spec == {
|
||||
"openapi": "3.0.0",
|
||||
"info": {"title": "Aiohttp pydantic application", "version": "1.0.0"},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://development.gigantic-server.com/v1",
|
||||
|
||||
Reference in New Issue
Block a user