remove error response except default (#1295)
This commit is contained in:
Родитель
77e0e7ce05
Коммит
b0bb844d05
|
@ -205,7 +205,7 @@ export /* @internal */ class Inferrer {
|
|||
const hasQueryParameter = getOperation?.parameters?.find(p => p.protocol.http?.in === 'query' && p.language.default.name !== 'apiVersion');
|
||||
//parameter.protocal.http.in === 'body' probably only applies to open api 2.0
|
||||
const schema = putOperation?.requests?.[0]?.parameters?.find(p => p.protocol.http?.in === 'body')?.schema;
|
||||
if (getOperation && !hasQueryParameter && schema && [...values(getOperation?.responses), ...values(getOperation?.exceptions)].filter(each => each.protocol?.http?.statusCodes[0] !== 'default' && (<SchemaResponse>each).schema !== schema).length === 0) {
|
||||
if (getOperation && !hasQueryParameter && schema && [...values(getOperation?.responses)].filter(each => (<SchemaResponse>each).schema !== schema).length === 0) {
|
||||
await this.addVariants(putOperation.parameters, putOperation, this.createCommandVariant('create', [operationGroup.$key], [], this.state.model), '', this.state, [getOperation], CommandType.GetPut);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,11 +27,22 @@ async function tweakModel(state: State): Promise<PwshModel> {
|
|||
|
||||
removeM4DefaultDescription(model);
|
||||
|
||||
removeExceptionResponse(model);
|
||||
|
||||
handleNoinlineDirective(state);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
//remove error responses except default
|
||||
function removeExceptionResponse(model: CodeModel) {
|
||||
model.operationGroups.forEach(group => {
|
||||
group.operations?.forEach(operation => {
|
||||
operation.exceptions = operation.exceptions?.filter(exception => exception.protocol.http?.statusCodes[0] === 'default');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//sort path parameters to follow the order in path for each operation
|
||||
function sortParameters(model: CodeModel) {
|
||||
model.operationGroups.forEach(group => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче