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.
Schema for Decision citations in CAP API response.
Load citation.
- Return type
CAPCitation
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'
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'
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 Fact.
- Return type
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 Exhibit.
- Return type
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>'
Schema for an Allegation of a Fact.
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
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>'
Return name of object schema.
- Return type
Schema for loading a Procedure from data fitting an OpenAPI schema.
Does not require separate
TermSequence
schema.FactorSchema
will load the equivalent of aTermSequence
with the parametermany=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'
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)
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)
Alias for field number 0
Alias for field number 1
Alias for field number 0
Alias for field number 1
Find the Marshmallow schema for an AuthoritySpoke object.
- Return type
Schema