Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"$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"
}
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"
}
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"
}
def build_ref(spec, component_type, obj):
return build_reference(component_type, spec.openapi_version.major, obj)
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"
}
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"
}
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"
}
def build_ref(spec, component_type, obj):
return build_reference(component_type, spec.openapi_version.major, obj)
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