digital-asset / lib-message-integration

Apache License 2.0
2 stars 1 forks source link

Handle`$ref`s in parameters and responses (Swagger) #7

Open lJoublanc opened 4 years ago

lJoublanc commented 4 years ago

Currently this is undefined.

lucianojoublanc-da commented 4 years ago

This now works when the dereferenced parameters are simple types, see e49736f1594cc6b7b9643d3fd505397f874150ef. Type aliases are created for them.

However, the case where the parameter is of optional or array type can't be handled. This is because the top-level types are defined as:

-- | Top-level declaration with optional field annotations.
data Decl a
    = EnumType      Name [(Name, a, Comment)] Comment
    | RecordType    Name [Field a] Comment
    | VariantType   Name [Field a] Comment
    | NewType       Name (Type a) Comment
    | TemplateType   Name [Field a] Signatory Comment
    | InlineComment String
    deriving (Eq, Show)

And so the type alias (NewType), must refer to an existing type, which in practice must be either dataor a primitive type.

We could 'cheat' by passing in a Nominal $ case cardinality of optional -> "Maybe " <> printType t or something like that ... but it's really messy.