[Json] JSON Schema Language: extensibility and unspecified properties

Ulysse Carion <ulysse@segment.com> Sat, 10 August 2019 01:43 UTC

Return-Path: <ulysse@segment.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 425E612003F for <json@ietfa.amsl.com>; Fri, 9 Aug 2019 18:43:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.999
X-Spam-Level:
X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=segment.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TFu9gtQgIF5v for <json@ietfa.amsl.com>; Fri, 9 Aug 2019 18:43:49 -0700 (PDT)
Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id E134D120047 for <json@ietf.org>; Fri, 9 Aug 2019 18:43:48 -0700 (PDT)
Received: by mail-ot1-x341.google.com with SMTP id l15so82505411oth.7 for <json@ietf.org>; Fri, 09 Aug 2019 18:43:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=segment.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=1MaDFKSb7T+nQ5SPCviGOGa0eO1rchY2iVJ3a2WJlTg=; b=qrevrOAqa2i1wNj5mLUKpIcIUKTEG7YBZ2FsdxrrOmjEYHbw0uMg5lwW7WdLyMg1hQ 9IVjSJWAVbGS718gR6ywqo8sTieU8OE+UUu4FG0nil+HMjeC4BwUdIpAVFGga9N5C6db UgmEy/3vL06ZAQ/PUVZsGCPFG7VqMSN7D4/gc=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=1MaDFKSb7T+nQ5SPCviGOGa0eO1rchY2iVJ3a2WJlTg=; b=fLyOKjv26fg2AtqjayYFgYxkvkzlC7qu9ErTI8P+VTiI3vFQ8iwjVNudIJ9o53gEDD GRBSnGDbcQu5JeLtJgr96+5jbwQC2ed0fOKD+vPr+jWjYFeBZcqc+R/TdkVe3zBG9rFb wdY7+L7XdXAOOhjZJeQYhe21Nn3jihyLvtTCueNqcr6KsN1XLuaF2eWMPMi6gPYnoXHe s4BYMfOb+eiNCcy92M0IRzkf9eWm+1H2ctEHRZQdhgf1YsPhhxMxi63htmqHT7Yzj6gK cqdijbSZe/XT7tDCf2dRq9SCFrbE7eLdlZzbRDO9bt37c5XefCg1o97Q/RizjaST4UaQ 6BXQ==
X-Gm-Message-State: APjAAAVvYWQdbeavsQkJlS1RpwyPkGDNTCfxbhbNseL4StQlRxoBUHv6 FRi+1GFkxmiQ0wBMSstW6pZXEx8uPAYhwoCGsJB4vvF1Yvo=
X-Google-Smtp-Source: APXvYqyjefg369JTYWxRyaUATmdf1pDpLWUHK1PzDjzOAWiZ9/gCCZkM7AxKJ/OTWrLTP0j+9+vuF4gSIo8wzmb1IQs=
X-Received: by 2002:a5d:96d8:: with SMTP id r24mr24263612iol.269.1565401427789; Fri, 09 Aug 2019 18:43:47 -0700 (PDT)
MIME-Version: 1.0
From: Ulysse Carion <ulysse@segment.com>
Date: Fri, 09 Aug 2019 18:43:37 -0700
Message-ID: <CAJK=1RhXp85cz-pOAQPw2JM=CYHgGSygj4Hw0spht56jbzQE2g@mail.gmail.com>
To: JSON WG <json@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/j1fWnmndLH0cUcHSI3_MfR9q5rg>
Subject: [Json] JSON Schema Language: extensibility and unspecified properties
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 10 Aug 2019 01:43:52 -0000

Hi folks,

Thanks again for all the wonderful suggestions for JSON Schema
Language. I've just published a new draft incorporating suggestions
from the last update. You can read it here:

https://tools.ietf.org/html/draft-ucarion-json-schema-language-02

I would like advice on the two following changes I've made to the spec.

First, I added explicit discussion of how JSL can be extended. The
language is at the end of section 2, but I'll reproduce it here:

> This document does not describe any extension mechanisms for JSL schema
> validation. However, schemas (through the `non-keyword` CDDL rule in this
> section) are defined to allow members whose names are not equal to any of the
> specially-defined keywords (i.e. `definitions`, `elements`, etc.) described in
> this section. Call these members "non-keyword members".
>
> Users MAY add additional, non-keyword members to JSL schemas to convey
> information that is not pertinent to validation. For example, such non-keyword
> members could provide hints to code generators, or trigger some special behavior
> for a library that generates user interfaces from schemas.
>
> Users SHOULD NOT expect non-keyword members to be understood by other parties.
> As a result, if consistent validation with other parties is a requirement, users
> SHOULD NOT use non-keyword members to affect how schema validation, as described
> in {{semantics}}, works.

Basically, my stance is: you can add custom stuff to schemas, but you
can't change validation. I expect that people will change validation
anyway, but they're not going to expect portability. I don't feel that
adding some sort of registry of keywords / forms is valuable yet.
Perhaps something like that can be in whatever replaces JSL?

How do folks feel about this? Does anyone have suggestions on better
ways I can approach extensibility, or how I should phrase this
language?

The other thing I want advice on is "strict" mode, called "strict
instance semantics" in the spec. Basically, strict instance semantics
about whether it's ok to send "extra"/"unknown"/"unspecified"
properties in an object.

Right now, validation behavior is specified as a single, top-level
"strict": true/false (default is "true") property. You can't mix and
match strict and non-strict. But Carsten off-list noted that might be
a bit "blunt". Do others agree?

The context for my decision is that two of major typed languages used
in industry, Java and Golang, don't typically support mixing and
matching. Go just as a blunt DisallowUnknownFields:

https://golang.org/pkg/encoding/json/#Decoder.DisallowUnknownFields

And Java's Jackson has a FAIL_ON_UNKNOWN_PROPERTIES:

http://fasterxml.github.io/jackson-databind/javadoc/2.9/com/fasterxml/jackson/databind/DeserializationFeature.html#FAIL_ON_UNKNOWN_PROPERTIES

Both are all or nothing.

Also, there is the question of whether "strict" is a good name for
this property in schemas. Is there a better name for it? "strict" can
be understood in many ways. Open to ideas here as well.

Other changes:

- Removed int64/uint64 (and removed discussion related to I-JSON)
- Clarified that 1.0e1 is an integer

Finally, I've moved JSL to a desired status of "Informative", and I'll
be going through the independent stream once the discussion here
appears to have settled.

Thanks again for all the help,
Ulysse