Skip to content
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

[Mgmt]Build enums from code model converter #4576

Draft
wants to merge 3 commits into
base: feature/v3
Choose a base branch
from

Conversation

pshao25
Copy link
Member

@pshao25 pshao25 commented Apr 15, 2024

This PR is to gradually support code model conversion to input types with several PRs, instead of a huge PR at one time.

Current behavior:
We have

  1. Different kinds of schemas in code model. (and operations)
  2. Constructors for these schemas as public TypeProvider(Schema schem){}

Final goal:
We want:

  1. Schame mapping to input type pseudo as InputType inputType = CodeModelConverter.From(schema).
  2. Constructors for these input types as public TypeProvider(InputType inputType){}

Solution:
We could support one kind of schema/input type pair at one time. For example, in this PR, it supports ChoiceSchema/InputEnumType. Therefore this PR would introduce (which actually already exists):

  1. InputEnumType inputType = CodeModelConverter.From(ChoiceSchema/SealedChoiceSchema).
  2. public EnumType(InputEnumType inputType){}

To support one type at one time, we might need to expose CodeModelConverter and the mappings it builds temporarily as what this PR did. In the transition period,

  1. CodeModelConverter is exposed all the time.
  2. We get type from input types if we support.
  3. We get type from code model if we not support.

After we convert all the types to input types, we remove all the exposed things from CodeModelConverter.

CodeModelTransformer.TransformForMgmt(codeModel);
MgmtContext.Initialize(new BuildContext<MgmtOutputLibrary>(codeModel, sourceInputModel, schemaUsageProvider));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think before we go any further, we should remove this MgmtContext first to make everything explicit.
Also we should remove BuildContext.

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.

None yet

2 participants