Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Intended date/time format for schema #17

Open
iadgovuser1 opened this issue Jun 4, 2018 · 5 comments
Open

Intended date/time format for schema #17

iadgovuser1 opened this issue Jun 4, 2018 · 5 comments

Comments

@iadgovuser1
Copy link

https://github.com/GSA/code-gov-web/blob/master/src/assets/schemas/2.0.0.json#L243 has comments of "in YYYY-MM-DD or ISO 8601 format" for the dates. Is the intent to allow both date and date time formats or just a date format? The JSON Schema spec at http://json-schema.org/latest/json-schema-validation.html#rfc.section.7.3.1 shows "date" as being the same thing as "full-date" (date is same thing as full-date according to https://tools.ietf.org/html/rfc3339#section-5.6 ). Neither includes time. The current "date" value specified in the code.gov schema means just a date without time which explains why I'm getting errors with the library I'm using (https://github.com/JamesNK/Newtonsoft.Json.Schema/).

I'm taking dates from GitHub API calls and assigning them to certain code.gov schema fields but the schema isn't validating. Seems like the GitHub API uses the equivalent to date-time as far JSON Schema spec and RFC3339 is concerned.

Fix would be to either change code.gov schema to use date-time or I'd change my code to output a date string that's valid with what's currently in the schema (date). Former would probably be too big of a change than the later, but just wanted to ask what the intent was (date versus date-time). Seems like the intent is that code.gov schema wants date without time.

@DanielJDufour
Copy link
Contributor

@iadgovuser1 , great question. @froi or @RicardoAReyes , can you help clarify? Thanks!

@froi
Copy link
Contributor

froi commented Jun 4, 2018

Hi @iadgovuser1, thanks for reaching out.

In schema version 1.0.1 the date fields were just strings without the format specified. The intent of version 2.0.0 was always to give it a format to improve data quality. I believe that the intent was to accept both formats as stated in the description. Thanks for catching this oversight!

We will be discussing what approach to take, although I think we will update the schema to permit both formats.

Ex.

"date": {
    "type": "object",
    "description": "A date object describing the release.",
    "properties": {
        "created": {
            "anyOf": [{
                    "type": "string",
                    "format": "date"
                },
                {
                    "type": "string",
                    "format": "date-time"
                }
            ],
            "description": "The date the release was created, in YYYY-MM-DD or ISO 8601 format."
        },
        "lastModified": {
            "anyOf": [{
                    "type": "string",
                    "format": "date"
                },
                {
                    "type": "string",
                    "format": "date-time"
                }
            ],
            "description": "The date the release was modified, in YYYY-MM-DD or ISO 8601 format."
        },
        "metadataLastUpdated": {
            "anyOf": [{
                    "type": "string",
                    "format": "date"
                },
                {
                    "type": "string",
                    "format": "date-time"
                }
            ],
            "description": "The date the metadata of the release was last updated, in YYYY-MM-DD or ISO 8601 format."
        }
    },
    "additionalProperties": false
}

We will get back to you.

@iadgovuser1
Copy link
Author

@froi Thanks for the quick response. For now I've updated my code so it will validate against the current schema requirement (date only), but allowing both in the future would be great.

@iadgovuser1
Copy link
Author

I forgot to mention the project I'm using the schema with: https://github.com/nsacyber/CodeGov This is what I use to generate https://nsacyber.github.io/code.json

Right now the schema is embedded in the code, but I might switch to dynamically retrieving the schema from https://github.com/GSA/code-gov-data/blob/master/schemas/schema-2.0.0.json

@DanielJDufour
Copy link
Contributor

Hi, @iadgovuser1 . I'm moving this to code-gov-data where we are now hosting the schema discussions. Thanks!

@DanielJDufour DanielJDufour transferred this issue from GSA/code-gov-web Dec 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants