idealingua-v1 icon indicating copy to clipboard operation
idealingua-v1 copied to clipboard

API descriptor generator

Open pshirshov opened this issue 7 years ago • 2 comments

We may implement a tool converting a JSON into a set of model drafts.

This API call:

{
  "personalizations": [
    {
      "to": [
        {
          "email": "[email protected]",
          "name": "John Doe"
        }
      ],
      "subject": "Hello, World!"
    }
  ],
  "from": {
    "email": "[email protected]",
    "name": "Sam Smith"
  },
  "reply_to": {
    "email": "[email protected]",
    "name": "Sam Smith"
  }
}

may be translated into

data emailuser {
   email: str
   name: str
}

data emailData {
   to: list[emailuser]
   subject: str
}

data {
   personalizations: list[emailData]
   from: emailUser
   reply_to: emailUser
}

This may allow us to interoperate with simple REST data providers.

Also we may convert swagger and other popular formats into our models. Kinda related: 7mind/idealingua-v1#19

pshirshov avatar Jul 26 '18 13:07 pshirshov

@pshirshov How get should deal with follow input?

"from": {
    "email": "[email protected]",
    "name": "Sam Smith"
  },
  "reply_to": {
    "email": "[email protected]",
    "name": "Sam Smith"
    "extra_field" : "foo"    // new field!
  }

Either:

// One for both inputs
data emailUser {
    email : str
    name : str
    extraField : opt[str]
}

or

data emailUser {
    email : str
    name : str
}

data emailUserWithExtra {
    email : str
    name : str
    extraField : str
}

ratoshniuk avatar Sep 24 '18 06:09 ratoshniuk

I guess second one. From what I can see first one requires a complex and fragile heuristic.

pshirshov avatar Sep 24 '18 12:09 pshirshov