How to use the apispec.utils.build_reference function in apispec

To help you get started, we’ve selected a few apispec examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marshmallow-code / apispec / tests / test_utils.py View on Github external
"$ref": "#/parameters/Test"
    }
    assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"}
    assert utils.build_reference("security_scheme", 2, "Test") == {
        "$ref": "#/securityDefinitions/Test"
    }
    assert utils.build_reference("schema", 3, "Test") == {
        "$ref": "#/components/schemas/Test"
    }
    assert utils.build_reference("parameter", 3, "Test") == {
        "$ref": "#/components/parameters/Test"
    }
    assert utils.build_reference("response", 3, "Test") == {
        "$ref": "#/components/responses/Test"
    }
    assert utils.build_reference("security_scheme", 3, "Test") == {
        "$ref": "#/components/securitySchemes/Test"
    }
github marshmallow-code / apispec / tests / test_utils.py View on Github external
def test_build_reference():
    assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
    assert utils.build_reference("parameter", 2, "Test") == {
        "$ref": "#/parameters/Test"
    }
    assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"}
    assert utils.build_reference("security_scheme", 2, "Test") == {
        "$ref": "#/securityDefinitions/Test"
    }
    assert utils.build_reference("schema", 3, "Test") == {
        "$ref": "#/components/schemas/Test"
    }
    assert utils.build_reference("parameter", 3, "Test") == {
        "$ref": "#/components/parameters/Test"
    }
    assert utils.build_reference("response", 3, "Test") == {
        "$ref": "#/components/responses/Test"
    }
    assert utils.build_reference("security_scheme", 3, "Test") == {
        "$ref": "#/components/securitySchemes/Test"
    }
github marshmallow-code / apispec / tests / test_utils.py View on Github external
def test_build_reference():
    assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
    assert utils.build_reference("parameter", 2, "Test") == {
        "$ref": "#/parameters/Test"
    }
    assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"}
    assert utils.build_reference("security_scheme", 2, "Test") == {
        "$ref": "#/securityDefinitions/Test"
    }
    assert utils.build_reference("schema", 3, "Test") == {
        "$ref": "#/components/schemas/Test"
    }
    assert utils.build_reference("parameter", 3, "Test") == {
        "$ref": "#/components/parameters/Test"
    }
    assert utils.build_reference("response", 3, "Test") == {
        "$ref": "#/components/responses/Test"
    }
    assert utils.build_reference("security_scheme", 3, "Test") == {
        "$ref": "#/components/securitySchemes/Test"
    }
github marshmallow-code / apispec / tests / utils.py View on Github external
def build_ref(spec, component_type, obj):
    return build_reference(component_type, spec.openapi_version.major, obj)
github marshmallow-code / apispec / tests / test_utils.py View on Github external
def test_build_reference():
    assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
    assert utils.build_reference("parameter", 2, "Test") == {
        "$ref": "#/parameters/Test"
    }
    assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"}
    assert utils.build_reference("security_scheme", 2, "Test") == {
        "$ref": "#/securityDefinitions/Test"
    }
    assert utils.build_reference("schema", 3, "Test") == {
        "$ref": "#/components/schemas/Test"
    }
    assert utils.build_reference("parameter", 3, "Test") == {
        "$ref": "#/components/parameters/Test"
    }
    assert utils.build_reference("response", 3, "Test") == {
        "$ref": "#/components/responses/Test"
    }
    assert utils.build_reference("security_scheme", 3, "Test") == {
        "$ref": "#/components/securitySchemes/Test"
    }
github marshmallow-code / apispec / tests / test_utils.py View on Github external
def test_build_reference():
    assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
    assert utils.build_reference("parameter", 2, "Test") == {
        "$ref": "#/parameters/Test"
    }
    assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"}
    assert utils.build_reference("security_scheme", 2, "Test") == {
        "$ref": "#/securityDefinitions/Test"
    }
    assert utils.build_reference("schema", 3, "Test") == {
        "$ref": "#/components/schemas/Test"
    }
    assert utils.build_reference("parameter", 3, "Test") == {
        "$ref": "#/components/parameters/Test"
    }
    assert utils.build_reference("response", 3, "Test") == {
        "$ref": "#/components/responses/Test"
    }
    assert utils.build_reference("security_scheme", 3, "Test") == {
        "$ref": "#/components/securitySchemes/Test"
    }
github marshmallow-code / apispec / tests / test_utils.py View on Github external
def test_build_reference():
    assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
    assert utils.build_reference("parameter", 2, "Test") == {
        "$ref": "#/parameters/Test"
    }
    assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"}
    assert utils.build_reference("security_scheme", 2, "Test") == {
        "$ref": "#/securityDefinitions/Test"
    }
    assert utils.build_reference("schema", 3, "Test") == {
        "$ref": "#/components/schemas/Test"
    }
    assert utils.build_reference("parameter", 3, "Test") == {
        "$ref": "#/components/parameters/Test"
    }
    assert utils.build_reference("response", 3, "Test") == {
        "$ref": "#/components/responses/Test"
    }
    assert utils.build_reference("security_scheme", 3, "Test") == {
        "$ref": "#/components/securitySchemes/Test"
    }
github marshmallow-code / flask-smorest / tests / utils.py View on Github external
def build_ref(spec, component_type, obj):
    return build_reference(component_type, spec.openapi_version.major, obj)
github marshmallow-code / apispec / src / apispec / ext / marshmallow / openapi.py View on Github external
def get_ref_dict(self, schema):
        """Method to create a dictionary containing a JSON reference to the
        schema in the spec
        """
        schema_key = make_schema_key(schema)
        ref_schema = build_reference(
            "schema", self.openapi_version.major, self.refs[schema_key]
        )
        if getattr(schema, "many", False):
            return {"type": "array", "items": ref_schema}
        return ref_schema