op (one: int32, two: int32): void;
Send JSON:
{"one": 12, "two": 47}
Python:
@overload
def sum(self, body: JSON) # make this programatically positional only
@overload
def sum(self, *, one: int, two: int)
def sum(self, *args, **kwargs)
alias MyModel = {
one: int32;
two: int32;
}
op (...MyModel): void;
Send JSON:
{"one": 12, "two": 47}
Python:
@overload
def sum(self, body: JSON) # make this programatically positional only
@overload
def sum(self, *, one: int, two: int)
def sum(self, *args, **kwargs)
Syntax 2 is the same compiled CADL than Syntax 1
model MyModel {
one: int32;
two: int32;
}
op (...MyModel): void;
Send JSON:
{"one": 12, "two": 47}
Python:
def sum(self, body: Union[JSON, MyModel])
model MyModel {
one: int32;
two: int32;
}
op (my_model: MyModel): void;
Send JSON:
{"my_model": {"one": 12, "two": 47}}
Python:
# Don't need to solve this for now
# This is bad practice (anonymous class as input) and will be flagged in review
model MyModel {
one: int32;
two: int32;
}
op (@body my_model: MyModel): void;
Send JSON:
{"one": 12, "two": 47}
Python:
def sum(self, body: Union[JSON, MyModel])
python api: https://gist.github.com/iscai-msft/65b4dcc67b965f12361491294506ee20