[TT-11439/TT-11452] fix custom plugins contract#6097
Conversation
|
API Changes --- prev.txt 2024-03-07 10:50:44.592306817 +0000
+++ current.txt 2024-03-07 10:50:41.840304413 +0000
@@ -2783,10 +2783,10 @@
type CustomPlugins []CustomPlugin
CustomPlugins is a list of CustomPlugin objects.
-func (c CustomPlugins) ExtractTo(mwDefs []apidef.MiddlewareDefinition)
+func (c *CustomPlugins) ExtractTo(mwDefs []apidef.MiddlewareDefinition)
ExtractTo extracts CustomPlugins into supplied Middleware definitions.
-func (c CustomPlugins) Fill(mwDefs []apidef.MiddlewareDefinition)
+func (c *CustomPlugins) Fill(mwDefs []apidef.MiddlewareDefinition)
Fill fills CustomPlugins from supplied Middleware definitions.
type DetailedActivityLogs struct {
@@ -2950,21 +2950,37 @@
CORS *CORS `bson:"cors,omitempty" json:"cors,omitempty"`
// PrePlugin contains configuration related to the custom plugin that is run before authentication.
- // Tyk classic API definition: `custom_middleware.pre`.
+ // Deprecated: Use PrePlugins instead.
PrePlugin *PrePlugin `bson:"prePlugin,omitempty" json:"prePlugin,omitempty"`
+ // PrePlugins contains configuration related to the custom plugin that is run before authentication.
+ // Tyk classic API definition: `custom_middleware.pre`.
+ PrePlugins CustomPlugins `bson:"prePlugins,omitempty" json:"prePlugins,omitempty"`
+
// PostAuthenticationPlugin contains configuration related to the custom plugin that is run immediately after authentication.
- // Tyk classic API definition: `custom_middleware.post_key_auth`.
+ // Deprecated: Use PostAuthenticationPlugins instead.
PostAuthenticationPlugin *PostAuthenticationPlugin `bson:"postAuthenticationPlugin,omitempty" json:"postAuthenticationPlugin,omitempty"`
+ // PostAuthenticationPlugin contains configuration related to the custom plugin that is run immediately after authentication.
+ // Tyk classic API definition: `custom_middleware.post_key_auth`.
+ PostAuthenticationPlugins CustomPlugins `bson:"postAuthenticationPlugins,omitempty" json:"postAuthenticationPlugins,omitempty"`
+
// PostPlugin contains configuration related to the custom plugin that is run immediately prior to proxying the request to the upstream.
- // Tyk classic API definition: `custom_middleware.post`.
+ // Deprecated: Use PostPlugins instead.
PostPlugin *PostPlugin `bson:"postPlugin,omitempty" json:"postPlugin,omitempty"`
- // ResponsePlugin contains configuration related to to the custom plugin that is run during processing of the response from the upstream service.
+ // PostPlugins contains configuration related to the custom plugin that is run immediately prior to proxying the request to the upstream.
+ // Tyk classic API definition: `custom_middleware.post`.
+ PostPlugins CustomPlugins `bson:"postPlugins,omitempty" json:"postPlugins,omitempty"`
+
+ // Deprecated: ResponsePlugin contains configuration related to the custom plugin that is run during processing of the response from the upstream service.
+ // Deprecated: Use ResponsePlugins instead.
+ ResponsePlugin *ResponsePlugin `bson:"responsePlugin,omitempty" json:"responsePlugin,omitempty"`
+
+ // ResponsePlugins contains configuration related to the custom plugin that is run during processing of the response from the upstream service.
//
// Tyk classic API definition: `custom_middleware.response`.
- ResponsePlugin *ResponsePlugin `bson:"responsePlugin,omitempty" json:"responsePlugin,omitempty"`
+ ResponsePlugins CustomPlugins `bson:"responsePlugins,omitempty" json:"responsePlugins,omitempty"`
// Cache contains the configurations related to caching.
// Tyk classic API definition: `cache_options`.
@@ -2986,6 +3002,13 @@
func (g *Global) Fill(api apidef.APIDefinition)
Fill fills *Global from apidef.APIDefinition.
+func (g *Global) MarshalJSON() ([]byte, error)
+ MarshalJSON is a custom JSON marshaler for the Global struct. It is
+ implemented to facilitate a smooth migration from deprecated fields that
+ were previously used to represent the same data. This custom marshaler
+ ensures backwards compatibility and proper handling of the deprecated fields
+ during the migration process.
+
type HMAC struct {
// Enabled activates the HMAC authentication mode.
// Tyk classic API definition: `enable_signature_checking`
@@ -3629,6 +3652,8 @@
func (p *PrePlugin) Fill(api apidef.APIDefinition)
Fill fills PrePlugin from supplied Tyk classic api definition.
+func (p *PrePlugin) Migrate() CustomPlugins
+
type Provider struct {
// Issuer contains a validation value for the issuer claim, usually a domain name e.g. `accounts.google.com` or similar.
Issuer string `bson:"issuer,omitempty" json:"issuer,omitempty"` |
|
PR Description updated to latest commit (c373caf) |
PR Review
Code feedback:
✨ Review tool usage guide:Overview: With a configuration file, use the following template:
See the review usage page for a comprehensive guide on using this tool. |
PR Code Suggestions
✨ Improve tool usage guide:Overview: With a configuration file, use the following template:
See the improve usage page for a more comprehensive guide on using this tool. |
7ccec2e to
2cf949a
Compare
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
|
API tests result - postgres15-sha256 env: success ✅ User descriptionDescriptionFix custom plugins contract in OAS API definition to remove unnecessary Related IssueParent: https://tyktech.atlassian.net/browse/TT-11439 Motivation and ContextAt the moment the Plugins configuration at API level follows this Same happens for: Having a Also all the plugin sections should be using plural: i.e How This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement, bug_fix Description
Changes walkthrough
|
|
API tests result - mongo44-sha256 env: success ✅ User descriptionDescriptionFix custom plugins contract in OAS API definition to remove unnecessary Related IssueParent: https://tyktech.atlassian.net/browse/TT-11439 Motivation and ContextAt the moment the Plugins configuration at API level follows this Same happens for: Having a Also all the plugin sections should be using plural: i.e How This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement, bug_fix Description
Changes walkthrough
|
d4a58ba to
11b6524
Compare
11b6524 to
9461289
Compare
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
1 similar comment
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
21d3185 to
5be5d4c
Compare
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
0628bdb to
8ea373c
Compare
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
6352467 to
d1390ae
Compare
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
|
|
/release to release-5.3 |
|
Working on it! Note that it can take a few minutes. |
|
/release to release-5.3.0 |
## **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description Fix custom plugins contract in OAS API definition to remove unnecessary nesting. ## Related Issue Parent: https://tyktech.atlassian.net/browse/TT-11439 Subtask: https://tyktech.atlassian.net/browse/TT-11452 ## Motivation and Context At the moment the Plugins configuration at API level follows this structure: ``` responsePlugin: plugins: - enabled: true functionName: ... ``` Same happens for: `responsePlugin`, `prePlugin`, `postPlugin`, `postAuthenticationPlugin` sections. Having a `plugins` subsection doesn’t make sense at this point as there aren’t multiple options, so this PR removes the `plugins` structure and use the array of plugins directly in the main section, like: ``` responsePlugins: - enabled true .... ``` Also all the plugin sections should be using plural: i.e `responsePlugins`, `prePlugins`, `postPlugins`, `postAuthenticationPlugins`. This PR adds these fields alongside maintaining `responsePlugin`, `prePlugin`, `postPlugin`, `postAuthenticationPlugin` with a deprecated note, for backwards compatibility. This also provides an opportunity to do the migration in memory without doing hard storage level migrations. ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ## **Type** enhancement, bug_fix ___ ## **Description** - Deprecated singular custom plugin configurations (`PrePlugin`, `PostAuthenticationPlugin`, `PostPlugin`, `ResponsePlugin`) in favor of plural forms (`PrePlugins`, `PostAuthenticationPlugins`, `PostPlugins`, `ResponsePlugins`) to remove unnecessary nesting and align with the structure of having multiple plugins directly under their respective sections. - Added new plural fields for custom plugins configuration, allowing for a more intuitive and streamlined configuration structure. - Updated `Fill` and `ExtractTo` methods in `middleware.go` to support both singular and plural plugin configurations, ensuring backward compatibility. - Introduced new schema definitions in `x-tyk-api-gateway.json` for the plural forms of custom plugins configurations and marked the singular forms as deprecated. - Added and updated tests in `middleware_test.go` and `oas_test.go` to validate the migration from singular to plural plugin configurations. ___ ## **Changes walkthrough** <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware.go</strong><dd><code>Refactor Custom Plugins Configuration to Support Plural Forms</code></dd></summary> <hr> apidef/oas/middleware.go <li>Deprecated <code>PrePlugin</code>, <code>PostAuthenticationPlugin</code>, <code>PostPlugin</code>, and <br><code>ResponsePlugin</code> in favor of plural forms.<br> <li> Added new plural fields <code>PrePlugins</code>, <code>PostAuthenticationPlugins</code>, <br><code>PostPlugins</code>, and <code>ResponsePlugins</code> for custom plugins configuration.<br> <li> Updated <code>Fill</code> and <code>ExtractTo</code> methods to support both singular and plural <br>plugin configurations. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+91/-51</a> </td> </tr> <tr> <td> <details> <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Schema Update to Support Plural Custom Plugins Configuration</code></dd></summary> <hr> apidef/oas/schema/x-tyk-api-gateway.json <li>Introduced new schema definitions for plural custom plugins <br>configurations.<br> <li> Deprecated singular custom plugin configurations in favor of plural <br>forms. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+20/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware_test.go</strong><dd><code>Add Tests for Plural Custom Plugins Configuration</code> </dd></summary> <hr> apidef/oas/middleware_test.go <li>Added tests to validate the migration from singular to plural plugin <br>configurations. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+46/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>oas_test.go</strong><dd><code>Update Tests to Support Plural Custom Plugins Configuration</code></dd></summary> <hr> apidef/oas/oas_test.go <li>Updated tests to reflect changes in custom plugins configuration from <br>singular to plural forms. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+28/-32</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > ✨ **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions (cherry picked from commit 4cddc45)
…ct (#6097) [TT-11439/TT-11452] fix custom plugins contract (#6097) ## **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description Fix custom plugins contract in OAS API definition to remove unnecessary nesting. ## Related Issue Parent: https://tyktech.atlassian.net/browse/TT-11439 Subtask: https://tyktech.atlassian.net/browse/TT-11452 ## Motivation and Context At the moment the Plugins configuration at API level follows this structure: ``` responsePlugin: plugins: - enabled: true functionName: ... ``` Same happens for: `responsePlugin`, `prePlugin`, `postPlugin`, `postAuthenticationPlugin` sections. Having a `plugins` subsection doesn’t make sense at this point as there aren’t multiple options, so this PR removes the `plugins` structure and use the array of plugins directly in the main section, like: ``` responsePlugins: - enabled true .... ``` Also all the plugin sections should be using plural: i.e `responsePlugins`, `prePlugins`, `postPlugins`, `postAuthenticationPlugins`. This PR adds these fields alongside maintaining `responsePlugin`, `prePlugin`, `postPlugin`, `postAuthenticationPlugin` with a deprecated note, for backwards compatibility. This also provides an opportunity to do the migration in memory without doing hard storage level migrations. ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ## **Type** enhancement, bug_fix ___ ## **Description** - Deprecated singular custom plugin configurations (`PrePlugin`, `PostAuthenticationPlugin`, `PostPlugin`, `ResponsePlugin`) in favor of plural forms (`PrePlugins`, `PostAuthenticationPlugins`, `PostPlugins`, `ResponsePlugins`) to remove unnecessary nesting and align with the structure of having multiple plugins directly under their respective sections. - Added new plural fields for custom plugins configuration, allowing for a more intuitive and streamlined configuration structure. - Updated `Fill` and `ExtractTo` methods in `middleware.go` to support both singular and plural plugin configurations, ensuring backward compatibility. - Introduced new schema definitions in `x-tyk-api-gateway.json` for the plural forms of custom plugins configurations and marked the singular forms as deprecated. - Added and updated tests in `middleware_test.go` and `oas_test.go` to validate the migration from singular to plural plugin configurations. ___ ## **Changes walkthrough** <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware.go</strong><dd><code>Refactor Custom Plugins Configuration to Support Plural Forms</code></dd></summary> <hr> apidef/oas/middleware.go <li>Deprecated <code>PrePlugin</code>, <code>PostAuthenticationPlugin</code>, <code>PostPlugin</code>, and <br><code>ResponsePlugin</code> in favor of plural forms.<br> <li> Added new plural fields <code>PrePlugins</code>, <code>PostAuthenticationPlugins</code>, <br><code>PostPlugins</code>, and <code>ResponsePlugins</code> for custom plugins configuration.<br> <li> Updated <code>Fill</code> and <code>ExtractTo</code> methods to support both singular and plural <br>plugin configurations. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+91/-51</a> </td> </tr> <tr> <td> <details> <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Schema Update to Support Plural Custom Plugins Configuration</code></dd></summary> <hr> apidef/oas/schema/x-tyk-api-gateway.json <li>Introduced new schema definitions for plural custom plugins <br>configurations.<br> <li> Deprecated singular custom plugin configurations in favor of plural <br>forms. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+20/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware_test.go</strong><dd><code>Add Tests for Plural Custom Plugins Configuration</code> </dd></summary> <hr> apidef/oas/middleware_test.go <li>Added tests to validate the migration from singular to plural plugin <br>configurations. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+46/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>oas_test.go</strong><dd><code>Update Tests to Support Plural Custom Plugins Configuration</code></dd></summary> <hr> apidef/oas/oas_test.go <li>Updated tests to reflect changes in custom plugins configuration from <br>singular to plural forms. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+28/-32</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > ✨ **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions
|
@jeffy-mathew Succesfully merged PR |
|
Working on it! Note that it can take a few minutes. |
## **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description Fix custom plugins contract in OAS API definition to remove unnecessary nesting. ## Related Issue Parent: https://tyktech.atlassian.net/browse/TT-11439 Subtask: https://tyktech.atlassian.net/browse/TT-11452 ## Motivation and Context At the moment the Plugins configuration at API level follows this structure: ``` responsePlugin: plugins: - enabled: true functionName: ... ``` Same happens for: `responsePlugin`, `prePlugin`, `postPlugin`, `postAuthenticationPlugin` sections. Having a `plugins` subsection doesn’t make sense at this point as there aren’t multiple options, so this PR removes the `plugins` structure and use the array of plugins directly in the main section, like: ``` responsePlugins: - enabled true .... ``` Also all the plugin sections should be using plural: i.e `responsePlugins`, `prePlugins`, `postPlugins`, `postAuthenticationPlugins`. This PR adds these fields alongside maintaining `responsePlugin`, `prePlugin`, `postPlugin`, `postAuthenticationPlugin` with a deprecated note, for backwards compatibility. This also provides an opportunity to do the migration in memory without doing hard storage level migrations. ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ## **Type** enhancement, bug_fix ___ ## **Description** - Deprecated singular custom plugin configurations (`PrePlugin`, `PostAuthenticationPlugin`, `PostPlugin`, `ResponsePlugin`) in favor of plural forms (`PrePlugins`, `PostAuthenticationPlugins`, `PostPlugins`, `ResponsePlugins`) to remove unnecessary nesting and align with the structure of having multiple plugins directly under their respective sections. - Added new plural fields for custom plugins configuration, allowing for a more intuitive and streamlined configuration structure. - Updated `Fill` and `ExtractTo` methods in `middleware.go` to support both singular and plural plugin configurations, ensuring backward compatibility. - Introduced new schema definitions in `x-tyk-api-gateway.json` for the plural forms of custom plugins configurations and marked the singular forms as deprecated. - Added and updated tests in `middleware_test.go` and `oas_test.go` to validate the migration from singular to plural plugin configurations. ___ ## **Changes walkthrough** <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware.go</strong><dd><code>Refactor Custom Plugins Configuration to Support Plural Forms</code></dd></summary> <hr> apidef/oas/middleware.go <li>Deprecated <code>PrePlugin</code>, <code>PostAuthenticationPlugin</code>, <code>PostPlugin</code>, and <br><code>ResponsePlugin</code> in favor of plural forms.<br> <li> Added new plural fields <code>PrePlugins</code>, <code>PostAuthenticationPlugins</code>, <br><code>PostPlugins</code>, and <code>ResponsePlugins</code> for custom plugins configuration.<br> <li> Updated <code>Fill</code> and <code>ExtractTo</code> methods to support both singular and plural <br>plugin configurations. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+91/-51</a> </td> </tr> <tr> <td> <details> <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Schema Update to Support Plural Custom Plugins Configuration</code></dd></summary> <hr> apidef/oas/schema/x-tyk-api-gateway.json <li>Introduced new schema definitions for plural custom plugins <br>configurations.<br> <li> Deprecated singular custom plugin configurations in favor of plural <br>forms. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+20/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware_test.go</strong><dd><code>Add Tests for Plural Custom Plugins Configuration</code> </dd></summary> <hr> apidef/oas/middleware_test.go <li>Added tests to validate the migration from singular to plural plugin <br>configurations. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+46/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>oas_test.go</strong><dd><code>Update Tests to Support Plural Custom Plugins Configuration</code></dd></summary> <hr> apidef/oas/oas_test.go <li>Updated tests to reflect changes in custom plugins configuration from <br>singular to plural forms. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+28/-32</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > ✨ **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions (cherry picked from commit 4cddc45)
…ract (#6097) [TT-11439/TT-11452] fix custom plugins contract (#6097) ## **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description Fix custom plugins contract in OAS API definition to remove unnecessary nesting. ## Related Issue Parent: https://tyktech.atlassian.net/browse/TT-11439 Subtask: https://tyktech.atlassian.net/browse/TT-11452 ## Motivation and Context At the moment the Plugins configuration at API level follows this structure: ``` responsePlugin: plugins: - enabled: true functionName: ... ``` Same happens for: `responsePlugin`, `prePlugin`, `postPlugin`, `postAuthenticationPlugin` sections. Having a `plugins` subsection doesn’t make sense at this point as there aren’t multiple options, so this PR removes the `plugins` structure and use the array of plugins directly in the main section, like: ``` responsePlugins: - enabled true .... ``` Also all the plugin sections should be using plural: i.e `responsePlugins`, `prePlugins`, `postPlugins`, `postAuthenticationPlugins`. This PR adds these fields alongside maintaining `responsePlugin`, `prePlugin`, `postPlugin`, `postAuthenticationPlugin` with a deprecated note, for backwards compatibility. This also provides an opportunity to do the migration in memory without doing hard storage level migrations. ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ## **Type** enhancement, bug_fix ___ ## **Description** - Deprecated singular custom plugin configurations (`PrePlugin`, `PostAuthenticationPlugin`, `PostPlugin`, `ResponsePlugin`) in favor of plural forms (`PrePlugins`, `PostAuthenticationPlugins`, `PostPlugins`, `ResponsePlugins`) to remove unnecessary nesting and align with the structure of having multiple plugins directly under their respective sections. - Added new plural fields for custom plugins configuration, allowing for a more intuitive and streamlined configuration structure. - Updated `Fill` and `ExtractTo` methods in `middleware.go` to support both singular and plural plugin configurations, ensuring backward compatibility. - Introduced new schema definitions in `x-tyk-api-gateway.json` for the plural forms of custom plugins configurations and marked the singular forms as deprecated. - Added and updated tests in `middleware_test.go` and `oas_test.go` to validate the migration from singular to plural plugin configurations. ___ ## **Changes walkthrough** <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware.go</strong><dd><code>Refactor Custom Plugins Configuration to Support Plural Forms</code></dd></summary> <hr> apidef/oas/middleware.go <li>Deprecated <code>PrePlugin</code>, <code>PostAuthenticationPlugin</code>, <code>PostPlugin</code>, and <br><code>ResponsePlugin</code> in favor of plural forms.<br> <li> Added new plural fields <code>PrePlugins</code>, <code>PostAuthenticationPlugins</code>, <br><code>PostPlugins</code>, and <code>ResponsePlugins</code> for custom plugins configuration.<br> <li> Updated <code>Fill</code> and <code>ExtractTo</code> methods to support both singular and plural <br>plugin configurations. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+91/-51</a> </td> </tr> <tr> <td> <details> <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Schema Update to Support Plural Custom Plugins Configuration</code></dd></summary> <hr> apidef/oas/schema/x-tyk-api-gateway.json <li>Introduced new schema definitions for plural custom plugins <br>configurations.<br> <li> Deprecated singular custom plugin configurations in favor of plural <br>forms. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+20/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware_test.go</strong><dd><code>Add Tests for Plural Custom Plugins Configuration</code> </dd></summary> <hr> apidef/oas/middleware_test.go <li>Added tests to validate the migration from singular to plural plugin <br>configurations. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+46/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>oas_test.go</strong><dd><code>Update Tests to Support Plural Custom Plugins Configuration</code></dd></summary> <hr> apidef/oas/oas_test.go <li>Updated tests to reflect changes in custom plugins configuration from <br>singular to plural forms. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6097/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+28/-32</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > ✨ **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions
|
@jeffy-mathew Succesfully merged PR |
|
API tests result - mongo44-murmur64 env: success ✅ User descriptionDescriptionFix custom plugins contract in OAS API definition to remove unnecessary Related IssueParent: https://tyktech.atlassian.net/browse/TT-11439 Motivation and ContextAt the moment the Plugins configuration at API level follows this Same happens for: Having a Also all the plugin sections should be using plural: i.e How This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement, bug_fix Description
Changes walkthrough
|
1 similar comment
|
API tests result - mongo44-murmur64 env: success ✅ User descriptionDescriptionFix custom plugins contract in OAS API definition to remove unnecessary Related IssueParent: https://tyktech.atlassian.net/browse/TT-11439 Motivation and ContextAt the moment the Plugins configuration at API level follows this Same happens for: Having a Also all the plugin sections should be using plural: i.e How This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement, bug_fix Description
Changes walkthrough
|
|
API tests result - postgres15-murmur64 env: success ✅ User descriptionDescriptionFix custom plugins contract in OAS API definition to remove unnecessary Related IssueParent: https://tyktech.atlassian.net/browse/TT-11439 Motivation and ContextAt the moment the Plugins configuration at API level follows this Same happens for: Having a Also all the plugin sections should be using plural: i.e How This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement, bug_fix Description
Changes walkthrough
|




User description
Description
Fix custom plugins contract in OAS API definition to remove unnecessary nesting.
Related Issue
Parent: https://tyktech.atlassian.net/browse/TT-11439
Subtask: https://tyktech.atlassian.net/browse/TT-11452
Motivation and Context
At the moment the Plugins configuration at API level follows this structure:
Same happens for:
responsePlugin,prePlugin,postPlugin,postAuthenticationPluginsections.Having a
pluginssubsection doesn’t make sense at this point as there aren’t multiple options, so this PR removes thepluginsstructure and use the array of plugins directly in the main section, like:Also all the plugin sections should be using plural: i.e
responsePlugins,prePlugins,postPlugins,postAuthenticationPlugins.This PR adds these fields alongside maintaining
responsePlugin,prePlugin,postPlugin,postAuthenticationPluginwith a deprecated note, for backwards compatibility. This also provides an opportunity to do the migration in memory without doing hard storage level migrations.How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
Type
enhancement, bug_fix
Description
PrePlugin,PostAuthenticationPlugin,PostPlugin,ResponsePlugin) in favor of plural forms (PrePlugins,PostAuthenticationPlugins,PostPlugins,ResponsePlugins) to remove unnecessary nesting and align with the structure of having multiple plugins directly under their respective sections.FillandExtractTomethods inmiddleware.goto support both singular and plural plugin configurations, ensuring backward compatibility.x-tyk-api-gateway.jsonfor the plural forms of custom plugins configurations and marked the singular forms as deprecated.middleware_test.goandoas_test.goto validate the migration from singular to plural plugin configurations.Changes walkthrough
middleware.go
Refactor Custom Plugins Configuration to Support Plural Formsapidef/oas/middleware.go
PrePlugin,PostAuthenticationPlugin,PostPlugin, andResponsePluginin favor of plural forms.PrePlugins,PostAuthenticationPlugins,PostPlugins, andResponsePluginsfor custom plugins configuration.FillandExtractTomethods to support both singular and pluralplugin configurations.
x-tyk-api-gateway.json
Schema Update to Support Plural Custom Plugins Configurationapidef/oas/schema/x-tyk-api-gateway.json
configurations.
forms.
middleware_test.go
Add Tests for Plural Custom Plugins Configurationapidef/oas/middleware_test.go
configurations.
oas_test.go
Update Tests to Support Plural Custom Plugins Configurationapidef/oas/oas_test.go
singular to plural forms.