Skip to content

Commit

Permalink
Skip literal path parameters in the fake servers (#999)
Browse files Browse the repository at this point in the history
Literal path parameters are embedded constant values so they're never
passed as an explicit parameter and can be omitted.
  • Loading branch information
jhendrixMSFT authored Jul 24, 2023
1 parent adb0baa commit 5e5df43
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 124 deletions.
4 changes: 3 additions & 1 deletion packages/autorest.go/src/generator/fake/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ function getMediaTypeForMultiRespOperation(op: Operation): string {
}

function dispatchForOperationBody(clientPkg: string, receiverName: string, op: Operation, imports: ImportManager): string {
const numPathParams = values(op.parameters).where((each: Parameter) => { return each.protocol.http?.in === 'path'; }).count();
// M4 models literal parameters as required === true with a type of Constant.
// since these are directly embedded in the generated code, they aren't passed as parameters so skip those
const numPathParams = values(op.parameters).where((each: Parameter) => { return each.protocol.http?.in === 'path' && !(each.required && each.schema.type === SchemaType.Constant); }).count();
let content = '';
if (numPathParams > 0) {
imports.add('regexp');
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 0 additions & 102 deletions packages/autorest.go/test/autorest/urlgroup/fake/zz_paths_server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5e5df43

Please sign in to comment.