Open chunyu3 opened 2 months ago
FYI: For now, emitters could use the following way to judge it
function isSpreadBody(bodyParam: SdkBodyParameter | undefined): boolean { return bodyParam?.type.kind === "model" && bodyParam.type !== bodyParam.correspondingMethodParams[0]?.type;}
Another concern I have for spread usage of model is: for emitters, we have to translate model usage into "input" or "output", "spread" usage on model is not useful. So I would agree to put the spread usage into body parameter.
FYI: For now, emitters could use the following way to judge it
function isSpreadBody(bodyParam: SdkBodyParameter | undefined): boolean { return bodyParam?.type.kind === "model" && bodyParam.type !== bodyParam.correspondingMethodParams[0]?.type;}
This is a non-safe workaround. considering that the model which contains a property with its own type(circle model). Yes. it is a workaround to unblock us. But eventually we need to add a flag spread
to body parameter
With current design, the usage in model is just used to identify whether emitter need to generate this model. If a model is used both in spread and non-spread case, you need to use correspondingMethodParams
to identify if the body parameter is spread or not.
When an operation's body parameter is spread, the Usage of the body parameter model will append
Usage
. Butspread
is a meta-data of a body parameter, because a model can be used in more than one operations, and not all operations will spread the body.e.g.
The body of
op2
will be spread by mistake.solution: tag
spread
in theSdkHttpParameter
instead of body model type Usage