Skip to content

Instantly share code, notes, and snippets.

@cds-amal
Created April 14, 2015 22:33
Show Gist options
  • Save cds-amal/b5b72c3b79d96733e9a1 to your computer and use it in GitHub Desktop.
Save cds-amal/b5b72c3b79d96733e9a1 to your computer and use it in GitHub Desktop.
import json
from jsl import Document, StringField, ArrayField, IntField
from jsl import DocumentField, OneOfField
class Organization(Document):
class Options(object):
title = 'Organization'
description = 'A DCAS Organization.\nSee: http://talk.beta.nyc'
definition_id = 'org'
agencyCode = IntField(description='An agency code as defined by DCAS')
agencyName = StringField()
agency = StringField()
agencyDivisionId = IntField()
parent = IntField()
name = StringField()
agencyDivision = StringField()
class NoticeItem(Document):
class Options(object):
title = 'Notice Item'
description = ''
definition_id = 'noticeitem'
id = IntField(description='')
description = StringField(description='')
itemObject = StringField()
itemAction = StringField()
adminContext = StringField()
documentContext = StringField()
refOrg = ArrayField(DocumentField(Organization, as_ref=True))
class Skeleton(Document):
class Options(object):
title = 'NoticeBase'
definition_id = 'basenotice'
description = '''The schema is still a working draft, but the completion of it is fairly
simple if we can make sure that we are on the same page with DCAS as to
what we are trying to do. In a nutshell, the community team wants to work
together with DCAS to make the public schema an optimized way of presenting
the City Record data as open data to the public. This involves adapting
best practices for open data publication.
'''
requestId = StringField(required=True)
typeOfNotice = IntField(required=True)
noticeTypeName = StringField(required=True)
sectionName = StringField()
shortTitle = StringField()
noticeDescription = StringField()
otherInfo = StringField()
printOut = StringField()
organization = DocumentField(Organization, as_ref=True)
class NoticeSchema(Document):
class Options(object):
title = 'Notice'
description = 'Description of a Notice'
definition_id = 'notice_schema'
base = DocumentField(Skeleton, as_ref=True)
items = ArrayField(NoticeItem)
# print(json.dumps(Skeleton.get_schema()))
print(json.dumps(NoticeSchema.get_schema()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment