Skip to content

codegen.go: support seeding pager with initial nextLink #1502

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions packages/autorest.go/src/m4togocodemodel/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ function adaptMethodParameter(op: m4.Operation, param: m4.Parameter): go.Paramet
// this is a synthesized parameter (e.g. ResumeToken)
if (param.language.go!.isResumeToken) {
adaptedParam = new go.ResumeTokenParameter();
} else if (param.language.go!.isNextLink) {
adaptedParam = new go.NextLinkParameter();
} else {
const type = adaptPossibleType(param.schema);
const placement = adaptParameterKind(param);
Expand Down
11 changes: 11 additions & 0 deletions packages/autorest.go/src/transform/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,17 @@ async function processOperationRequests(session: Session<m4.CodeModel>) {
op.parameters?.push(tokenParam);
tokenParam.language.go!.paramGroup = op.language.go!.optionalParamGroup;
(<m4.GroupProperty>op.language.go!.optionalParamGroup).originalParameter.push(tokenParam);
} else if (helpers.isPageableOperation(op)) {
// add the NextLink to the optional params type
const nextLinkParam = newParameter('NextLink', '', newString('string', ''));
nextLinkParam.language.go!.byValue = true;
nextLinkParam.language.go!.isNextLink = true;
nextLinkParam.required = false;
op.parameters?.push(nextLinkParam);
nextLinkParam.language.go!.paramGroup = op.language.go!.optionalParamGroup;
if (<m4.GroupProperty>op.language.go!.optionalParamGroup) { // TODO: why is this sometimes unset?
(<m4.GroupProperty>op.language.go!.optionalParamGroup).originalParameter.push(nextLinkParam);
}
}
// recursively add the marshalling format to the body param if applicable
const marshallingFormat = getMarshallingFormat(op.requests![0].protocol);
Expand Down

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

9 changes: 9 additions & 0 deletions packages/autorest.go/test/acr/azacr/zz_options.go

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

66 changes: 49 additions & 17 deletions packages/autorest.go/test/autorest/paginggroup/zz_options.go

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

Loading
Loading