-
Notifications
You must be signed in to change notification settings - Fork 21
feat: twilio-python token pagination support #729
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
Changes from all commits
ae103b9
155ba71
d0a9955
5fe6646
1b12577
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,6 @@ | |
|
|
||
|
|
||
| public class TwilioPhpGenerator extends PhpClientCodegen { | ||
|
|
||
| ResourceCache2 resourceCache2 = new ResourceCache2(); | ||
| public static final String VALUES = "values"; | ||
| public static final String JSON_INGRESS = "json_ingress"; | ||
| private static final String PHP_CONVENTIONAL_MAP_PATH = "config/" + EnumConstants.Generator.TWILIO_PHP.getValue() + ".json"; | ||
|
|
@@ -55,8 +53,6 @@ protected ImmutableMap.Builder<String, Mustache.Lambda> addMustacheLambdas() { | |
|
|
||
| public TwilioPhpGenerator() { | ||
| super(); | ||
| ResourceCacheContext.clear(); | ||
| ResourceCacheContext.set(resourceCache2); // initialize the resource cache context to avoid null pointer exceptions | ||
| twilioCodegen = new TwilioCodegenAdapter(this, getName()); | ||
| } | ||
|
|
||
|
|
@@ -81,22 +77,13 @@ public void processOpts() { | |
| @Override | ||
| @SuppressWarnings("unchecked") | ||
| public void processOpenAPI(final OpenAPI openAPI) { | ||
| String apiStdVersion = null; | ||
| if (openAPI.getInfo().getExtensions() != null && openAPI.getInfo().getExtensions().containsKey("x-twilio")) { | ||
| Object xTwilioObj = openAPI.getInfo().getExtensions().get("x-twilio"); | ||
| if (xTwilioObj instanceof Map) { | ||
| Map<String, Object> xTwilio = (Map<String, Object>) xTwilioObj; | ||
| apiStdVersion = (String) xTwilio.get("apiStandards"); | ||
| } | ||
| } | ||
| boolean isV1 = ApplicationConstants.isV1.test(apiStdVersion); | ||
| ResourceCacheContext.get().setV1(isV1); | ||
|
|
||
| String domain = StringHelper.camelize(twilioCodegen.getDomainFromOpenAPI(openAPI)); | ||
| String version = StringHelper.camelize(twilioCodegen.getVersionFromOpenAPI(openAPI)); | ||
| twilioCodegen.setDomain(domain); | ||
| twilioCodegen.setVersion(version); | ||
| twilioCodegen.setOutputDir(domain, version); | ||
| twilioCodegen.setIsV1ApiStandard(openAPI); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This design looks much better to keep the resource cache code in adapter. Have you checked if this is present in all languages except java?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, we can support this in all generators |
||
| setSrcBasePath(""); | ||
|
|
||
| directoryStructureService.configureResourceFamily(openAPI); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -331,7 +331,7 @@ | |||||
| )] | ||||||
|
|
||||||
| def page(self, {{#allParams}} | ||||||
| {{#startsWith paramName text='page_size'}}{{else}}{{paramName}}: Union[{{{dataType}}}, object] = values.unset,{{/startsWith}}{{/allParams}} | ||||||
| {{#startsWith paramName text='page_size'}}{{else}}{{#startsWith paramName text='page_token'}}{{else}}{{paramName}}: Union[{{{dataType}}}, object] = values.unset,{{/startsWith}}{{/startsWith}}{{/allParams}} | ||||||
| page_token: Union[str, object] = values.unset, | ||||||
| page_number: Union[int, object] = values.unset, | ||||||
| page_size: Union[int, object] = values.unset, | ||||||
|
|
@@ -365,8 +365,9 @@ | |||||
| headers["Accept"] = "{{{mediaType}}}" | ||||||
| {{/vendorExtensions.successProduce}} | ||||||
|
|
||||||
| response = self._version.page(method='{{vendorExtensions.x-http-method}}', uri=self._uri, params=data, headers=headers) | ||||||
| return {{apiName}}Page(self._version, response{{#if listPathParams}}, self._solution{{/if}}) | ||||||
| response = self._version.page(method='{{vendorExtensions.x-http-method}}', uri=self._uri, params=data, headers=headers){{#isApiV1}} | ||||||
| return {{apiName}}Page(self._version, response, uri=self._uri{{#if listPathParams}}, self._solution{{/if}}){{/isApiV1}}{{^isApiV1}} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think the only difference is that we are passing the url as well when it's token pagination right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||||||
| return {{apiName}}Page(self._version, response{{#if listPathParams}}, self._solution{{/if}}){{/isApiV1}} | ||||||
|
|
||||||
| async def page_async(self, {{#allParams}} | ||||||
| {{#startsWith paramName text='page_size'}}{{else}}{{paramName}}: Union[{{{dataType}}}, object] = values.unset,{{/startsWith}}{{/allParams}} | ||||||
|
||||||
| {{#startsWith paramName text='page_size'}}{{else}}{{paramName}}: Union[{{{dataType}}}, object] = values.unset,{{/startsWith}}{{/allParams}} | |
| {{#startsWith paramName text='page_size'}}{{else}}{{#startsWith paramName text='page_token'}}{{else}}{{paramName}}: Union[{{{dataType}}}, object] = values.unset,{{/startsWith}}{{/startsWith}}{{/allParams}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an extra space before the opening parenthesis in the method name. It should be
setIsV1ApiStandard(final OpenAPI openAPI)instead ofsetIsV1ApiStandard (final OpenAPI openAPI).