Subject: [Cbor] CDDL: Multiple root files / file includes

From: Joachim Breitner <[email-masked]>
Date: Tue, 14 Apr 2020 11:53:17 +0200

Dear group,

I started playing around with CDDL, but I am facing a minor problem,
and would like to hear your advice:

I need to define multiple types (e.g. request and responses) that share
common definitions.

I currently begin my file with 

   ; This "root type" of this CDDL file is a hack: We want to define multiple
   ; types in one file (to shared common definitions), but CDDL requires a single
   ; root type. So we just list the types defined here:
   defined-here =
     request /
     response

but this is obviously a hack, and while good enough to use CDDL for
documentation, it will break certain tool usages.

I was expecting either a way to label multiple types as (named) root
types, and tools would allow me to select which type I want to
generate/validate/etc. Or a way to include other files, similar to the
implicitly included prelude, so that I can put common definitions in
common.cddl and then have indeed a request.cddl and response.cddl
import that file.

But maybe there is yet another way? How do you solve this issue?

Cheers,
Joachim

-- 
Joachim Breitner
  [email-masked]
  http://www.joachim-breitner.de/

---

From: Carsten Bormann <[email-masked]>
Date: Tue, 14 Apr 2020 12:53:10 +0200

Hi Joachim,

>     response

That is pretty much what all CDDL users do.

E.g., see RFC 8152 section 1.3 near the end [1]:

   start = COSE_Messages / COSE_Key / COSE_KeySet / Internal_Types

I wouldn’t call it a “hack”, but rather an “idiom”…

Maybe we’ll add something like an export interface (and, more importantly, imports) in the next round of updating CDDL.  The CDDL freezer [2] contains some initial thoughts about this; it you could consider the requirements that you have in this space and post them here, that would help.

For now, the “start” idiom should work fine.

Grüße, Carsten

[1]: https://tools.ietf.org/html/rfc8152#section-1.3
[2]: https://tools.ietf.org/html/draft-bormann-cbor-cddl-freezer-03#section-7

---

From: Joachim Breitner <[email-masked]>
Date: Tue, 14 Apr 2020 13:01:54 +0200

Hi,

> For now, the “start” idiom should work fine.

thanks!

Cheers,
Joachim