Skip to content

Commit

Permalink
Read AllowReserved value (microsoft#4294)
Browse files Browse the repository at this point in the history
Fix Azure/autorest.csharp#4966

---------

Co-authored-by: Pan Shao <pashao@microsoft.com>
  • Loading branch information
2 people authored and sarangan12 committed Sep 16, 2024
1 parent 95325b2 commit 59dfc39
Show file tree
Hide file tree
Showing 27 changed files with 1,202 additions and 596 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { getExternalDocs, getOperationId } from "./decorators.js";
import { fromSdkHttpExamples } from "./example-converter.js";
import { Logger } from "./logger.js";
import { getInputType } from "./model.js";
import { isSdkPathParameter } from "./utils.js";

export function fromSdkServiceMethod(
method: SdkServiceMethod<SdkHttpOperation>,
Expand Down Expand Up @@ -207,6 +208,7 @@ function fromSdkHttpOperationParameter(
Kind: getParameterKind(p, parameterType, rootApiVersions.length > 0),
DefaultValue: getParameterDefaultValue(p.clientDefaultValue, parameterType),
Decorators: p.decorators,
SkipUrlEncoding: isSdkPathParameter(p) ? p.allowReserved : false,
} as InputParameter;
}

Expand Down
8 changes: 8 additions & 0 deletions packages/http-client-csharp/emitter/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {
SdkContext,
SdkModelPropertyTypeBase,
SdkPathParameter,
getLibraryName,
getSdkModel,
} from "@azure-tools/typespec-client-generator-core";
Expand Down Expand Up @@ -72,3 +74,9 @@ export function createContentTypeOrAcceptParameter(
: undefined,
};
}

export function isSdkPathParameter(
parameter: SdkModelPropertyTypeBase
): parameter is SdkPathParameter {
return (parameter as SdkPathParameter).kind === "path";
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down Expand Up @@ -339,7 +340,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
},
{
"$id": "39",
Expand All @@ -355,7 +357,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down Expand Up @@ -416,7 +419,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
},
{
"$id": "45",
Expand All @@ -432,7 +436,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down Expand Up @@ -493,7 +498,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
},
{
"$id": "51",
Expand All @@ -509,7 +515,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down Expand Up @@ -563,7 +570,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down Expand Up @@ -707,7 +715,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
},
{
"$id": "71",
Expand All @@ -723,7 +732,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down Expand Up @@ -784,7 +794,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
},
{
"$id": "77",
Expand All @@ -800,7 +811,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down Expand Up @@ -904,7 +916,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
},
{
"$id": "89",
Expand All @@ -920,7 +933,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down Expand Up @@ -981,7 +995,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Constant",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
},
{
"$id": "95",
Expand All @@ -997,7 +1012,8 @@
"Explode": false,
"IsRequired": true,
"Kind": "Method",
"Decorators": []
"Decorators": [],
"SkipUrlEncoding": false
}
],
"Responses": [
Expand Down
Loading

0 comments on commit 59dfc39

Please sign in to comment.