Re: [Json] JSON Schema Language: extensibility and unspecified properties

Anders Rundgren <anders.rundgren.net@gmail.com> Sat, 10 August 2019 19:00 UTC

Return-Path: <anders.rundgren.net@gmail.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 5D6BB120186 for <json@ietfa.amsl.com>; Sat, 10 Aug 2019 12:00:55 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.998
X-Spam-Level:
X-Spam-Status: No, score=-1.998 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 (2048-bit key) header.d=gmail.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 c7ZjlkgOIwQY for <json@ietfa.amsl.com>; Sat, 10 Aug 2019 12:00:52 -0700 (PDT)
Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (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 DD238120148 for <json@ietf.org>; Sat, 10 Aug 2019 12:00:51 -0700 (PDT)
Received: by mail-wm1-x342.google.com with SMTP id f72so8691639wmf.5 for <json@ietf.org>; Sat, 10 Aug 2019 12:00:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Qs29bHdVzAjprg/ppIT5N5iDH8Lx61iFdgv1/T+EpaE=; b=jO74D84mCGhYSlunAnLpyqEeGZwfPEDkX+RYLQSbksdGlSgzzlXuINvTDggYFZkPKd 9s9UtU798GqJVwMAmoZUetZXqnG/VfCDXHXCH3Ap+lYTifulwHchHxA24lDs9DtefZ9B mwXZ/jhh1kp6iyQ46LlzgzO9m+IXXBiPXyOKVZ/Z/lzA3I1wb02ZiV3gOm1Pkjws+o/a MOquVWojQKdPaqWPvQ1N0rPrHbslgFPE0/BS3FxCSQEWxURkudCJWyzKhQD1eQjQ2nzX 6yBDeLN2st/zlF+oJw9ncFjAYOvuaIotsNPYYmMfWoaysszqWXArqxYqAqDe8zTzOJSu nB3g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Qs29bHdVzAjprg/ppIT5N5iDH8Lx61iFdgv1/T+EpaE=; b=Ewb/7uzLDjIKRJFCP6CyNAxC8HHD/a6Lyw3Aa3e5PErq2wvuWOiSk0az6GSjXsRGog SQEBBbLtgML05AGhp5aWlnMbevi0hoGZ9/Q4OtCxoWhTQsJQn+1Kk7R6dGDS1XBnTpRl Uef6GYaTRpaia7iYuDWKXeEsVvCVtHu3s31qD9dg0sMRehYZbD95DBN8fp8FHfMnNY07 zN66FpAXR6Cp6A412cKE6+o1w5vWU32izGY+ewYHQo6covr7P3oVgQ6SSdm6FaTew/dw FcQA2tpWn+jXO1046Ro4aCBVxM4+ktCG/Heqx7pSp3l+POmvkaenl3v0BD/2MARGtnYj BQ3Q==
X-Gm-Message-State: APjAAAUCEF8z488TfH3gtVGuEs56VXVfoMGidc6ur4C+xFtPf/90pNUM bQKUqNb12uptqU7qXpoYfEc=
X-Google-Smtp-Source: APXvYqz5P1zUO5sAKq3ojfKUZfk1fr9MtK/nEyAICIKoD87YfLIpPZ5lDCyf8REkXWIaMee60ahqKA==
X-Received: by 2002:a1c:be11:: with SMTP id o17mr18154717wmf.115.1565463650207; Sat, 10 Aug 2019 12:00:50 -0700 (PDT)
Received: from [192.168.1.79] (25.131.146.77.rev.sfr.net. [77.146.131.25]) by smtp.googlemail.com with ESMTPSA id u1sm11221364wml.14.2019.08.10.12.00.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Aug 2019 12:00:49 -0700 (PDT)
To: Ulysse Carion <ulysse@segment.com>, JSON WG <json@ietf.org>
References: <CAJK=1RhXp85cz-pOAQPw2JM=CYHgGSygj4Hw0spht56jbzQE2g@mail.gmail.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <8d56f00d-14af-c387-ff02-e279cca6ddea@gmail.com>
Date: Sat, 10 Aug 2019 21:00:46 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
MIME-Version: 1.0
In-Reply-To: <CAJK=1RhXp85cz-pOAQPw2JM=CYHgGSygj4Hw0spht56jbzQE2g@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/R7VIBmyvlSMI4Vsl3iwNDYJiERc>
Subject: Re: [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 19:01:03 -0000

If we stick to unspecified properties I'm currently working with a
payment authorization scheme where some components will be defined
by the payment networks.  The components start with a defined property
holding a JSON Object but the contents of the object is not known by
the "main" schema.

In my programmatic solution the "main schema" ignores such components
and only validates that they conform JSON.  The components are
then dealt with by customer supplied decoders which indeed may use
a schema.

How can you express this in a main schema using JCL?

Anders

   paymentRequest = new PaymentRequest(rd.getObject(PAYMENT_REQUEST_JSON));
   undecodedPaymentMethodSpecific = rd.getObject(BACKEND_METHOD_SPECIFIC_JSON);
   rd.scanAway(BACKEND_METHOD_SPECIFIC_JSON);
   referenceId = rd.getString(REFERENCE_ID_JSON);


On 2019-08-10 03:43, Ulysse Carion wrote:
> 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
> 
> _______________________________________________
> json mailing list
> json@ietf.org
> https://www.ietf.org/mailman/listinfo/json
>