-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: Organizations Api Uptake for twilio-csharp and support for bearer token/ no token authentication #595
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passed for 'twilio-oai-generator-java'Issues Measures |
@@ -62,6 +66,13 @@ public IApiResourceBuilder setImports(DirectoryStructureService directoryStructu | |||
metaAPIProperties.put("array-exists-options", true); | |||
} | |||
}); | |||
|
|||
if(this.authMethod == "BearerToken"){ | |||
metaAPIProperties.put("auth_method-bearer-token", true); |
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.
Authmethod can be basic and bearer token. We need to handle that as well.
@@ -62,6 +66,13 @@ public IApiResourceBuilder setImports(DirectoryStructureService directoryStructu | |||
metaAPIProperties.put("array-exists-options", true); | |||
} | |||
}); | |||
|
|||
if(this.authMethod == "BearerToken"){ |
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.
Store'BearerToken' in enum and refer from there
|
||
public void processAuthMethods(List<CodegenOperation> opList) { | ||
if(opList != null){ | ||
List<CodegenSecurity> authMethods = opList.get(0).authMethods; |
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.
We have to decide rest client on operation not on group of operations.
if(authMethods != null){ | ||
for(CodegenSecurity c : authMethods){ | ||
if(c.isOAuth == true){ | ||
this.authMethod = "BearerToken"; |
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.
public apis will have basic and token based authentication, We don't want to re-write this code again for OAuth for public APIs.
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.
If Oauth is added to public(Non Orgs) APIs, This code will break existing public APIs by modifying its rest client.
This code should not break existing written code if OAuth is added to public APIs.
@@ -175,7 +203,7 @@ public ApiResourceBuilder updateResponseModel(Resolver<CodegenProperty> codegenP | |||
modelName = response.baseType; | |||
} | |||
Optional<CodegenModel> responseModel = Utility.getModel(allModels, modelName, recordKey, codegenOperation); | |||
if (responseModel.isEmpty()) { | |||
if ((responseModel == null) || responseModel.isEmpty() || (Integer.parseInt(response.code) >= 400)) { |
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.
We discussed before that, all twilio APIs uses common exception models and Orgs API follows the same exception model.
Exception Model: https://www.twilio.com/docs/usage/twilios-response#response-formats-exceptions
(Athira has tested that this exception model is used by Orgs API as well)
So we can ignore all error models from generating.
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.
I will think about it and we can re-visit it later.
@@ -118,7 +118,7 @@ public Optional<CodegenModel> getModel(final List<CodegenModel> models, | |||
.map(CodegenProperty::getComplexType) | |||
.map(classname -> getModelByClassname(models, classname)) | |||
.findFirst() | |||
.orElseThrow(); | |||
.orElse(null); |
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.
Why we are changing to orElse(null) ?
? Utility.removeEnumName(property.complexType) + ApplicationConstants.ENUM | ||
if(property.complexType != null){ | ||
property.enumName = property.complexType.contains("Enum") || property.complexType.contains("enum") | ||
? Utility.removeEnumName(property.complexType) + ApplicationConstants.ENUM |
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.
Check if it is not breaking existing code.
Also test if an Enum defined as referenced and is used at multiple places as a property or property and parameter.
For Example:
Enum is defined under component.schema
component.schema.UpdateStatusEnum
And above enum is referenced at 2 or more places.
{ | ||
client = client ?? TwilioClient.GetRestClient(); | ||
client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); |
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.
Use similar to {{clientName}}
|
||
var request = new Request( | ||
var request = new {{requestName}}Request( |
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.
Do we need to have different request model ?
What if we use AuthStrategy class as discussed.
AuthStrategy can have child classes which will handle different types of Authentication mechanism
For Example
BasicAuthStrategy, TokenAuthStrategy, NoAuthStrategy.
Quality Gate passed for 'twilio-oai-generator-java'Issues Measures |
Fixes
A short description of what this PR does.
Checklist
make test-docker
python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go
and inspect the diffmake test
intwilio-go
twilio-go
If you have questions, please create a GitHub Issue in this repository.