repo_id stringclasses 400
values | commit_sha stringclasses 400
values | commit_index int32 0 951 | in_repo_split stringclasses 1
value | cross_repo_split stringclasses 1
value | test_file stringlengths 7 121 | test_function stringlengths 1 108 | assertion_type stringclasses 32
values | difficulty stringclasses 8
values | context_lines int32 3 600 | prefix large_stringlengths 44 113k | target large_stringlengths 1 498 | anchor_sha stringclasses 400
values | anchor_index int32 0 951 | qna_source stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_tags.py | test_path_tags_with_blueprint_tag | assert | collection | 20 | import pytest
from openapi_spec_validator import validate_spec
from apiflask import APIBlueprint
@pytest.mark.parametrize('tag', ['test', {'name': 'test'}])
def test_path_tags_with_blueprint_tag(app, client, tag):
bp = APIBlueprint('foo', __name__, tag=tag)
@bp.get('/')
def foo():
pass
app.r... | ['test'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_tags.py | test_path_tags_with_nesting_blueprints | assert | collection | 26 | import pytest
from openapi_spec_validator import validate_spec
from apiflask import APIBlueprint
def test_path_tags_with_nesting_blueprints(app, client):
parent_bp = APIBlueprint('parent', __name__, url_prefix='/parent')
child_bp = APIBlueprint('child', __name__, url_prefix='/child')
@parent_bp.get('/')... | ['Parent'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_commands.py | test_flask_spec_fields_order | assert | collection | 18 | import json
import pytest
from .schemas import Foo
from apiflask.commands import spec_command
def test_flask_spec_fields_order(app, cli_runner):
@app.get('/foo')
@app.output(Foo)
def foo():
pass
result = cli_runner.invoke(spec_command)
assert 'openapi' in result.output
assert json.lo... | ['id', 'name'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_fields.py | test_multiple_file_field | assert | collection | 31 | import io
from werkzeug.datastructures import FileStorage
from .schemas import Files
from .schemas import FilesList
def test_multiple_file_field(app, client):
@app.post('/')
@app.input(FilesList, location='files')
def index(files_data):
data = {'images': True}
for f in files_data['images'... | {'images': True} | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_fields.py | test_multiple_file_field | assert | collection | 45 | import io
from werkzeug.datastructures import FileStorage
from .schemas import Files
from .schemas import FilesList
def test_multiple_file_field(app, client):
@app.post('/')
@app.input(FilesList, location='files')
def index(files_data):
data = {'images': True}
for f in files_data['images'... | ['Not a valid file.'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_security.py | test_httpbasicauth_security_scheme | assert | collection | 20 | import pytest
from openapi_spec_validator import validate_spec
from apiflask import HTTPBasicAuth
from apiflask import HTTPTokenAuth
def test_httpbasicauth_security_scheme(app, client):
auth = HTTPBasicAuth()
@app.get('/')
@app.auth_required(auth)
def foo():
pass
rv = client.get('/openap... | { 'type': 'http', 'scheme': 'basic' } | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_async.py | test_input_on_async_view | assert | variable | 17 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import HTTPTokenAuth
def test_input_on_async_view(app, client):
@app.post('/')
@app.input(Foo)
async def index(json_data):
return json_data
data = {'id': 1, 'name': 'foo'}
rv = client.post('/', json=d... | data | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_basic.py | test_get_spec | assert | variable | 23 | import json
import pytest
from flask import request
from openapi_spec_validator import validate_spec
from .schemas import Bar
from .schemas import Baz
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import Schema
from apiflask.commands import spec_command
from apiflask.fields import Integer
... | spec | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_openapi_fields | assert | variable | 55 | from openapi_spec_validator import validate_spec
def test_openapi_fields(app, client):
openapi_version = '3.0.2'
description = 'My API'
tags = [
{
'name': 'foo',
'description': 'some description for foo',
'externalDocs': {
'description': 'Find mor... | tags | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_blueprint.py | test_openapi_blueprint_url_prefix | assert | variable | 11 | import pytest
from apiflask import APIFlask
def test_openapi_blueprint_url_prefix(app):
assert app.openapi_blueprint_url_prefix is None
prefix = '/api'
app = APIFlask(__name__, openapi_blueprint_url_prefix=prefix)
assert app.openapi_blueprint_url_prefix == | prefix | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_route.py | test_route_shortcuts | assert | variable | 21 | import pytest
from flask.views import MethodView
from flask.views import View
from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import HTTPTokenAuth
@pytest.mark.parametrize('method', ['get', 'post', 'put', 'patch', 'delete'])
def test_route_shor... | method | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_async.py | test_async_doc_input_and_output_decorator | assert | variable | 19 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import HTTPTokenAuth
def test_async_doc_input_and_output_decorator(app, client):
@app.post('/')
@app.doc(summary='Test Root Endpoint')
@app.input(Foo)
@app.output(Foo)
async def index(json_data):
retur... | payload | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_schemas.py | test_file_schema | assert | variable | 21 | import pytest
from openapi_spec_validator import validate_spec
from apiflask.schemas import EmptySchema
from apiflask.schemas import FileSchema
def test_file_schema(app, client):
@app.get('/image')
@app.output(
FileSchema(type='string', format='binary'),
content_type='image/png',
descr... | content | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_openapi_fields | assert | variable | 56 | from openapi_spec_validator import validate_spec
def test_openapi_fields(app, client):
openapi_version = '3.0.2'
description = 'My API'
tags = [
{
'name': 'foo',
'description': 'some description for foo',
'externalDocs': {
'description': 'Find mor... | servers | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_openapi_fields | assert | variable | 59 | from openapi_spec_validator import validate_spec
def test_openapi_fields(app, client):
openapi_version = '3.0.2'
description = 'My API'
tags = [
{
'name': 'foo',
'description': 'some description for foo',
'externalDocs': {
'description': 'Find mor... | contact | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_openapi_fields | assert | variable | 60 | from openapi_spec_validator import validate_spec
def test_openapi_fields(app, client):
openapi_version = '3.0.2'
description = 'My API'
tags = [
{
'name': 'foo',
'description': 'some description for foo',
'externalDocs': {
'description': 'Find mor... | license | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_base_response.py | test_base_response_spec | pytest.raises | variable | 32 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import Schema
from apiflask.fields import Field
from apiflask.fields import Integer
from apiflask.fields import String
@pytest.mark.parametrize(
'base_schema',
[
BaseResponse,
base_response_sc... | TypeError) | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_base_response.py | test_base_response_spec | assert | variable | 51 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import Schema
from apiflask.fields import Field
from apiflask.fields import Integer
from apiflask.fields import String
@pytest.mark.parametrize(
'base_schema',
[
BaseResponse,
base_response_sc... | schema_ref | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_security.py | test_unknown_auth_security_scheme | pytest.raises | variable | 17 | import pytest
from openapi_spec_validator import validate_spec
from apiflask import HTTPBasicAuth
from apiflask import HTTPTokenAuth
def test_unknown_auth_security_scheme(app):
from flask_httpauth import HTTPDigestAuth
auth = HTTPDigestAuth()
@app.get('/')
@app.auth_required(auth)
def foo():
... | TypeError) | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_response_customization.py | test_validation_error_schema_bad_type | pytest.raises | variable | 20 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import HTTPError
from .schemas import ValidationError
from apiflask.schemas import EmptySchema
from apiflask.schemas import http_error_schema
from apiflask.security import HTTPBasicAuth
def test_validation_error_sche... | TypeError) | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_exceptions.py | test_invalid_error_status_code | pytest.raises | variable | 8 | import pytest
from apiflask.exceptions import abort
from apiflask.exceptions import HTTPError
def test_invalid_error_status_code():
with pytest.raises( | LookupError) | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_paths.py | test_path_arguments_order | assert | string_literal | 28 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Header
from .schemas import Pagination
from .schemas import Query
def test_path_arguments_order(app, client):
@app.route('/<foo>/bar')
@app.input(Query, location='query')
@app.output(Foo)
def path_and_query(... | 'id' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_async.py | test_output_on_async_view | assert | string_literal | 17 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import HTTPTokenAuth
def test_output_on_async_view(app, client):
@app.get('/foo')
@app.output(Foo)
async def foo():
return {'id': 1, 'name': 'foo'}
rv = client.get('/foo')
assert rv.status_code == 200... | 'foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_blueprint.py | test_blueprint_tag | assert | string_literal | 12 | from flask.views import MethodView
from openapi_spec_validator import validate_spec
from apiflask import APIBlueprint
from apiflask.security import HTTPBasicAuth
from apiflask.security import HTTPTokenAuth
def test_blueprint_tag():
bp = APIBlueprint('test', __name__, tag='foo')
assert bp.name == 'test'
a... | 'foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_decorator_doc.py | test_doc_responses | assert | string_literal | 32 | import pytest
from flask.views import MethodView
from openapi_spec_validator import validate_spec
from .schemas import CustomHTTPError
from .schemas import Foo
def test_doc_responses(app, client):
@app.route('/foo')
@app.input(Foo)
@app.output(Foo)
@app.doc(responses={200: 'success', 400: 'bad', 404: ... | 'bad' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_exceptions.py | test_httperror | assert | string_literal | 27 | import pytest
from apiflask.exceptions import abort
from apiflask.exceptions import HTTPError
@pytest.mark.parametrize('kwargs', [
{},
{'message': 'bad'},
{'message': 'bad', 'detail': {'location': 'json'}},
{'message': 'bad', 'detail': {'location': 'json'}, 'headers': {'X-FOO': 'bar'}}
])
def test_htt... | 'bad' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_exceptions.py | test_abort | assert | string_literal | 30 | import pytest
from apiflask.exceptions import abort
from apiflask.exceptions import HTTPError
@pytest.mark.parametrize('kwargs', [
{},
{'message': 'missing'},
{'message': 'missing', 'detail': {'location': 'query'}},
{'message': 'missing', 'detail': {'location': 'query'}, 'headers': {'X-BAR': 'foo'}},
... | 'foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_exceptions.py | test_default_error_handler | assert | string_literal | 26 | import pytest
from apiflask.exceptions import abort
from apiflask.exceptions import HTTPError
@pytest.mark.parametrize('kwargs', [
{},
{'message': 'bad'},
{'message': 'bad', 'detail': {'location': 'json'}},
{'message': 'bad', 'detail': {'location': 'json'}, 'headers': {'X-FOO': 'bar'}}
])
def test_def... | 'bar' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_exceptions.py | test_custom_error_classes | assert | string_literal | 36 | import pytest
from apiflask.exceptions import abort
from apiflask.exceptions import HTTPError
def test_custom_error_classes(app, client):
class PetDown(HTTPError):
status_code = 400
message = 'The pet is down.'
extra_data = {
'error_code': '123',
'error_docs': 'http... | '123' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_basic.py | test_spec_processor | assert | string_literal | 30 | import json
import pytest
from flask import request
from openapi_spec_validator import validate_spec
from .schemas import Bar
from .schemas import Baz
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import Schema
from apiflask.commands import spec_command
from apiflask.fields import Integer
... | 'Foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_info.py | test_info_title_and_version | assert | string_literal | 11 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
def test_info_title_and_version(app):
assert app.title == 'APIFlask'
assert app.version == '0.1.0'
app = APIFlask(__name__, title='Foo', version='1.0')
assert app.spec['info']['title'] == | 'Foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_info.py | test_info_title_and_version | assert | string_literal | 12 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
def test_info_title_and_version(app):
assert app.title == 'APIFlask'
assert app.version == '0.1.0'
app = APIFlask(__name__, title='Foo', version='1.0')
assert app.spec['info']['title'] == 'Foo'
assert app.spec['info']... | '1.0' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_paths.py | test_path_arguments_order | assert | string_literal | 26 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Header
from .schemas import Pagination
from .schemas import Query
def test_path_arguments_order(app, client):
@app.route('/<foo>/bar')
@app.input(Query, location='query')
@app.output(Foo)
def path_and_query(... | 'foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_paths.py | test_path_arguments_order | assert | string_literal | 32 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Header
from .schemas import Pagination
from .schemas import Query
def test_path_arguments_order(app, client):
@app.route('/<foo>/bar')
@app.input(Query, location='query')
@app.output(Foo)
def path_and_query(... | 'bar' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_tags.py | test_tags | assert | string_literal | 26 | import pytest
from openapi_spec_validator import validate_spec
from apiflask import APIBlueprint
def test_tags(app, client):
assert app.tags is None
app.tags = [
{
'name': 'foo',
'description': 'some description for foo',
'externalDocs': {
'descripti... | 'foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_auto_behaviour.py | test_auto_path_summary | assert | string_literal | 49 | import pytest
from flask.views import MethodView
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Query
from apiflask import APIBlueprint
from apiflask.security import HTTPBasicAuth
@pytest.mark.parametrize('config_value', [True, False])
def test_auto_path_summary(app, cl... | 'Foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_response_customization.py | test_validation_error_status_code_and_description | assert | string_literal | 25 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import HTTPError
from .schemas import ValidationError
from apiflask.schemas import EmptySchema
from apiflask.schemas import http_error_schema
from apiflask.security import HTTPBasicAuth
def test_validation_error_stat... | 'Bad' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_async.py | test_async_error_processor | assert | string_literal | 15 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import HTTPTokenAuth
def test_async_error_processor(app, client):
@app.error_processor
async def custom_error_processor(e):
return {'foo': 'test'}, e.status_code, e.headers
rv = client.get('/foo')
assert ... | 'test' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_base_response.py | test_output_base_response | assert | string_literal | 27 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import Schema
from apiflask.fields import Field
from apiflask.fields import Integer
from apiflask.fields import String
def test_output_base_response(app, client):
app.config['BASE_RESPONSE_SCHEMA'] = BaseResponse... | 'test' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_blueprint.py | test_blueprint_object | assert | string_literal | 11 | from flask.views import MethodView
from openapi_spec_validator import validate_spec
from apiflask import APIBlueprint
from apiflask.security import HTTPBasicAuth
from apiflask.security import HTTPTokenAuth
def test_blueprint_object():
bp = APIBlueprint('test', __name__)
assert bp.name == | 'test' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_paths.py | test_spec_path_parameters_registration | assert | string_literal | 33 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Header
from .schemas import Pagination
from .schemas import Query
def test_spec_path_parameters_registration(app, client):
@app.route('/strings/<some_string>')
@app.output(Foo)
def get_string(some_string):
... | 'path' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_route.py | test_route_on_method_view | assert | string_literal | 30 | import pytest
from flask.views import MethodView
from flask.views import View
from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import HTTPTokenAuth
def test_route_on_method_view(app, client):
@app.route('/')
class Foo(MethodView):
... | b'get' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_route.py | test_route_on_method_view | assert | string_literal | 36 | import pytest
from flask.views import MethodView
from flask.views import View
from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import HTTPTokenAuth
def test_route_on_method_view(app, client):
@app.route('/')
class Foo(MethodView):
... | b'put' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_async.py | test_async_view | assert | string_literal | 15 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import HTTPTokenAuth
def test_async_view(app, client):
@app.get('/')
async def index():
return {'message': 'hello'}
rv = client.get('/')
assert rv.status_code == 200
assert rv.json['message'] == | 'hello' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_decorator_doc.py | test_doc_responses_custom_spec | assert | string_literal | 80 | import pytest
from flask.views import MethodView
from openapi_spec_validator import validate_spec
from .schemas import CustomHTTPError
from .schemas import Foo
def test_doc_responses_custom_spec(app, client):
response_spec = {
'description': 'Success',
'content': {
'application/json': ... | 'Error' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_basic.py | test_spec_processor | assert | string_literal | 29 | import json
import pytest
from flask import request
from openapi_spec_validator import validate_spec
from .schemas import Bar
from .schemas import Baz
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import Schema
from apiflask.commands import spec_command
from apiflask.fields import Integer
... | '3.0.2' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_basic.py | test_auto_200_response | assert | string_literal | 49 | import json
import pytest
from flask import request
from openapi_spec_validator import validate_spec
from .schemas import Bar
from .schemas import Baz
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import Schema
from apiflask.commands import spec_command
from apiflask.fields import Integer
... | 'empty' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_basic.py | edit_spec | assert | string_literal | 18 | import json
import pytest
from flask import request
from openapi_spec_validator import validate_spec
from .schemas import Bar
from .schemas import Baz
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import Schema
from apiflask.commands import spec_command
from apiflask.fields import Integer
... | '3.0.3' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_info.py | test_info_title_and_version | assert | string_literal | 8 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
def test_info_title_and_version(app):
assert app.title == 'APIFlask'
assert app.version == | '0.1.0' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_route.py | test_route_on_method_view | assert | string_literal | 32 | import pytest
from flask.views import MethodView
from flask.views import View
from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import HTTPTokenAuth
def test_route_on_method_view(app, client):
@app.route('/')
class Foo(MethodView):
... | b'post' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_fields.py | test_file_field | assert | string_literal | 21 | import io
from werkzeug.datastructures import FileStorage
from .schemas import Files
from .schemas import FilesList
def test_file_field(app, client):
@app.post('/')
@app.input(Files, location='files')
def index(files_data):
data = {}
if 'image' in files_data and isinstance(files_data['ima... | 'string' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_fields.py | test_file_field | assert | string_literal | 22 | import io
from werkzeug.datastructures import FileStorage
from .schemas import Files
from .schemas import FilesList
def test_file_field(app, client):
@app.post('/')
@app.input(Files, location='files')
def index(files_data):
data = {}
if 'image' in files_data and isinstance(files_data['ima... | 'binary' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_paths.py | test_spec_path_parameters_registration | assert | string_literal | 37 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Header
from .schemas import Pagination
from .schemas import Query
def test_spec_path_parameters_registration(app, client):
@app.route('/strings/<some_string>')
@app.output(Foo)
def get_string(some_string):
... | 'string' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_decorator_doc.py | test_doc_responses | assert | string_literal | 30 | import pytest
from flask.views import MethodView
from openapi_spec_validator import validate_spec
from .schemas import CustomHTTPError
from .schemas import Foo
def test_doc_responses(app, client):
@app.route('/foo')
@app.input(Foo)
@app.output(Foo)
@app.doc(responses={200: 'success', 400: 'bad', 404: ... | 'success' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_decorator_doc.py | test_doc_responses_custom_spec | assert | string_literal | 78 | import pytest
from flask.views import MethodView
from openapi_spec_validator import validate_spec
from .schemas import CustomHTTPError
from .schemas import Foo
def test_doc_responses_custom_spec(app, client):
response_spec = {
'description': 'Success',
'content': {
'application/json': ... | 'Success' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_exceptions.py | test_abort | assert | string_literal | 24 | import pytest
from apiflask.exceptions import abort
from apiflask.exceptions import HTTPError
@pytest.mark.parametrize('kwargs', [
{},
{'message': 'missing'},
{'message': 'missing', 'detail': {'location': 'query'}},
{'message': 'missing', 'detail': {'location': 'query'}, 'headers': {'X-BAR': 'foo'}},
... | 'missing' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_helpers.py | test_get_reason_phrase_default | assert | string_literal | 10 | import pytest
from apiflask import get_reason_phrase
from apiflask import pagination_builder
from apiflask import PaginationSchema
def test_get_reason_phrase_default():
rv = get_reason_phrase(1234)
assert rv == | 'Unknown' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_auto_behaviour.py | test_auto_path_summary | assert | string_literal | 50 | import pytest
from flask.views import MethodView
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Query
from apiflask import APIBlueprint
from apiflask.security import HTTPBasicAuth
@pytest.mark.parametrize('config_value', [True, False])
def test_auto_path_summary(app, cl... | 'Get Bar' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_auto_behaviour.py | test_auto_path_summary_with_methodview | assert | string_literal | 43 | import pytest
from flask.views import MethodView
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Query
from apiflask import APIBlueprint
from apiflask.security import HTTPBasicAuth
@pytest.mark.parametrize('config_value', [True, False])
def test_auto_path_summary_with_me... | 'Get Foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_auto_behaviour.py | test_auto_operationid | assert | string_literal | 37 | import pytest
from flask.views import MethodView
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import Query
from apiflask import APIBlueprint
from apiflask.security import HTTPBasicAuth
@pytest.mark.parametrize('config_value', [True, False])
def test_auto_operationid(app, cli... | 'get_foo' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_response_customization.py | test_response_description_config | assert | string_literal | 43 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import HTTPError
from .schemas import ValidationError
from apiflask.schemas import EmptySchema
from apiflask.schemas import http_error_schema
from apiflask.security import HTTPBasicAuth
def test_response_description_... | 'Success' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_basic.py | edit_spec | assert | string_literal | 20 | import json
import pytest
from flask import request
from openapi_spec_validator import validate_spec
from .schemas import Bar
from .schemas import Baz
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import Schema
from apiflask.commands import spec_command
from apiflask.fields import Integer
... | 'APIFlask' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_info.py | test_info_title_and_version | assert | string_literal | 7 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
def test_info_title_and_version(app):
assert app.title == | 'APIFlask' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_helpers.py | test_get_reason_phrase | assert | string_literal | 16 | import pytest
from apiflask import get_reason_phrase
from apiflask import pagination_builder
from apiflask import PaginationSchema
@pytest.mark.parametrize('code', [204, 400, 404, 456, 4123])
def test_get_reason_phrase(code):
rv = get_reason_phrase(code)
if code == 204:
assert rv == 'No Content'
e... | 'Not Found' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_helpers.py | test_get_reason_phrase | assert | string_literal | 12 | import pytest
from apiflask import get_reason_phrase
from apiflask import pagination_builder
from apiflask import PaginationSchema
@pytest.mark.parametrize('code', [204, 400, 404, 456, 4123])
def test_get_reason_phrase(code):
rv = get_reason_phrase(code)
if code == 204:
assert rv == | 'No Content' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_helpers.py | test_get_reason_phrase | assert | string_literal | 14 | import pytest
from apiflask import get_reason_phrase
from apiflask import pagination_builder
from apiflask import PaginationSchema
@pytest.mark.parametrize('code', [204, 400, 404, 456, 4123])
def test_get_reason_phrase(code):
rv = get_reason_phrase(code)
if code == 204:
assert rv == 'No Content'
e... | 'Bad Request' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_security.py | test_default_auth_error_handler | assert | string_literal | 20 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
from apiflask.security import HTTPBasicAuth
from apiflask.security import HTTPTokenAuth
def test_default_auth_error_handler(app, client):
auth = HTTPTokenAuth()
@app.route('/foo')
@app.auth_required(auth)
def foo():
... | 'Unauthorized' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_async.py | test_async_spec_processor | assert | string_literal | 17 | from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import HTTPTokenAuth
def test_async_spec_processor(app, client):
@app.spec_processor
async def update_spec(spec):
spec['info']['title'] = 'Updated Title'
return spec
rv = client.get('/openapi.json')
... | 'Updated Title' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_helpers.py | test_get_reason_phrase_default | assert | string_literal | 13 | import pytest
from apiflask import get_reason_phrase
from apiflask import pagination_builder
from apiflask import PaginationSchema
def test_get_reason_phrase_default():
rv = get_reason_phrase(1234)
assert rv == 'Unknown'
rv = get_reason_phrase(1234, 'Unknown error')
assert rv == | 'Unknown error' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_spec.py | test_yaml_spec_mimetype | assert | string_literal | 16 | import json
import pytest
from apiflask import APIFlask
from apiflask.commands import spec_command
def test_yaml_spec_mimetype():
app = APIFlask(__name__, spec_path='/openapi.yaml')
app.config['SPEC_FORMAT'] = 'yaml'
client = app.test_client()
rv = client.get('/openapi.yaml')
assert rv.status_co... | 'text/vnd.yaml' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_spec.py | test_json_spec_mimetype | assert | string_literal | 12 | import json
import pytest
from apiflask import APIFlask
from apiflask.commands import spec_command
def test_json_spec_mimetype(app, client):
rv = client.get('/openapi.json')
assert rv.status_code == 200
assert rv.mimetype == | 'application/json' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_spec.py | test_yaml_spec_mimetype | assert | string_literal | 22 | import json
import pytest
from apiflask import APIFlask
from apiflask.commands import spec_command
def test_yaml_spec_mimetype():
app = APIFlask(__name__, spec_path='/openapi.yaml')
app.config['SPEC_FORMAT'] = 'yaml'
client = app.test_client()
rv = client.get('/openapi.yaml')
assert rv.status_co... | 'text/custom.yaml' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_response_customization.py | test_validation_error_schema | assert | string_literal | 28 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import HTTPError
from .schemas import ValidationError
from apiflask.schemas import EmptySchema
from apiflask.schemas import http_error_schema
from apiflask.security import HTTPBasicAuth
@pytest.mark.parametrize('sche... | 'Validation error' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_spec.py | test_json_spec_mimetype | assert | string_literal | 18 | import json
import pytest
from apiflask import APIFlask
from apiflask.commands import spec_command
def test_json_spec_mimetype(app, client):
rv = client.get('/openapi.json')
assert rv.status_code == 200
assert rv.mimetype == 'application/json'
app.config['JSON_SPEC_MIMETYPE'] = 'application/custom.j... | 'application/custom.json' | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_base_response.py | test_output_base_response | assert | complex_expr | 23 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from apiflask import Schema
from apiflask.fields import Field
from apiflask.fields import Integer
from apiflask.fields import String
def test_output_base_response(app, client):
app.config['BASE_RESPONSE_SCHEMA'] = BaseResponse... | rv.json | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_helpers.py | test_pagination_builder | assert | complex_expr | 35 | import pytest
from apiflask import get_reason_phrase
from apiflask import pagination_builder
from apiflask import PaginationSchema
def test_pagination_builder(app, client):
class Pagination:
page = 1
per_page = 20
pages = 100
total = 2000
next_num = 2
has_next = Tru... | rv.json | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_security.py | test_default_auth_error_handler | assert | complex_expr | 19 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
from apiflask.security import HTTPBasicAuth
from apiflask.security import HTTPTokenAuth
def test_default_auth_error_handler(app, client):
auth = HTTPTokenAuth()
@app.route('/foo')
@app.auth_required(auth)
def foo():
... | rv.json | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_security.py | test_bypass_default_auth_error_handler | assert | complex_expr | 20 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
from apiflask.security import HTTPBasicAuth
from apiflask.security import HTTPTokenAuth
def test_bypass_default_auth_error_handler():
app = APIFlask(__name__, json_errors=False)
auth = HTTPTokenAuth()
@app.route('/foo')
@a... | rv.data | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_api_docs.py | test_docs_favicon | assert | complex_expr | 11 | import pytest
from apiflask import APIFlask
def test_docs_favicon(app, client):
app.config['DOCS_FAVICON'] = '/my-favicon.png'
rv = client.get('/docs')
assert rv.status_code == 200
assert b'href="/my-favicon.png"' in | rv.data | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_spec.py | test_spec_format | assert | complex_expr | 18 | import json
import pytest
from apiflask import APIFlask
from apiflask.commands import spec_command
@pytest.mark.parametrize('format', ['yaml', 'yml', 'json'])
def test_spec_format(app, client, cli_runner, format):
app.config['SPEC_FORMAT'] = format
result = cli_runner.invoke(spec_command)
rv = client.ge... | rv.data | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_commands.py | test_flask_spec_stdout | assert | complex_expr | 12 | import json
import pytest
from .schemas import Foo
from apiflask.commands import spec_command
def test_flask_spec_stdout(app, cli_runner):
result = cli_runner.invoke(spec_command)
assert 'openapi' in result.output
assert json.loads(result.output) == | app.spec | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_basic.py | test_spec | assert | complex_expr | 18 | import json
import pytest
from flask import request
from openapi_spec_validator import validate_spec
from .schemas import Bar
from .schemas import Baz
from .schemas import Foo
from apiflask import APIBlueprint
from apiflask import Schema
from apiflask.commands import spec_command
from apiflask.fields import Integer
... | app.spec | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_spec.py | test_local_spec_path | assert | complex_expr | 16 | import json
import pytest
from apiflask import APIFlask
from apiflask.commands import spec_command
def test_local_spec_path(app, cli_runner, tmp_path):
local_spec_path = tmp_path / 'api.json'
app.config['LOCAL_SPEC_PATH'] = local_spec_path
result = cli_runner.invoke(spec_command)
assert 'openapi' in... | app.spec | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_security.py | test_default_auth_error_handler | assert | complex_expr | 21 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
from apiflask.security import HTTPBasicAuth
from apiflask.security import HTTPTokenAuth
def test_default_auth_error_handler(app, client):
auth = HTTPTokenAuth()
@app.route('/foo')
@app.auth_required(auth)
def foo():
... | rv.headers | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_commands.py | test_flask_spec_stdout | assert | complex_expr | 11 | import json
import pytest
from .schemas import Foo
from apiflask.commands import spec_command
def test_flask_spec_stdout(app, cli_runner):
result = cli_runner.invoke(spec_command)
assert 'openapi' in | result.output | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_spec.py | test_spec_format | assert | complex_expr | 17 | import json
import pytest
from apiflask import APIFlask
from apiflask.commands import spec_command
@pytest.mark.parametrize('format', ['yaml', 'yml', 'json'])
def test_spec_format(app, client, cli_runner, format):
app.config['SPEC_FORMAT'] = format
result = cli_runner.invoke(spec_command)
rv = client.ge... | result.output | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_tags.py | test_tags | assert | complex_expr | 25 | import pytest
from openapi_spec_validator import validate_spec
from apiflask import APIBlueprint
def test_tags(app, client):
assert app.tags is None
app.tags = [
{
'name': 'foo',
'description': 'some description for foo',
'externalDocs': {
'descripti... | rv.json['tags'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_blueprint.py | test_blueprint_enable_openapi | assert | complex_expr | 37 | from flask.views import MethodView
from openapi_spec_validator import validate_spec
from apiflask import APIBlueprint
from apiflask.security import HTTPBasicAuth
from apiflask.security import HTTPTokenAuth
def test_blueprint_enable_openapi(app, client):
auth = HTTPBasicAuth()
@app.get('/hello')
@app.auth... | rv.json['paths'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_commands.py | test_flask_spec_format | assert | complex_expr | 23 | import json
import pytest
from .schemas import Foo
from apiflask.commands import spec_command
@pytest.mark.parametrize('format', ['json', 'yaml', 'yml', 'foo'])
def test_flask_spec_format(app, cli_runner, format, tmp_path):
local_spec_path = tmp_path / 'openapi.json'
@app.get('/')
def hello():
p... | file_result.output | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_info.py | test_info_attribute | assert | complex_expr | 28 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
def test_info_attribute(app, client):
assert app.info is None
app.info = {
'description': 'My API',
'termsOfService': 'http://example.com',
'contact': {
'name': 'API Support',
'url':... | app.info['contact'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_info.py | test_info_attribute | assert | complex_expr | 29 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
def test_info_attribute(app, client):
assert app.info is None
app.info = {
'description': 'My API',
'termsOfService': 'http://example.com',
'contact': {
'name': 'API Support',
'url':... | app.info['license'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_commands.py | test_flask_spec_format | assert | complex_expr | 22 | import json
import pytest
from .schemas import Foo
from apiflask.commands import spec_command
@pytest.mark.parametrize('format', ['json', 'yaml', 'yml', 'foo'])
def test_flask_spec_format(app, cli_runner, format, tmp_path):
local_spec_path = tmp_path / 'openapi.json'
@app.get('/')
def hello():
p... | stdout_result.output | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_overwirte_info | assert | complex_expr | 36 | from openapi_spec_validator import validate_spec
def test_overwirte_info(app, client):
app.config['INFO'] = {
'description': 'Not set',
'termsOfService': 'Not set',
'contact': {
'name': 'Not set',
'url': 'Not set',
'email': 'Not set'
},
'l... | app.config['CONTACT'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_overwirte_info | assert | complex_expr | 37 | from openapi_spec_validator import validate_spec
def test_overwirte_info(app, client):
app.config['INFO'] = {
'description': 'Not set',
'termsOfService': 'Not set',
'contact': {
'name': 'Not set',
'url': 'Not set',
'email': 'Not set'
},
'l... | app.config['LICENSE'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_openapi_info.py | test_info_attribute | assert | complex_expr | 26 | from openapi_spec_validator import validate_spec
from apiflask import APIFlask
def test_info_attribute(app, client):
assert app.info is None
app.info = {
'description': 'My API',
'termsOfService': 'http://example.com',
'contact': {
'name': 'API Support',
'url':... | app.info['description'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_overwirte_info | assert | complex_expr | 34 | from openapi_spec_validator import validate_spec
def test_overwirte_info(app, client):
app.config['INFO'] = {
'description': 'Not set',
'termsOfService': 'Not set',
'contact': {
'name': 'Not set',
'url': 'Not set',
'email': 'Not set'
},
'l... | app.config['DESCRIPTION'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_info | assert | complex_expr | 24 | from openapi_spec_validator import validate_spec
def test_info(app, client):
app.config['INFO'] = {
'description': 'My API',
'termsOfService': 'http://example.com',
'contact': {
'name': 'API Support',
'url': 'http://www.example.com/support',
'email': 'sup... | app.config['INFO']['contact'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_info | assert | complex_expr | 25 | from openapi_spec_validator import validate_spec
def test_info(app, client):
app.config['INFO'] = {
'description': 'My API',
'termsOfService': 'http://example.com',
'contact': {
'name': 'API Support',
'url': 'http://www.example.com/support',
'email': 'sup... | app.config['INFO']['license'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_openapi_fields.py | test_overwirte_info | assert | complex_expr | 35 | from openapi_spec_validator import validate_spec
def test_overwirte_info(app, client):
app.config['INFO'] = {
'description': 'Not set',
'termsOfService': 'Not set',
'contact': {
'name': 'Not set',
'url': 'Not set',
'email': 'Not set'
},
'l... | app.config['TERMS_OF_SERVICE'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
apiflask/apiflask | d4070ebed440918b8e2389601ab2417958129cee | 138 | train | train | tests/test_settings_response_customization.py | test_validation_error_schema | assert | complex_expr | 30 | import pytest
from openapi_spec_validator import validate_spec
from .schemas import Foo
from .schemas import HTTPError
from .schemas import ValidationError
from apiflask.schemas import EmptySchema
from apiflask.schemas import http_error_schema
from apiflask.security import HTTPBasicAuth
@pytest.mark.parametrize('sche... | rv.json['components']['schemas'] | d4070ebed440918b8e2389601ab2417958129cee | 138 | v2_extractor_at_anchor |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.