Re: [httpapi] Discussion about JSON payloads and code generation

Jason Desrosiers <jason@hyperjump.io> Sun, 17 January 2021 20:41 UTC

Return-Path: <jason@hyperjump.io>
X-Original-To: httpapi@ietfa.amsl.com
Delivered-To: httpapi@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 5824E3A1398 for <httpapi@ietfa.amsl.com>; Sun, 17 Jan 2021 12:41:04 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.698
X-Spam-Level:
X-Spam-Status: No, score=-1.698 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=neutral reason="invalid (public key: invalid data)" header.d=hyperjump.io
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 L8WPkRSidwuR for <httpapi@ietfa.amsl.com>; Sun, 17 Jan 2021 12:41:02 -0800 (PST)
Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) (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 4B7133A1397 for <httpapi@ietf.org>; Sun, 17 Jan 2021 12:41:02 -0800 (PST)
Received: by mail-oi1-x235.google.com with SMTP id d203so15717099oia.0 for <httpapi@ietf.org>; Sun, 17 Jan 2021 12:41:02 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hyperjump.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eYIhm4avrND7q4N+KE1jh9lC2gXi/rtOQW8QwEj70vc=; b=a5fO6t+Y/yu5tZQG44vqz6CbBNK9Av6WGcv4jgX2Exyvu+aZPPx4j20QpKP41CjqIh zE6juBzQ5ZmKugYUKDkFwuU8v859SCn3Su17CspxPqWVqrYUp2yTK+nM35TeJsvZpPaN PyZcaEUFLUcviqjGqum6UWMYwPaqn6kjXcYH3d4hSCD+tURNDzifU6hQNpf64W6e0hcp Hfz+7qn36wMoZh7amcGlkWi2Baa4aFzuMj6xB86xxy4xR7Uuzq46V6r/KJbBfmPyE0k3 WPPCUFF5thAXBG4KOI1gl0pYPohMjxGtwh2SD9Ebf8Coi9uTZAAdzWo0mHmaik9S2/E7 2ALg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eYIhm4avrND7q4N+KE1jh9lC2gXi/rtOQW8QwEj70vc=; b=cQjimOHgi9afbGn2E57OEpbp6pC89PwLjg1VNLEMBEni/YOrcbeXtl+OYk5fLyyWUj HfYmONMUvrsE8Rd2O3O9+GLqRVuygBZ9kInTFpGODJN5UFPJuDGL9NHordO5kZO+06j7 30f2Nhxdl3xWtRvKIJCMS0fxgPMzYmVQD8mJ0T8owGNW48lCLAeLV5ZcQUsNyTiz8rXf upMz+65dBLFOVNmzZoE7y9kNGm9LUH0L+skebKj5eRT1IVCrJOmr6Mbm2s58PbOYdlYk s8LtiSD0P0RsHKR61ZR1lMxji0i2Gkrg1dWDw1tbwKHpLwsuieL/3THBXFhSE7YkGK6t 0wyg==
X-Gm-Message-State: AOAM533hcBgS6CAgnyr5JnE9nZkBlCeahXaty5nful+180WZYTCYymn/ K78bjHVoGNaOqJ+Tk3JD7DeK1KzlBlV7Vu/miBhazQ==
X-Google-Smtp-Source: ABdhPJwgrUlCAnL91e9dH0yFsK9DjXsCcunqg1hPgRHNObK9oab7/04vtZe+4JTfIpd8QnyEBMUTzlQWBtE0t6ULD6s=
X-Received: by 2002:aca:bac3:: with SMTP id k186mr10887446oif.93.1610916061405; Sun, 17 Jan 2021 12:41:01 -0800 (PST)
MIME-Version: 1.0
References: <CALcRZn6-ojAAdJcMWFHef70Xp32O2iFatuw-YjGLKtr8VnbmYQ@mail.gmail.com> <DM6PR00MB0845824BE38945071F9774A5F0A69@DM6PR00MB0845.namprd00.prod.outlook.com> <CALcRZn6HdXE2WAn0vSod0XDY_yJd7jV7m5JnRWKWGDJaDaag-A@mail.gmail.com>
In-Reply-To: <CALcRZn6HdXE2WAn0vSod0XDY_yJd7jV7m5JnRWKWGDJaDaag-A@mail.gmail.com>
From: Jason Desrosiers <jason@hyperjump.io>
Date: Sun, 17 Jan 2021 12:40:50 -0800
Message-ID: <CANeun7tsmZ_M0ZYC_amLEpYaLrEFhs21j1ELm7BA6g6+ZSH_fQ@mail.gmail.com>
To: Christoph Kappestein <christoph.kappestein@gmail.com>
Cc: Darrel Miller <Darrel.Miller@microsoft.com>, "httpapi@ietf.org" <httpapi@ietf.org>
Content-Type: multipart/alternative; boundary="0000000000009a77bc05b91e9fb5"
Archived-At: <https://mailarchive.ietf.org/arch/msg/httpapi/4BZcY92enxwyRomhfehUNKBBIjM>
Subject: Re: [httpapi] Discussion about JSON payloads and code generation
X-BeenThere: httpapi@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Building Blocks for HTTP APIs <httpapi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/httpapi>, <mailto:httpapi-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/httpapi/>
List-Post: <mailto:httpapi@ietf.org>
List-Help: <mailto:httpapi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/httpapi>, <mailto:httpapi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 17 Jan 2021 20:41:04 -0000

Hi Christoph,

Even if/when OpenAPI allows you to use something other than JSON Schema, I
think you still have a serious problem. The problem with "do one thing and
do it well" in this case is that you end up with a lot of duplication. I
don't want to have to maintain separate and almost identical sets of
schemas for code generation, validation, documentation, etc. Ideally, you
would start with a simple and flexible core that other specifications can
build off of to progressively enhance the core. That's what we're trying to
enable with JSON Schema vocabularies.

I believe it's possible to define a JSON Schema vocabulary for code
generation that progressively enhances standard JSON Schema so only one
schema needs to be maintained. I say that with all due humility and
willingness to wrong. I have never attempted to implement a JSON Schema
based code generator, but I have written other tooling with this kind of
thing in mind. In our Github Issue, I'll share more details about how I
think the problems you identified could be solved without breaking JSON
Schema validation.

Full disclosure: I am a member of the JSON Schema core team, so I should be
considered even more biased than Darrel :-). But, even if you decide not to
align with JSON Schema, I'd be happy to share lessons we've learned from
developing JSON Schema that might apply to TypeSchema as well.

Jason Desrosiers

On Sun, Jan 17, 2021 at 3:46 AM Christoph Kappestein <
christoph.kappestein@gmail.com> wrote:

> Hi Darrel,
>
> Thank you for the feedback. I understand that it is not easy possible to
> change the schema specification but I had the hope that the OpenAPI spec
> will be in future versions more JSON schema independent. I.e. that a user
> could use XSD, JTD, Protobuf or any other specification to describe the
> request/response payload, also for payloads in the future which are not
> JSON. So that a user is not forced to use JSON schema and that an
> alternative could emerge.
>
> A core editor from the JSON schema spec has already approached me
> regarding a vocabulary, but from my point of view I think that those
> vocabularies inherit many properties from JSON schema which are not ideal
> for code generation. In the spirit of "do one thing and do it well" we
> could have different specifications for specific use cases, which would be
> a much more flexible framework than forcing every schema to be a
> vocabulary. A generator could then support only specific schema types. If I
> remember correctly the RAML specification solved this also in a similar
> way. This approach would be also great for the OpenAPI since they do not
> have to force a different schema spec but the users can decide which is the
> optimal solution.
>
> Thanks to the link of the API report, I was not aware of it and it looks
> really interesting. Regarding the OpenAPI spec, for me it would be really
> interesting to know whether there is such a plan to make the schema
> description part more JSON schema independent?
>
> best regards
> Christoph
>
>
> Am Sa., 16. Jan. 2021 um 23:12 Uhr schrieb Darrel Miller <
> Darrel.Miller@microsoft.com>:
>
>> Hi Christoph,
>>
>> *From:* httpapi <httpapi-bounces@ietf.org> on behalf of Christoph
>> Kappestein <christoph.kappestein@gmail.com>
>>
>> I would like to gauge whether there is some interest in discussing ways
>> to describe JSON payloads with a focus on code generation on this WG. Also
>> it would be interesting to gather feedback from other developers who have
>> experiences in this space.
>>
>>
>> As an editor of the OpenAPI spec, that relies heavily on JSON Schema,
>> consider my perspective to be heavily biased here. But I do agree
>> wholeheartedly that JSON Schema has challenges when it comes to describing
>> types for code generation.  However, I would be reluctant to go down a path
>> of defining a new specification for describing types.
>>
>> The recent Postman developer survey https://www.postman.com/state-of-api/ found
>> that in their 13,000 respondents, 75% of them claimed to be users of JSON
>> Schema.  Convincing developers to move to a different format is going to
>> require a compelling alternative.
>>
>> What would be awesome to see is if a community could form around creating
>> a new JSON Schema vocabulary that targets type description.  JSON Schema
>> itself is now defined by a set of vocabularies, one of which is the
>> validation vocabulary.  I know the JSON Schema core team have been looking
>> for someone to spearhead this effort.
>> https://github.com/json-schema-org/json-schema-vocabularies
>>
>> By taking this approach, the existing JSON Schema specifications and
>> artifacts can be leveraged, and the new type definition keywords could be
>> used alongside the validation keywords.
>>
>> Darrel
>>
>>
>> --
> httpapi mailing list
> httpapi@ietf.org
> https://www.ietf.org/mailman/listinfo/httpapi
>