Skip to content

[WIP] flatten JSONModelType body properties as operation parameters #1623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 6, 2023

Conversation

changlong-liu
Copy link
Member

@changlong-liu changlong-liu commented Dec 16, 2022

For cadl:

alias MyModel = {
   one: int32;
   two: int32;
}

op sum(...MyModel): void;

Generate as:

@overload
def sum(self, body: JSON)

@overload
def sum(self, *, one: int, two: int)

def sum(self, body: JSON, *, one: int, two: int)

The alias parameter in OpenAI cadl https://github.com/changlong-liu/autorest.python/blob/20221216-openai-flatten/packages/cadl-python/OpenAI.Inference/models/embeddings.create.cadl#L8-L23 is generated as JSON body+ flattened properties: https://github.com/changlong-liu/autorest.python/blob/20221216-openai-flatten/packages/cadl-python/cadl-output/azure/openai/_operations/_operations.py#L107-L241

@msyyc msyyc marked this pull request as ready for review December 19, 2022 06:45
@iscai-msft
Copy link
Contributor

@changlong-liu i think this looks ok, can you show me what it generates in OpenAI before I merge? Thanks!

@changlong-liu
Copy link
Member Author

@changlong-liu i think this looks ok, can you show me what it generates in OpenAI before I merge? Thanks!

Thanks @iscai-msft for review, generated code for OpenAI.Inference are uploaded at https://github.com/changlong-liu/autorest.python/tree/20221216-openai-flatten/packages/cadl-python/cadl-output/azure/openai, and the part related to this PR is at https://github.com/changlong-liu/autorest.python/blob/20221216-openai-flatten/packages/cadl-python/cadl-output/azure/openai/_operations/_operations.py#L107-L241

@iscai-msft iscai-msft merged commit dbc7dfa into autorestv3 Jan 6, 2023
@iscai-msft iscai-msft deleted the 20221216-flatten-json-model branch January 6, 2023 18:21
iscai-msft added a commit that referenced this pull request Jan 6, 2023
…into update_cadl

* 'autorestv3' of https://github.com/Azure/autorest.python:
  Update CHANGELOG.md
  Update package.json
  Update ChangeLog.md
  use """ pair presenting enum item docs (#1655)
  [WIP] flatten JSONModelType body properties as operation parameters (#1623)
  [cadl-python] fix import and _vendor.py for subclient (#1649)
@changlong-liu changlong-liu linked an issue Jan 10, 2023 that may be closed by this pull request
iscai-msft added a commit that referenced this pull request Mar 10, 2023
…into cadl_ranch_branch

* 'autorestv3' of https://github.com/Azure/autorest.python: (53 commits)
  Fix publish (#1667)
  pip dev(deps-dev): bump pylint in /packages/autorest.python (#1664)
  Update package.json
  Update ChangeLog.md
  Update package.json
  Update CHANGELOG.md
  fix emitter for ADP (#1659)
  pip dev(deps-dev): bump pyright from 1.1.274 to 1.1.287 in /packages/autorest.python (#1653)
  have pipelines fail on regeneration failure (#1663)
  clean up cadl code with tim (#1657)
  Update CHANGELOG.md
  Update package.json
  Update ChangeLog.md
  use """ pair presenting enum item docs (#1655)
  [WIP] flatten JSONModelType body properties as operation parameters (#1623)
  [cadl-python] fix import and _vendor.py for subclient (#1649)
  pip prod(deps): bump m2r2 from 0.3.2 to 0.3.3 in /packages/autorest.python (#1644)
  pip prod(deps): bump platformdirs in /packages/autorest.python (#1641)
  pip prod(deps): bump pathspec in /packages/autorest.python (#1642)
  pip prod(deps): bump json-rpc in /packages/autorest.python (#1638)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generate cadl operations with spread alias model
4 participants