-
Notifications
You must be signed in to change notification settings - Fork 16
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
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.
<!-- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below. Please format the PR title appropriately based on the type of change: <type>[!]: <description> Where <type> is one of: docs, chore, feat, fix, test, misc. Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature). **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.** Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! e.g. Fixes #1 Closes #2 --> # Fixes # In twilio-node, read operation does not handle required query params correctly, see [here](https://github.com/twilio/twilio-oai-generator/blob/main/src/main/resources/twilio-node/api-single.mustache#L139). Till now, the existing APIs do not have such use case, but now some APIs are trying to pass required query params. This needs to be supported in twilio-node. ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository.
# Fixes # In python, the instancePathParams were not being used to initialize response models in constructors. So removing those unused params.
<!-- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below. Please format the PR title appropriately based on the type of change: <type>[!]: <description> Where <type> is one of: docs, chore, feat, fix, test, misc. Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature). **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.** Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! e.g. Fixes #1 Closes #2 --> # Fixes # Removing local file paths ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository.
Removing run_openapi_generator from for loop which was causing too much delay with pipelines
…file as versionless (#606)
# Fixes # Added a null check for content_v1 file before removing it. ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository.
fixed contentType for twilio-java
Quality Gate passed for 'twilio-oai-generator-php'Issues Measures |
Quality Gate passed for 'twilio-oai-generator-java'Issues Measures |
Quality Gate passed for 'twilio-oai-generator-python'Issues Measures |
Quality Gate passed for 'twilio-oai-generator-node'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.