Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 83EB0200D33 for ; Wed, 8 Nov 2017 11:01:48 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 82587160BE0; Wed, 8 Nov 2017 10:01:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A21C7160BDA for ; Wed, 8 Nov 2017 11:01:47 +0100 (CET) Received: (qmail 53599 invoked by uid 500); 8 Nov 2017 10:01:46 -0000 Mailing-List: contact dev-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list dev@brooklyn.apache.org Received: (qmail 53587 invoked by uid 99); 8 Nov 2017 10:01:46 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Nov 2017 10:01:46 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 820D4180780 for ; Wed, 8 Nov 2017 10:01:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.379 X-Spam-Level: ** X-Spam-Status: No, score=2.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=cloudsoftcorp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id mnKqXrogwd9s for ; Wed, 8 Nov 2017 10:01:42 +0000 (UTC) Received: from mail-qk0-f180.google.com (mail-qk0-f180.google.com [209.85.220.180]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 495635FD83 for ; Wed, 8 Nov 2017 10:01:42 +0000 (UTC) Received: by mail-qk0-f180.google.com with SMTP id 2so1754719qkg.13 for ; Wed, 08 Nov 2017 02:01:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudsoftcorp.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=9xLe04gzie8ED05yhD3e1po8SbK8B1DbC3jdmKSI50A=; b=KgKvbjzCjyAX5Nx8xAu+sjtjE63+dU+3nOE1GZSSva19rGqvYkXmUc/EjP3asVSlwQ xelVE8bMLGfAhgUjvboDtWsPFaOv2qJlwn6N6Uwe3qiiZLrCcwIvRT1Po+A1IAYsuMQZ Gfamyf7VY902oSrIbMBag2lnGi/qlUz7buef8= 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; bh=9xLe04gzie8ED05yhD3e1po8SbK8B1DbC3jdmKSI50A=; b=Rd2d5AQpZvgXxnG72ppa9hZI/7DvRRDeBZCDPewi0eJMo04C3MDp29Jjlq2d2Ani/O fOLJsAUGPFXrN14M85bshv6FakjeK5mcy7ExK6HXhJ5oomQCSV6B60ry8RgAJR0806Ep 4TDfajx4Wm5Ygszn+zEFnRqXk3P0zOq+ZYtOAQJqMeJ9ASjmRN+Mf3H4VExwO40vfeXn sYdTrD9hAyX2PAdE0MDdwLEB6WgSff3nWU0+t8VoCceveKt2/o1DLWsWqXweD6JYQxAk hOoro/omRFZuevasiDJ32C9VSpbFAReX6ndKj78pWhCozilQxlUDxlEmiCkIUmeSGzjS Iz4g== X-Gm-Message-State: AJaThX5CCDEOP64qvdJXlh99lMoj/Z9cqB1dDD5X2yqIK91oc5WJgeXZ hDi0lyG+tZrfJPJABUAF4+3mdX0VXARIPWbFLU6PdK7OmGjYsj+6VbHc0KEMbebXLOb1ialvUMe GlSnB7nY8QDq5dUYkJMMlnkskOvw= X-Google-Smtp-Source: ABhQp+QBueka3ZsFn/9F3ML48hkalQRNJJmZ/WSuwmhDLqPINO5MXGQ4bX5WvuIWKOuSCsRbGUvB5bFWUEqAEic9ofs= X-Received: by 10.55.177.129 with SMTP id a123mr2379439qkf.162.1510135296536; Wed, 08 Nov 2017 02:01:36 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Thomas Bouron Date: Wed, 08 Nov 2017 10:01:26 +0000 Message-ID: Subject: Re: Brooklyn REST API - omitting fields in JSON objects To: dev@brooklyn.apache.org Content-Type: multipart/alternative; boundary="94eb2c070cfae9cc14055d75c595" X-Legal-Virus-Advice: Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by Cloudsoft Corporation Limited in this regard and the recipient should carry out such virus and other checks as it considers appropriate. X-Legal-Confidentiality: This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. Cloudsoft Corporation Limited does not accept responsibility for changes made to this message after it was sent. X-Legal-Company-Info: Cloudsoft Corporation Limited. Registered in Scotland. Number: SC349230. Registered Office: 13 Dryden Place, Edinburgh, EH9 1RP. archived-at: Wed, 08 Nov 2017 10:01:48 -0000 --94eb2c070cfae9cc14055d75c595 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all. I'm not a fan of excluding fields from the JSON payload, if empty, for few reasons: 1. this is a breaking change for the UI and CLI which will be time consuming to fix (very fiddly to guard against this in JS for example) 2. this makes it harder to design clients, because you need to guard against the presence of those fields. The swagger page displays all fields leading the user/dev to think that they are always returned in the payload 3. I don't think it saves bandwidth to remove a `constraints: []` from the final JSON. If you want to have a smaller payload, I would much prefer to set a query string flag to restrict (or expand) the full body, something like `?summary=3Dtrue` =3D> returns only necessary information. Now, my comments apply for the API endpoints under /v1 only. I'm all in favour of break things with a v2 API though. Best. On Mon, 6 Nov 2017 at 15:17 Alex Heneveld wrote: > > Hi All- > > Until recently our REST API returned full records in most cases, > including often lots of empty lists and maps and sometimes nulls -- such > as `constraints: []` on all config keys. > > The widespread preference in REST / JSON community seems to be to omit > these unless there is a very good reason for having them, e.g. Google > JSON Style Guide [1]. > > Recently in replacing deprecated FasterXML annotations with newer ones > many fields were changed to be included only if NON_EMPTY, in line with > that preference, but this is technically a breaking change. And it's > not just technical, as there are a few places in UI code which assume > fields exist which now do break. These are easy to fix once they're > encountered at runtime but tedious to ensure no problems at design time. > > Thus we have two choices: > > * Yes, make this break now. This (v1.0) is probably the best time. > There is no efficient way to pass this through a deprecation cycle. Cost > is adding to release nodes and REST API client breakages and fixes. > * No, revert any `Include(NON_EMPTY)` annotations recently introduced to > be strict about backwards-compatibility here. Cost is restoring old > behaviour and bloat/ugliness in the API response objects. > > I have a preference for "Yes", roll-forward and tolerate some breakages > with the shift to 1.0. > > Best > Alex > > > [1] > > https://google.github.io/styleguide/jsoncstyleguide.xml#Empty/Null_Proper= ty_Values > > -- Thomas Bouron =E2=80=A2 Senior Software Engineer @ Cloudsoft Corporation = =E2=80=A2 https://cloudsoft.io/ Github: https://github.com/tbouron Twitter: https://twitter.com/eltibouron --94eb2c070cfae9cc14055d75c595--