Skip to content

Instantly share code, notes, and snippets.

@iscai-msft
Last active January 12, 2023 22:39
Show Gist options
  • Save iscai-msft/65b4dcc67b965f12361491294506ee20 to your computer and use it in GitHub Desktop.
Save iscai-msft/65b4dcc67b965f12361491294506ee20 to your computer and use it in GitHub Desktop.
op sum(one: int32, two: int32, three: "hello"): int32;
// cadl will give this to us as an anonymous model with two properties
// describes us as sending {"one": 12, "two": 32} over the wire
// pyhthon emitter: if it's anonymous model, don't generate model, just use JSON
// @overload
// def sum(self, body: JSON) # make this programatically positional only
// @overload
// def sum(self, *, one: int, two: int, three: typing.Literal["hello"] = "hello")
// def sum(self, *args, **kwargs)
// ANONYMOUS MODEL FOR PYTHON IS JUST JSON
model MyModel {
one: int32;
two: int32
}
op sum2(@body input: MyModel): int32;
// def sum2(self, input: MyModel)
op update(...MyModel): void; // JSON merge patch
op update2(body: MyModel): void; // not valid JSON merge patch cadl definition
// @overload
// def update(self, body: JSON) # make this programatically positional only
// @overload
// def update(self, *, one: int, two: int, content_type: str = "application/merge-patch+json")
// def update(self, *args, **kwargs)
alias MyModel2 = {
one: int32;
two: int32;
};
op sum3(...MyModel2): int32;
// @overload
// def sum3(self, body: JSON) # make this programatically positional only
// @overload
// def sum3(self, *, one: int, two: int)
// def sum3(self, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment