Re: [Json] Another problematic JSON Schema use-case

Austin William Wright <aaa@bzfx.net> Wed, 25 May 2016 01:07 UTC

Return-Path: <aaa@bzfx.net>
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 6BAE212B028 for <json@ietfa.amsl.com>; Tue, 24 May 2016 18:07:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.7
X-Spam-Level:
X-Spam-Status: No, score=-2.7 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=bzfx.net
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 KEznvHhB7jOi for <json@ietfa.amsl.com>; Tue, 24 May 2016 18:07:31 -0700 (PDT)
Received: from mail-qk0-x236.google.com (mail-qk0-x236.google.com [IPv6:2607:f8b0:400d:c09::236]) (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 A5F0312D100 for <json@ietf.org>; Tue, 24 May 2016 18:07:31 -0700 (PDT)
Received: by mail-qk0-x236.google.com with SMTP id t145so21905139qke.2 for <json@ietf.org>; Tue, 24 May 2016 18:07:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bzfx.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sxaondNbmMkv6mLKe00eudHOaaM728OYJevDxHWoY+A=; b=4gzm89uVxNcPbvjdYXDUpqgopRzwg3zVW1CTiaGsMpQaGI6WZsP2t2X+GSyrLub1fp 0apOJdxUBKUeNezba5OQnqbl+GLhafL1oWVuCe+jr1EXByZ+05UN7gTJeSwgzZCf6T1B lMtXdpoCrwL6eobCiF+KGPDKhEmokCdfO+ouU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sxaondNbmMkv6mLKe00eudHOaaM728OYJevDxHWoY+A=; b=f0zRljWQx/KuduAusI9gDo3RDBYMpqp+UkLNfZ4HjOr08QemSjk/FYlZ7Wj0KUjnbO 43b7EbGdl+C+quBDGafm8LpjZw5rz41awPnLfqNBwHjYv/W8SbJmJwWDziqElNTRssFT KzcrdqXkkOBnmsjJFzh6RHoMcq8BwvyOnz4PHjHrbnTCSfqFjHZl+v+6TlQmJYFJ8kXZ SkwOOpq4N6L2g4BH64SAlK0j2ESjewIPTJfdFZPMQlwPocuJsrUI3cW2m4/4yOp6hb+t m8UMmDsEgM1OTIqdXa8RN5t/KJFdlpuzlJyR/dI1Y+VI5YOC5tpWr1OIsU3SIP2d3KdL zfTw==
X-Gm-Message-State: ALyK8tKHceRlHL5VOIEvJ/tN8lxe2r3MMFiWZ0nzPKL9TrqfDKRF+QALubwgsVfxXPgSrCSuIimRG2fTBdJ89g==
X-Received: by 10.55.215.132 with SMTP id t4mr1136347qkt.66.1464138450704; Tue, 24 May 2016 18:07:30 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.55.80.85 with HTTP; Tue, 24 May 2016 18:07:16 -0700 (PDT)
In-Reply-To: <CAHBU6iu_nYyUBS-8PAJ3zER=RNKfiV532vEOeOnfr5eXbPv8Tw@mail.gmail.com>
References: <CAHBU6ivd5JJ7Hx_JtNPSnW40jXzEF1Yr7=rwuZzGnFrRoMphbg@mail.gmail.com> <CANkuk-WppF4WgeZc5OX2-tozmCd+eYtPwFgmDtoiJHxwdSjDzw@mail.gmail.com> <CAHBU6iu_nYyUBS-8PAJ3zER=RNKfiV532vEOeOnfr5eXbPv8Tw@mail.gmail.com>
From: Austin William Wright <aaa@bzfx.net>
Date: Tue, 24 May 2016 18:07:16 -0700
Message-ID: <CANkuk-Ufuzd4SZjV9-096J7yTSBt1XsRkra-dteXdgSMH8=QPA@mail.gmail.com>
To: Tim Bray <tbray@textuality.com>
Content-Type: multipart/alternative; boundary="001a1149dd5e41b6c20533a04c20"
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/7gRZ02GcPbjXs-L3ipsooFZQDs8>
Cc: "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Another problematic JSON Schema use-case
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.17
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: Wed, 25 May 2016 01:07:33 -0000

I also use them as specification aids, I think JSON Hyperschema is a great
tool to make JSON APIs become RESTful (because it's self-documenting).

I also use them for validation and sanity checking, like an assert() call:
It's not something that should ever trip, but it's there in case the
impossible happens (but that would never happen, right?).

I agree with your opinion it's troubling, though. Unfortunately it's hard
to strike a balance between making something that's easy to compose and
easy to read, versus something that's expressive and gives you exactly the
right error message.

I'd love to talk how to fix this problem, though!

It seems like this problem is closely tied with automatic UI generation.
How would I design a form to enter data of the kind that you're expecting?
Three separate forms? A master drop-down that automatically changes the
remaining fields and automatically populates the "Type" one? Move the
"Type" drop-down first, and change all the other fields if it changes? What
if I want to change the type of an entity from Vegetable to Plant? It seems
if we can answer these questions, we would also tackle your validation
errors problem for free.

Austin.

On Mon, May 23, 2016 at 8:54 PM, Tim Bray <tbray@textuality.com> wrote:

> Hmm, I have to excerpt one line here:
>
> On Mon, May 23, 2016 at 6:30 PM, Austin William Wright <aaa@bzfx.net>
> wrote:
>
>>
>> In general, JSON Schema and many other schemas are designed to ensure
>> things are valid. They're not well engineered to help people fix things
>> when they're invalid.
>>
>
> ​I find this troubling.  I expect modern compilers to give me highly
> actionable errors, with line numbers. Is the nature of JSON DSL’s and
> programming languages so deeply different that this is not a reasonable
> thing to ask a schema processor to do?
>
> If so, then what are schemas for?  I’ve seen them as having two uses:
>
> 1. Specification aids
> 2. Debugging aids
>
> For #1, I see schemas as a poor second-best to clear human-readable
> description.
> For #2, Schemas are appealingly declarative and presumably much more
> compact than the equivalent declarative code.  But if they can’t tell me
> what the problem is, why bother?  And furthermore, I’ve never thought
> validators could rely on schemas alone, because schemas can’t check
> semantic constraints (“is that a valid part number?”)
>
>
>
>