Skip to content

Flat schema - #60

Merged
timwis merged 10 commits into
gh-pagesfrom
flat-schema
Apr 3, 2016
Merged

timwis merged 10 commits into
gh-pagesfrom
flat-schema

Conversation

@timwis

@timwis timwis commented Mar 31, 2016

Copy link
Copy Markdown
Owner

A less complex alternative to #58 that I hope is enough. This pull request allows administrators to create schema files in the _data/schemas/ directory to extend the fields that ship with JKAN. Requirements around this schema file are:

  • field_name must be a string as it's used as the object key. As such, dataset schemas are flat (no foo[bar][baz]) with the exception of the resources section
  • JKAN hard-codes logic for title, notes, organization, and category. If there are no fields in the schema file with those field_names, JKAN functionality will gracefully degredate
  • In order for the data.json file generation to work, each field in the schema should have a datajson property indicating where it fits into the data.json structure. This property can use dot notation (ie. contactPoint.fn), and is not a required property as schemas may have fields that data.json does not expect.

TODO:

  • Incorporate Resources into the schema files
  • Ensure the graceful degredation I mentioned above
  • Finish adding the fields to the data.json generator, and figure out a way to remove whitespace without sacrificing all readability
  • Add documentation

What do you think @JJediny? This is that simpler alternative I mentioned, also trying to incorporate your idea of mapping the datajson fields.

@timwis

timwis commented Apr 3, 2016

Copy link
Copy Markdown
Owner Author

@JJediny should the data.json field property in the schema file be datajson? Is that the appropriate terminology? ex:

  - field_name: organization
    label: Organization
    form_template: form/organization.html
    datajson: publisher.name

@timwis

timwis commented Apr 3, 2016

Copy link
Copy Markdown
Owner Author

Woot, figured out a way to construct the data.json file in a readable way without completely sacrificing readability, by enclosing variable assignments in a {% capture %} tag.

Okay, it's ready to merge. Just want @JJediny to take a look at the datajson property name and approach taken in data.json generator

This was referenced Apr 3, 2016
@JJediny

JJediny commented Apr 3, 2016

Copy link
Copy Markdown
Contributor

Looks good to me... datajson should work just fine in the schema template... but in the dataset property comformsTo we should hard code the url to the schema:
https://project-open-data.cio.gov/v1.1/schema

+1 to merge

@timwis

timwis commented Apr 3, 2016

Copy link
Copy Markdown
Owner Author

Good point @JJediny and thanks for the quick response.

FYI, added documentation for this to the wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants