Skip to content

[TT-11439/TT-11452] fix custom plugins contract#6097

Merged
jeffy-mathew merged 13 commits into
masterfrom
fix/TT-11439/TT-11452/api-level-plugins-contract
Mar 7, 2024
Merged

[TT-11439/TT-11452] fix custom plugins contract#6097
jeffy-mathew merged 13 commits into
masterfrom
fix/TT-11439/TT-11452/api-level-plugins-contract

Conversation

@jeffy-mathew

@jeffy-mathew jeffy-mathew commented Mar 5, 2024

Copy link
Copy Markdown
Contributor

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:

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

Screenshots (if appropriate)

Types of changes

  • 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

  • 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

Relevant files
Enhancement
middleware.go
Refactor Custom Plugins Configuration to Support Plural Forms

apidef/oas/middleware.go

  • Deprecated PrePlugin, PostAuthenticationPlugin, PostPlugin, and
    ResponsePlugin in favor of plural forms.
  • Added new plural fields PrePlugins, PostAuthenticationPlugins,
    PostPlugins, and ResponsePlugins for custom plugins configuration.
  • Updated Fill and ExtractTo methods to support both singular and plural
    plugin configurations.
  • +91/-51 
    x-tyk-api-gateway.json
    Schema Update to Support Plural Custom Plugins Configuration

    apidef/oas/schema/x-tyk-api-gateway.json

  • Introduced new schema definitions for plural custom plugins
    configurations.
  • Deprecated singular custom plugin configurations in favor of plural
    forms.
  • +20/-0   
    Tests
    middleware_test.go
    Add Tests for Plural Custom Plugins Configuration               

    apidef/oas/middleware_test.go

  • Added tests to validate the migration from singular to plural plugin
    configurations.
  • +46/-0   
    oas_test.go
    Update Tests to Support Plural Custom Plugins Configuration

    apidef/oas/oas_test.go

  • Updated tests to reflect changes in custom plugins configuration from
    singular to plural forms.
  • +28/-32 

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    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"`

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    PR Description updated to latest commit (c373caf)

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    4, because the PR involves significant changes to the plugin configuration structure, including deprecation of existing fields and introduction of new ones. It requires careful review to ensure backward compatibility and correct functionality.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Possible Bug: The new plugin fields (PrePlugins, PostAuthenticationPlugins, PostPlugins, ResponsePlugins) are introduced alongside the deprecated ones, but there's no clear migration path or logic within the code to handle existing configurations. This might lead to issues where old configurations are not correctly migrated to the new structure.

    Backward Compatibility: The PR adds new fields and deprecates old ones for plugin configurations. While it maintains backward compatibility by keeping the old fields, there's a risk that existing integrations might not work as expected if they rely on the deprecated fields. Detailed testing is required to ensure that both old and new configurations work as expected.

    🔒 Security concerns

    No

    Code feedback:
    relevant fileapidef/oas/middleware.go
    suggestion      

    Consider implementing a migration function that automatically converts configurations using deprecated fields (PrePlugin, PostAuthenticationPlugin, PostPlugin, ResponsePlugin) to the new fields (PrePlugins, PostAuthenticationPlugins, PostPlugins, ResponsePlugins). This function should run during the API startup or configuration load phase to ensure all configurations are up-to-date. [important]

    relevant linePrePlugin *PrePlugin `bson:"prePlugin,omitempty" json:"prePlugin,omitempty"`

    relevant fileapidef/oas/middleware.go
    suggestion      

    Ensure that the deprecation of fields is clearly documented in the code comments and any user-facing documentation. Include instructions on how users should migrate their configurations to the new structure. This will help prevent confusion and support issues. [important]

    relevant line// Deprecated: Use PrePlugins instead.

    relevant fileapidef/oas/middleware_test.go
    suggestion      

    Add comprehensive tests for the new plugin configuration fields to verify that they work as expected in various scenarios. This should include tests for backward compatibility with the deprecated fields, ensuring that existing configurations are not broken. [important]

    relevant linet.Run("plugins", func(t *testing.T) {

    relevant fileapidef/oas/schema/x-tyk-api-gateway.json
    suggestion      

    Update the OpenAPI schema definition to mark the deprecated fields as such, and provide a description that guides users to the new fields. This will help users of the API definition to migrate to the new structure more easily. [medium]

    relevant line"prePlugin": {


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    

    With a configuration file, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Maintainability
    Rename the comment to match the variable name it describes.

    To avoid potential confusion and maintain consistency, consider renaming the second
    occurrence of PostAuthenticationPlugin to PostAuthenticationPlugins in the comment to
    accurately reflect the variable it describes.

    apidef/oas/middleware.go [65]

    -// PostAuthenticationPlugin contains configuration related to the custom plugin that is run immediately after authentication.
    +// PostAuthenticationPlugins contains configuration related to the custom plugin that is run immediately after authentication.
     
    Consider removing deprecated plugin fields in future versions.

    To improve code maintainability and avoid potential future errors, consider removing the
    deprecated PrePlugin, PostAuthenticationPlugin, PostPlugin, and ResponsePlugin fields and
    their associated logic in future versions, as they have been replaced by their plural
    counterparts.

    apidef/oas/middleware.go [55-79]

    -PrePlugin *PrePlugin `bson:"prePlugin,omitempty" json:"prePlugin,omitempty"`
    -PostAuthenticationPlugin *PostAuthenticationPlugin `bson:"postAuthenticationPlugin,omitempty" json:"postAuthenticationPlugin,omitempty"`
    -PostPlugin *PostPlugin `bson:"postPlugin,omitempty" json:"postPlugin,omitempty"`
    -ResponsePlugin *ResponsePlugin `bson:"responsePlugin,omitempty" json:"responsePlugin,omitempty"`
    +// Fields removed for future-proofing and simplification
     
    Best practice
    Use single line if statements for initializing plugin configurations.

    To ensure that the nil checks for plugin configurations are more concise and idiomatic,
    consider using a single line if statement where applicable, for instance, when
    initializing PrePlugins, PostAuthenticationPlugins, PostPlugins, and ResponsePlugins.

    apidef/oas/middleware.go [119-121]

    -if g.PrePlugins == nil {
    -    g.PrePlugins = make(CustomPlugins, len(api.CustomMiddleware.Pre))
    -    g.PrePlugins.Fill(api.CustomMiddleware.Pre)
    -}
    +if g.PrePlugins == nil { g.PrePlugins = make(CustomPlugins, len(api.CustomMiddleware.Pre)); g.PrePlugins.Fill(api.CustomMiddleware.Pre) }
     
    Possible issue
    Add synchronization to protect Global struct modifications.

    To avoid potential data races or unexpected behavior in concurrent environments, consider
    using a mutex or another synchronization mechanism when modifying the Global struct's
    fields within the Fill and ExtractTo methods.

    apidef/oas/middleware.go [125]

    +// Example with mutex
    +g.mutex.Lock()
     g.PrePlugins = nil
    +g.mutex.Unlock()
     
    Enhancement
    Add test cases for handling both deprecated and new plugin fields.

    To enhance the test coverage and ensure the deprecated fields are handled correctly,
    consider adding test cases that specifically verify the behavior when both the deprecated
    and the new plugin fields are populated, ensuring the new fields take precedence.

    apidef/oas/middleware_test.go [53]

    -pluginMW.ExtractTo(&convertedAPI)
    +// Additional test case for handling both deprecated and new plugin fields
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:

    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    

    With a configuration file, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    @jeffy-mathew
    jeffy-mathew force-pushed the fix/TT-11439/TT-11452/api-level-plugins-contract branch 2 times, most recently from 7ccec2e to 2cf949a Compare March 5, 2024 10:49
    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @buger

    buger commented Mar 5, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - postgres15-sha256 env: success
    Branch used: refs/heads/master
    Commit: 4cddc45 [TT-11439/TT-11452] fix custom plugins contract (#6097)

    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:

    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

    Screenshots (if appropriate)

    Types of changes

    • 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

    • 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

    Relevant files
    Enhancement
    middleware.go
    Refactor Custom Plugins Configuration to Support Plural Forms

    apidef/oas/middleware.go

  • Deprecated PrePlugin, PostAuthenticationPlugin, PostPlugin, and
    ResponsePlugin in favor of plural forms.
  • Added new plural fields PrePlugins, PostAuthenticationPlugins,
    PostPlugins, and ResponsePlugins for custom plugins configuration.
  • Updated Fill and ExtractTo methods to support both singular and plural
    plugin configurations.
  • +91/-51 
    x-tyk-api-gateway.json
    Schema Update to Support Plural Custom Plugins Configuration

    apidef/oas/schema/x-tyk-api-gateway.json

  • Introduced new schema definitions for plural custom plugins
    configurations.
  • Deprecated singular custom plugin configurations in favor of plural
    forms.
  • +20/-0   
    Tests
    middleware_test.go
    Add Tests for Plural Custom Plugins Configuration               

    apidef/oas/middleware_test.go

  • Added tests to validate the migration from singular to plural plugin
    configurations.
  • +46/-0   
    oas_test.go
    Update Tests to Support Plural Custom Plugins Configuration

    apidef/oas/oas_test.go

  • Updated tests to reflect changes in custom plugins configuration from
    singular to plural forms.
  • +28/-32 

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@jeffy-mathew)
    Execution page

    @buger

    buger commented Mar 5, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - mongo44-sha256 env: success
    Branch used: refs/heads/master
    Commit: 4cddc45 [TT-11439/TT-11452] fix custom plugins contract (#6097)

    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:

    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

    Screenshots (if appropriate)

    Types of changes

    • 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

    • 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

    Relevant files
    Enhancement
    middleware.go
    Refactor Custom Plugins Configuration to Support Plural Forms

    apidef/oas/middleware.go

  • Deprecated PrePlugin, PostAuthenticationPlugin, PostPlugin, and
    ResponsePlugin in favor of plural forms.
  • Added new plural fields PrePlugins, PostAuthenticationPlugins,
    PostPlugins, and ResponsePlugins for custom plugins configuration.
  • Updated Fill and ExtractTo methods to support both singular and plural
    plugin configurations.
  • +91/-51 
    x-tyk-api-gateway.json
    Schema Update to Support Plural Custom Plugins Configuration

    apidef/oas/schema/x-tyk-api-gateway.json

  • Introduced new schema definitions for plural custom plugins
    configurations.
  • Deprecated singular custom plugin configurations in favor of plural
    forms.
  • +20/-0   
    Tests
    middleware_test.go
    Add Tests for Plural Custom Plugins Configuration               

    apidef/oas/middleware_test.go

  • Added tests to validate the migration from singular to plural plugin
    configurations.
  • +46/-0   
    oas_test.go
    Update Tests to Support Plural Custom Plugins Configuration

    apidef/oas/oas_test.go

  • Updated tests to reflect changes in custom plugins configuration from
    singular to plural forms.
  • +28/-32 

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@jeffy-mathew)
    Execution page

    @jeffy-mathew
    jeffy-mathew force-pushed the fix/TT-11439/TT-11452/api-level-plugins-contract branch from d4a58ba to 11b6524 Compare March 5, 2024 14:23
    Comment thread apidef/oas/middleware.go
    Comment thread apidef/oas/middleware.go Outdated
    @jeffy-mathew
    jeffy-mathew force-pushed the fix/TT-11439/TT-11452/api-level-plugins-contract branch from 11b6524 to 9461289 Compare March 6, 2024 10:33
    @github-actions

    github-actions Bot commented Mar 6, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    1 similar comment
    @github-actions

    github-actions Bot commented Mar 6, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @jeffy-mathew
    jeffy-mathew force-pushed the fix/TT-11439/TT-11452/api-level-plugins-contract branch from 21d3185 to 5be5d4c Compare March 6, 2024 15:32
    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @jeffy-mathew
    jeffy-mathew removed the request for review from andyo-tyk March 7, 2024 10:21
    @jeffy-mathew
    jeffy-mathew force-pushed the fix/TT-11439/TT-11452/api-level-plugins-contract branch from 0628bdb to 8ea373c Compare March 7, 2024 10:21
    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @jeffy-mathew
    jeffy-mathew force-pushed the fix/TT-11439/TT-11452/api-level-plugins-contract branch from 6352467 to d1390ae Compare March 7, 2024 10:50
    @jeffy-mathew
    jeffy-mathew enabled auto-merge (squash) March 7, 2024 10:56
    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @sonarqubecloud

    sonarqubecloud Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    Quality Gate Failed Quality Gate failed

    Failed conditions
    C Reliability Rating on New Code (required ≥ A)

    See analysis details on SonarCloud

    Catch issues before they fail your Quality Gate with our IDE extension SonarLint

    @jeffy-mathew
    jeffy-mathew merged commit 4cddc45 into master Mar 7, 2024
    @jeffy-mathew
    jeffy-mathew deleted the fix/TT-11439/TT-11452/api-level-plugins-contract branch March 7, 2024 11:47
    @jeffy-mathew

    Copy link
    Copy Markdown
    Contributor Author

    /release to release-5.3

    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    Working on it! Note that it can take a few minutes.

    @jeffy-mathew

    Copy link
    Copy Markdown
    Contributor Author

    /release to release-5.3.0

    tykbot Bot pushed a commit that referenced this pull request Mar 7, 2024
    ## **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>&nbsp;
    </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>&nbsp;
    &nbsp; </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>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    </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)
    buger added a commit that referenced this pull request Mar 7, 2024
    …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>&nbsp;
    </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>&nbsp;
    &nbsp; </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>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    </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
    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    @jeffy-mathew Succesfully merged PR

    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    Working on it! Note that it can take a few minutes.

    tykbot Bot pushed a commit that referenced this pull request Mar 7, 2024
    ## **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>&nbsp;
    </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>&nbsp;
    &nbsp; </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>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    </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)
    buger added a commit that referenced this pull request Mar 7, 2024
    …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>&nbsp;
    </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>&nbsp;
    &nbsp; </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>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    </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
    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    @jeffy-mathew Succesfully merged PR

    @buger

    buger commented Mar 7, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - mongo44-murmur64 env: success
    Branch used: refs/heads/master
    Commit: 4cddc45 [TT-11439/TT-11452] fix custom plugins contract (#6097)

    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:

    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

    Screenshots (if appropriate)

    Types of changes

    • 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

    • 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

    Relevant files
    Enhancement
    middleware.go
    Refactor Custom Plugins Configuration to Support Plural Forms

    apidef/oas/middleware.go

  • Deprecated PrePlugin, PostAuthenticationPlugin, PostPlugin, and
    ResponsePlugin in favor of plural forms.
  • Added new plural fields PrePlugins, PostAuthenticationPlugins,
    PostPlugins, and ResponsePlugins for custom plugins configuration.
  • Updated Fill and ExtractTo methods to support both singular and plural
    plugin configurations.
  • +91/-51 
    x-tyk-api-gateway.json
    Schema Update to Support Plural Custom Plugins Configuration

    apidef/oas/schema/x-tyk-api-gateway.json

  • Introduced new schema definitions for plural custom plugins
    configurations.
  • Deprecated singular custom plugin configurations in favor of plural
    forms.
  • +20/-0   
    Tests
    middleware_test.go
    Add Tests for Plural Custom Plugins Configuration               

    apidef/oas/middleware_test.go

  • Added tests to validate the migration from singular to plural plugin
    configurations.
  • +46/-0   
    oas_test.go
    Update Tests to Support Plural Custom Plugins Configuration

    apidef/oas/oas_test.go

  • Updated tests to reflect changes in custom plugins configuration from
    singular to plural forms.
  • +28/-32 

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@jeffy-mathew)
    Execution page

    1 similar comment
    @buger

    buger commented Mar 7, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - mongo44-murmur64 env: success
    Branch used: refs/heads/master
    Commit: 4cddc45 [TT-11439/TT-11452] fix custom plugins contract (#6097)

    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:

    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

    Screenshots (if appropriate)

    Types of changes

    • 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

    • 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

    Relevant files
    Enhancement
    middleware.go
    Refactor Custom Plugins Configuration to Support Plural Forms

    apidef/oas/middleware.go

  • Deprecated PrePlugin, PostAuthenticationPlugin, PostPlugin, and
    ResponsePlugin in favor of plural forms.
  • Added new plural fields PrePlugins, PostAuthenticationPlugins,
    PostPlugins, and ResponsePlugins for custom plugins configuration.
  • Updated Fill and ExtractTo methods to support both singular and plural
    plugin configurations.
  • +91/-51 
    x-tyk-api-gateway.json
    Schema Update to Support Plural Custom Plugins Configuration

    apidef/oas/schema/x-tyk-api-gateway.json

  • Introduced new schema definitions for plural custom plugins
    configurations.
  • Deprecated singular custom plugin configurations in favor of plural
    forms.
  • +20/-0   
    Tests
    middleware_test.go
    Add Tests for Plural Custom Plugins Configuration               

    apidef/oas/middleware_test.go

  • Added tests to validate the migration from singular to plural plugin
    configurations.
  • +46/-0   
    oas_test.go
    Update Tests to Support Plural Custom Plugins Configuration

    apidef/oas/oas_test.go

  • Updated tests to reflect changes in custom plugins configuration from
    singular to plural forms.
  • +28/-32 

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@jeffy-mathew)
    Execution page

    @buger

    buger commented Mar 7, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - postgres15-murmur64 env: success
    Branch used: refs/heads/master
    Commit: 4cddc45 [TT-11439/TT-11452] fix custom plugins contract (#6097)

    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:

    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

    Screenshots (if appropriate)

    Types of changes

    • 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

    • 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

    Relevant files
    Enhancement
    middleware.go
    Refactor Custom Plugins Configuration to Support Plural Forms

    apidef/oas/middleware.go

  • Deprecated PrePlugin, PostAuthenticationPlugin, PostPlugin, and
    ResponsePlugin in favor of plural forms.
  • Added new plural fields PrePlugins, PostAuthenticationPlugins,
    PostPlugins, and ResponsePlugins for custom plugins configuration.
  • Updated Fill and ExtractTo methods to support both singular and plural
    plugin configurations.
  • +91/-51 
    x-tyk-api-gateway.json
    Schema Update to Support Plural Custom Plugins Configuration

    apidef/oas/schema/x-tyk-api-gateway.json

  • Introduced new schema definitions for plural custom plugins
    configurations.
  • Deprecated singular custom plugin configurations in favor of plural
    forms.
  • +20/-0   
    Tests
    middleware_test.go
    Add Tests for Plural Custom Plugins Configuration               

    apidef/oas/middleware_test.go

  • Added tests to validate the migration from singular to plural plugin
    configurations.
  • +46/-0   
    oas_test.go
    Update Tests to Support Plural Custom Plugins Configuration

    apidef/oas/oas_test.go

  • Updated tests to reflect changes in custom plugins configuration from
    singular to plural forms.
  • +28/-32 

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@jeffy-mathew)
    Execution page

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants