#NEWLINE# def test_swagger_json_api_doc_route( testapp_with_base64 ) : #NEWLINE# #INDENT# expected_schema = { #NEWLINE# #INDENT# 'host' : 'localhost:9999' , #NEWLINE# 'info' : { #NEWLINE# #INDENT# 'title' : 'Title was not specified' , #NEWLINE# 'version' : '0.1' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'produces' : [ 'application/json' ] , #NEWLINE# 'schemes' : [ 'http' ] , #NEWLINE# 'swagger' : '2.0' , #NEWLINE# 'paths' : { #NEWLINE# #INDENT# '/sample/{path_arg}/resource' : { #NEWLINE# #INDENT# 'get' : { #NEWLINE# #INDENT# 'description' : '' , #NEWLINE# 'operationId' : 'standard' , #NEWLINE# 'parameters' : [ { #NEWLINE# #INDENT# 'enum' : [ 'path_arg1' , 'path_arg2' ] , #NEWLINE# 'in' : 'path' , #NEWLINE# 'name' : 'path_arg' , #NEWLINE# 'required' : True , #NEWLINE# 'type' : 'string' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'format' : 'base64' , #NEWLINE# 'in' : 'query' , #NEWLINE# 'name' : 'required_arg' , #NEWLINE# 'required' : True , #NEWLINE# 'type' : 'string' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'in' : 'query' , #NEWLINE# 'name' : 'optional_arg' , #NEWLINE# 'required' : False , #NEWLINE# 'type' : 'string' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'responses' : { #NEWLINE# #INDENT# '200' : { #NEWLINE# #INDENT# 'description' : 'Return a standard_response' , #NEWLINE# 'schema' : { #NEWLINE# #INDENT# 'additionalProperties' : False , #NEWLINE# 'properties' : { #NEWLINE# #INDENT# 'logging_info' : { #NEWLINE# #INDENT# 'type' : 'object' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'raw_response' : { #NEWLINE# #INDENT# 'type' : 'string' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'required' : [ 'raw_response' , 'logging_info' ] , #NEWLINE# 'type' : 'object' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'post' : { #NEWLINE# #INDENT# 'parameters' : [ { #NEWLINE# #INDENT# 'in' : 'path' , #NEWLINE# 'name' : 'path_arg' , #NEWLINE# 'required' : True , #NEWLINE# 'type' : 'string' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'in' : 'body' , #NEWLINE# 'name' : 'request' , #NEWLINE# 'required' : True , #NEWLINE# 'schema' : { #NEWLINE# #INDENT# 'additionalProperties' : False , #NEWLINE# 'properties' : { #NEWLINE# #INDENT# 'bar' : { #NEWLINE# #INDENT# 'type' : 'string' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'foo' : { #NEWLINE# #INDENT# 'type' : 'string' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'required' : [ 'foo' ] , #NEWLINE# 'type' : 'object' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'responses' : { #NEWLINE# #INDENT# 'default' : { #NEWLINE# #INDENT# 'description' : 'test response' , #NEWLINE# 'schema' : { #NEWLINE# #INDENT# 'additionalProperties' : False , #NEWLINE# 'properties' : { #NEWLINE# #INDENT# 'logging_info' : { #NEWLINE# #INDENT# 'type' : 'object' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'raw_response' : { #NEWLINE# #INDENT# 'type' : 'string' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'required' : [ 'raw_response' , 'logging_info' ] , #NEWLINE# 'type' : 'object' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# response = testapp_with_base64 . get ( '/swagger.json' ) #NEWLINE# assert ( response . status_code == 200 ) #NEWLINE# assert ( response . headers [ 'content-type' ] == 'application/json; charset=UTF-8' ) #NEWLINE# import json #NEWLINE# assert ( json . loads ( response . body . decode ( 'utf-8' ) ) == expected_schema ) #NEWLINE# response = testapp_with_base64 . get ( '/swagger.yaml' ) #NEWLINE# assert ( response . status_code == 200 ) #NEWLINE# assert ( response . headers [ 'content-type' ] == 'application/x-yaml; charset=UTF-8' ) #NEWLINE# import yaml #NEWLINE# assert ( yaml . load ( response . body ) == expected_schema )