JSON Schemas

Marshmallow schemas for loading AuthoritySpoke objects from JSON.

Intended for use with machine-generated API responses. Should be suitable for generating an OpenAPI specification.

class authorityspoke.io.schemas_json.CAPCitationSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for Decision citations in CAP API response.

make_object(data, **kwargs)

Load citation.

Return type

CAPCitation

class authorityspoke.io.schemas_json.OpinionSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for Opinions, of which there may be several in one Decision.

>>> data = {
...     "type": "dissent",
...     "author": "Ginsburg",
...     "text": "I respectfully dissent."}
>>> schema = OpinionSchema()
>>> opinion = schema.load(data)
>>> opinion.position
'dissent'
format_data_to_load(data, **kwargs)

Standardize author name before loading object.

Return type

Dict[str, str]

class authorityspoke.io.schemas_json.DecisionSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for decisions retrieved from Caselaw Access Project API.

>>> data = {
...     "id": 12083986,
...     "url": "https://api.case.law/v1/cases/12083986/",
...     "name": "Bellingham executors v. Smith",
...     "name_abbreviation": "Bellingham v. Smith",
...     "decision_date": "1673-04-29",
...     "docket_number": "",
...     "first_page": "248",
...     "last_page": "248",
...     "citations": [
...         {
...             "type": "official",
...             "cite": "1 Rec. Co. Ct. 248"
...         }
...     ],
...     "volume": {
...         "url": "https://api.case.law/v1/volumes/32044031754302/",
...         "volume_number": "1",
...         "barcode": "32044031754302"
...     },
...     "reporter": {
...         "url": "https://api.case.law/v1/reporters/742/",
...         "full_name": "Records of the Suffolk county court, 1671-1680",
...         "id": 742
...     },
...     "court": {
...         "url": "https://api.case.law/v1/courts/suffolk-cty-ct-2/",
...         "name_abbreviation": "Suffolk Cty. Ct.",
...         "slug": "suffolk-cty-ct-2",
...         "id": 11154,
...         "name": "Suffolk County Court"
...     },
...     "jurisdiction": {
...         "id": 4,
...         "name_long": "Massachusetts",
...         "url": "https://api.case.law/v1/jurisdictions/mass/",
...         "slug": "mass",
...         "whitelisted": False,
...         "name": "Mass."
...     },
...     "cites_to": [],
... }
>>> schema = DecisionSchema()
>>> decision = schema.load(data)
>>> decision.jurisdiction
'Mass.'
>>> decision.date.year
1673
>>> decision.citations[0].cite
'1 Rec. Co. Ct. 248'
format_data_to_load(data, **kwargs)

Transform data from CAP API response for loading.

Return type

Dict[str, Union[str, int, Sequence[Dict[str, str]]]]

class authorityspoke.io.schemas_json.FactSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for Facts, which may contain arbitrary levels of nesting.

>>> lotus_entity = {"type": "Entity", "name": "Lotus Development Corporation"}
>>> menu_entity = {"type": "Entity", "name": "the Lotus menu command hierarchy"}
>>> fact_data = {
...             "predicate": {
...                 "content": "$owner registered a copyright covering $work"},
...             "terms": [lotus_entity, menu_entity]
...         }
>>> schema = FactSchema()
>>> fact = schema.load(fact_data)
>>> str(fact)
'the fact that <Lotus Development Corporation> registered a copyright covering <the Lotus menu command hierarchy>'
make_object(data, **kwargs)

Make Fact.

Return type

Fact

class authorityspoke.io.schemas_json.ExhibitSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for an object that may embody a statement.

>>> lotus_entity = {"type": "Entity", "name": "Lotus Development Corporation"}
>>> fact_data = {
...    "predicate": {
...    "content": "$owner registered a copyright covering $work"},
...    "terms": [lotus_entity, {"type": "Entity", "name": "the Lotus menu command hierarchy"}]
...         }
>>> exhibit_data = {
...     "form": "certificate of copyright registration",
...     "statement": fact_data,
...     "statement_attribution": {"name": "Lotus Development Corporation"}
...     }
>>> schema = ExhibitSchema()
>>> exhibit = schema.load(exhibit_data)
>>> print(exhibit)
the certificate of copyright registration attributed to <Lotus Development Corporation>, asserting the fact that <Lotus Development Corporation> registered a copyright covering <the Lotus menu command hierarchy>,
make_object(data, **kwargs)

Make Exhibit.

Return type

Exhibit

class authorityspoke.io.schemas_json.PleadingSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for a document to link Allegations to.

>>> lotus_entity = {"name": "Lotus Development Corporation"}
>>> pleading_data = {"filer": lotus_entity, "generic": False}
>>> schema = PleadingSchema()
>>> pleading = schema.load(pleading_data)
>>> str(pleading)
'the pleading filed by <Lotus Development Corporation>'
class authorityspoke.io.schemas_json.AllegationSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for an Allegation of a Fact.

class authorityspoke.io.schemas_json.EvidenceSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for an Exhibit and a reference to the Fact it would support.

>>> lotus_entity = {"type": "Entity", "name": "Lotus Development Corporation"}
>>> menu_entity = {"type": "Entity", "name": "the Lotus menu command hierarchy"}
>>> fact_data = {
...     "predicate": {
...     "content": "$owner registered a copyright covering $work"},
...     "terms": [lotus_entity, menu_entity]
...     }
>>> exhibit_data = {
...     "form": "certificate of copyright registration",
...     "statement": fact_data,
...     "statement_attribution": {"name": "Lotus Development Corporation"}
...     }
>>> evidence_data = {
...     "exhibit": exhibit_data,
...     "to_effect": {
...         "predicate": {"content": "$work was copyrightable"},
...         "terms": [menu_entity]}
... }
>>> schema = EvidenceSchema()
>>> evidence = schema.load(evidence_data)
>>> print(evidence)
the evidence of the certificate of copyright registration attributed to <Lotus Development Corporation>, asserting the fact that <Lotus Development Corporation> registered a copyright covering <the Lotus menu command hierarchy>, which supports the fact that <the Lotus menu command hierarchy> was copyrightable
class authorityspoke.io.schemas_json.FactorSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema that directs data to “one of” the other schemas.

Must include a type field to indicate which subclass schema to use.

>>> lotus_entity = {"type": "Entity", "name": "Lotus Development Corporation"}
>>> menu_entity = {"type": "Entity", "name": "the Lotus menu command hierarchy"}
>>> fact_data = {
...             "type": "Fact",
...             "predicate": {
...                 "content": "$owner registered a copyright covering $work"},
...             "terms": [lotus_entity, menu_entity]
...         }
>>> schema = FactorSchema()
>>> fact = schema.load(fact_data)
>>> str(fact)
'the fact that <Lotus Development Corporation> registered a copyright covering <the Lotus menu command hierarchy>'
get_obj_type(obj)

Return name of object schema.

Return type

str

class authorityspoke.io.schemas_json.ProcedureSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for loading a Procedure from data fitting an OpenAPI schema.

Does not require separate TermSequence schema. FactorSchema will load the equivalent of a TermSequence with the parameter many=True.

>>> api_data = {"type": "Entity", "name": "the Java API"}
>>> procedure_data = {
... "inputs": [{
...     "type": "Fact",
...     "predicate": {"content": "$work was an original work",
...     "truth": False},
...     "terms": [api_data]}],
... "outputs": [{
...     "type": "Fact",
...     "predicate": {"content": "$work was copyrightable",
...     "truth": False},
...     "terms": [api_data]}]}
>>> schema = ProcedureSchema()
>>> procedure = schema.load(procedure_data)
>>> procedure.short_string
'RESULT: the fact it was false that <the Java API> was copyrightable GIVEN: the fact it was false that <the Java API> was an original work'
class authorityspoke.io.schemas_json.RuleSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for loading Rules from data fitting an OpenAPI schema.

>>> api_data = {"type": "Entity", "name": "the Java API"}
>>> procedure_data = {
... "inputs": [{
...     "type": "Fact",
...     "predicate": {"content": "$work was an original work",
...     "truth": False},
...     "terms": [api_data]}],
... "outputs": [{
...     "type": "Fact",
...     "predicate": {"content": "$work was copyrightable",
...     "truth": False},
...     "terms": [api_data]}]}
>>> rule_data = {"procedure": procedure_data,
...     "mandatory": True,
...     "enactments": [{
...         "node": "/us/usc/t17/s102",
...         "start_date": "1990-12-01",
...         "text_version": {
...         "content": "Copyright protection subsists, in accordance with this title, in original works of authorship fixed in any tangible medium of expression, now known or later developed."},
...         "selection": [{"start": 0, "end": 93}]}]}
>>> schema = RuleSchema()
>>> rule = schema.load(rule_data)
>>> print(rule.short_string)
the Rule that the court MUST SOMETIMES impose the RESULT: the fact it was false that <the Java API> was copyrightable GIVEN: the fact it was false that <the Java API> was an original work GIVEN the ENACTMENT: "Copyright protection subsists, in accordance with this title, in original works of authorship…" (/us/usc/t17/s102 1990-12-01)
class authorityspoke.io.schemas_json.HoldingSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for loading Holdings from data fitting an OpenAPI schema.

>>> api_data = {"type": "Entity", "name": "the Java API"}
>>> procedure_data = {
... "inputs": [{
...     "type": "Fact",
...     "predicate": {"content": "$work was an original work",
...     "truth": False},
...     "terms": [api_data]}],
... "outputs": [{
...     "type": "Fact",
...     "predicate": {"content": "$work was copyrightable",
...     "truth": False},
...     "terms": [api_data]}]}
>>> rule_data = {"procedure": procedure_data,
...     "mandatory": True,
...     "enactments": [{
...         "node": "/us/usc/t17/s102",
...         "start_date": "1990-12-01",
...         "text_version": {
...         "content": "Copyright protection subsists, in accordance with this title, in original works of authorship fixed in any tangible medium of expression, now known or later developed."},
...         "selection": [{"start": 0, "end": 93}]}]}
>>> holding_data = {
...     "rule": rule_data,
...     "rule_valid": False}
>>> schema = HoldingSchema()
>>> holding = schema.load(holding_data)
>>> print(holding.short_string)
the Holding to REJECT the Rule that the court MUST SOMETIMES impose the RESULT: the fact it was false that <the Java API> was copyrightable GIVEN: the fact it was false that <the Java API> was an original work GIVEN the ENACTMENT: "Copyright protection subsists, in accordance with this title, in original works of authorship…" (/us/usc/t17/s102 1990-12-01)
class authorityspoke.io.schemas_json.NamedAnchors(name, anchors)
name: nettlesome.factors.Factor

Alias for field number 0

anchors: List[anchorpoint.textselectors.TextQuoteSelector]

Alias for field number 1

class authorityspoke.io.schemas_json.NamedAnchorsSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas_json.AnchoredEnactments(enactment, anchors)
enactment: legislice.enactments.Enactment

Alias for field number 0

anchors: List[anchorpoint.textselectors.TextQuoteSelector]

Alias for field number 1

class authorityspoke.io.schemas_json.AnchoredEnactmentsSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
authorityspoke.io.schemas_json.get_schema_for_item(classname)

Find the Marshmallow schema for an AuthoritySpoke object.

Return type

Schema