Skip to content

[TT-11954/TT-12155] add x-tyk-api-gateway.servers.contextVariables.enabled#6281

Merged
jeffy-mathew merged 1 commit into
masterfrom
feat/TT-11954/TT-12115/enabled-context-vars-oas
May 16, 2024
Merged

[TT-11954/TT-12155] add x-tyk-api-gateway.servers.contextVariables.enabled#6281
jeffy-mathew merged 1 commit into
masterfrom
feat/TT-11954/TT-12115/enabled-context-vars-oas

Conversation

@jeffy-mathew

@jeffy-mathew jeffy-mathew commented May 15, 2024

Copy link
Copy Markdown
Contributor

User description

  • add x-tyk-api-gateway.servers.contextVariables.enabled
  • enable context variables by default for OAS APIs if not explicitly configured otherwise.

Parent: https://tyktech.atlassian.net/browse/TT-11954
Subtask: https://tyktech.atlassian.net/browse/TT-12155

Motivation and Context

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

PR Type

enhancement


Description

  • Added handling and configuration for context variables in the OAS server structure.
  • Removed hardcoded enabling of context variables, now configurable via JSON.
  • Updated tests to reflect new logic and added new tests for context variable configuration.
  • Updated JSON schema to include new ContextVariables definition.

Changes walkthrough 📝

Relevant files
Tests
oas_test.go
Update OAS Test to Reflect Context Variable Changes           

apidef/oas/oas_test.go

  • Removed assertion for EnableContextVars in TestOAS.
+0/-1     
server_test.go
Add Tests for Context Variables in Server Struct                 

apidef/oas/server_test.go

  • Added tests for ContextVariables handling in Server struct.
+71/-0   
api_test.go
Test Default Enabling of Context Variables in OAS APIs     

gateway/api_test.go

  • Added tests to ensure context variables are enabled by default and
    respect explicit configuration.
  • +21/-0   
    Enhancement
    root.go
    Remove Hardcoded Context Variable Enabling in Root Extraction

    apidef/oas/root.go

    • Removed hardcoded enabling of EnableContextVars.
    +0/-3     
    server.go
    Integrate Context Variables Handling in Server Struct       

    apidef/oas/server.go

  • Added handling for ContextVariables in Server struct.
  • Implemented Fill and ExtractTo methods for ContextVariables.
  • +41/-0   
    api.go
    Default Enable Context Variables for OAS APIs                       

    gateway/api.go

  • Added default enabling of context variables for OAS APIs if not
    explicitly set.
  • +5/-0     
    x-tyk-api-gateway.json
    Add JSON Schema for Context Variables                                       

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

    • Added schema definition for ContextVariables.
    +14/-0   

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

    - enable context variables by default for OAS APIs if not explicitly configured otherwise.
    @jeffy-mathew
    jeffy-mathew force-pushed the feat/TT-11954/TT-12115/enabled-context-vars-oas branch from 06a4033 to 61fb076 Compare May 15, 2024 16:11
    @github-actions

    github-actions Bot commented May 15, 2024

    Copy link
    Copy Markdown
    Contributor

    API Changes

    --- prev.txt	2024-05-15 16:12:16.693082284 +0000
    +++ current.txt	2024-05-15 16:12:13.637085654 +0000
    @@ -2855,6 +2855,19 @@
     }
         ClientToPolicy contains a 1-1 mapping between Client ID and Policy ID.
     
    +type ContextVariables struct {
    +	// Enabled enables context variables to be passed to Tyk middlewares.
    +	// Tyk classic API definition: `enable_context_vars`.
    +	Enabled bool `json:"enabled" bson:"enabled"`
    +}
    +    ContextVariables holds the configuration related to Tyk context variables.
    +
    +func (c *ContextVariables) ExtractTo(api *apidef.APIDefinition)
    +    ExtractTo extracts *ContextVariables into *apidef.APIDefinition.
    +
    +func (c *ContextVariables) Fill(api apidef.APIDefinition)
    +    Fill fills *ContextVariables from apidef.APIDefinition.
    +
     type CustomPlugin struct {
     	// Enabled activates the custom pre plugin.
     	Enabled bool `bson:"enabled" json:"enabled"` // required.
    @@ -3974,6 +3987,9 @@
     	//
     	// Tyk classic API definition: `event_handlers`
     	EventHandlers EventHandlers `bson:"eventHandlers,omitempty" json:"eventHandlers,omitempty"`
    +
    +	// ContextVariables contains the configuration related to Tyk context variables.
    +	ContextVariables *ContextVariables `bson:"contextVariables,omitempty" json:"contextVariables,omitempty"`
     }
         Server contains the configuration that sets Tyk up to receive requests from
         the client applications.

    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Description updated to latest commit (61fb076)

    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves multiple files and changes related to enabling context variables in the API gateway. The changes are spread across both Go code and JSON schema, requiring a reviewer to understand the interactions between these components and their implications on the system's behavior.

    🧪 Relevant tests

    Yes

    ⚡ Possible issues

    Possible Bug: The default enabling of context variables might not respect existing configurations which explicitly disable them. This could lead to unexpected behavior in deployments relying on the previous default settings.

    🔒 Security concerns

    No

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

    Consider adding a check to ensure that ContextVariables is only set to enabled if it is not explicitly set in the configuration. This avoids overriding explicit user configurations which could lead to unexpected behavior. [important]

    relevant lineif s.ContextVariables == nil {

    relevant filegateway/api.go
    suggestion      

    Add error handling for the scenario where ContextVariables might fail to set, ensuring robustness in API creation and configuration updates. [important]

    relevant lineif oasObj.GetTykExtension().Server.ContextVariables == nil {

    relevant fileapidef/oas/server.go
    suggestion      

    Refactor the repeated code for creating a new ContextVariables instance into a helper function to improve code maintainability and reduce redundancy. [medium]

    relevant lines.ContextVariables = &ContextVariables{}

    relevant fileapidef/oas/server_test.go
    suggestion      

    Extend the test cases to cover scenarios where ContextVariables is explicitly set to false, ensuring that the system respects these settings and does not enable them by default. [important]

    relevant line"disabled",

    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    Remove redundant code to simplify logic and avoid unnecessary operations

    Remove the redundant initialization of ContextVariables in the ExtractTo method since it's
    already handled in the Fill method.

    apidef/oas/server.go [172-176]

    -if s.ContextVariables == nil {
    -    s.ContextVariables = &ContextVariables{}
    -    defer func() {
    -        s.ContextVariables = nil
    -    }()
    -}
    +// Removed redundant initialization
     
    Suggestion importance[1-10]: 6

    Why: The suggestion is valid as it points out redundancy. However, the initialization in ExtractTo is not redundant because it ensures ContextVariables is not nil before use, which is not handled in Fill.

    6
    Best practice
    Improve management of object lifecycle for clarity and better resource control

    Instead of setting ContextVariables to nil in a deferred function, consider managing its
    lifecycle more explicitly outside of ExtractTo to improve code clarity and control.

    apidef/oas/server.go [175]

    -defer func() {
    -    s.ContextVariables = nil
    -}()
    +// Consider lifecycle management strategy outside of this method
     
    Suggestion importance[1-10]: 4

    Why: The suggestion to manage lifecycle outside ExtractTo could improve clarity, but the current defer method is also a valid approach. The suggestion does not provide a clear alternative implementation.

    4

    @jeffy-mathew jeffy-mathew changed the title [TT-11954/TT-12115] add x-tyk-api-gateway.servers.contextVariables.enabled [TT-11954/TT-12156] add x-tyk-api-gateway.servers.contextVariables.enabled May 15, 2024
    @jeffy-mathew jeffy-mathew changed the title [TT-11954/TT-12156] add x-tyk-api-gateway.servers.contextVariables.enabled [TT-11954/TT-12155] add x-tyk-api-gateway.servers.contextVariables.enabled May 15, 2024
    @github-actions

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @sonarqubecloud

    Copy link
    Copy Markdown

    Quality Gate Failed Quality Gate failed

    Failed conditions
    76.2% Coverage on New Code (required ≥ 80%)

    See analysis details on SonarCloud

    @jeffy-mathew

    Copy link
    Copy Markdown
    Contributor Author

    sonarcloud coverage report is false positive.
    https://sonarcloud.io/component_measures?id=TykTechnologies_tyk&pullRequest=6281&metric=new_coverage&view=list
    Screenshot 2024-05-16 at 09 24 13
    PR has no changes made to internal/graphengine/transport.go

    @jeffy-mathew
    jeffy-mathew merged commit 6b7c9ad into master May 16, 2024
    @jeffy-mathew
    jeffy-mathew deleted the feat/TT-11954/TT-12115/enabled-context-vars-oas branch May 16, 2024 07:25
    @maciejwojciechowski

    Copy link
    Copy Markdown
    Contributor

    /release to release-5.3

    @tykbot

    tykbot Bot commented May 22, 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 May 22, 2024
    …abled (#6281)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    - add x-tyk-api-gateway.servers.contextVariables.enabled
    - enable context variables by default for OAS APIs if not explicitly
    configured otherwise.
    
    <!-- Describe your changes in detail -->
    Parent: https://tyktech.atlassian.net/browse/TT-11954
    Subtask: https://tyktech.atlassian.net/browse/TT-12155
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    <!-- Why is this change required? What problem does it solve? -->
    
    <!-- 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. -->
    
    <!-- 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)
    
    <!-- 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
    
    ___
    
    enhancement
    
    ___
    
    - Added handling and configuration for context variables in the OAS
    server structure.
    - Removed hardcoded enabling of context variables, now configurable via
    JSON.
    - Updated tests to reflect new logic and added new tests for context
    variable configuration.
    - Updated JSON schema to include new `ContextVariables` definition.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update OAS Test to
    Reflect Context Variable Changes</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add Tests for Context
    Variables in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` handling in `Server` struct.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Test Default Enabling of
    Context Variables in OAS APIs</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default and
    <br>respect explicit configuration.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove Hardcoded Context
    Variable Enabling in Root Extraction</code></dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Removed hardcoded enabling of `EnableContextVars`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Integrate Context Variables
    Handling in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added handling for <code>ContextVariables</code> in
    <code>Server</code> struct.<br> <li> Implemented <code>Fill</code> and
    <code>ExtractTo</code> methods for <code>ContextVariables</code>.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Default Enable Context
    Variables for OAS APIs</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    <li>Added default enabling of context variables for OAS APIs if not
    <br>explicitly set.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add JSON
    Schema for Context Variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Added schema definition for `ContextVariables`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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 6b7c9ad)
    @tykbot

    tykbot Bot commented May 22, 2024

    Copy link
    Copy Markdown

    @maciejwojciechowski Succesfully merged PR

    @titpetric

    Copy link
    Copy Markdown
    Contributor

    /release to release-5.3

    @tykbot

    tykbot Bot commented May 23, 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 May 23, 2024
    …abled (#6281)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    - add x-tyk-api-gateway.servers.contextVariables.enabled
    - enable context variables by default for OAS APIs if not explicitly
    configured otherwise.
    
    <!-- Describe your changes in detail -->
    Parent: https://tyktech.atlassian.net/browse/TT-11954
    Subtask: https://tyktech.atlassian.net/browse/TT-12155
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    <!-- Why is this change required? What problem does it solve? -->
    
    <!-- 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. -->
    
    <!-- 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)
    
    <!-- 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
    
    ___
    
    enhancement
    
    ___
    
    - Added handling and configuration for context variables in the OAS
    server structure.
    - Removed hardcoded enabling of context variables, now configurable via
    JSON.
    - Updated tests to reflect new logic and added new tests for context
    variable configuration.
    - Updated JSON schema to include new `ContextVariables` definition.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update OAS Test to
    Reflect Context Variable Changes</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add Tests for Context
    Variables in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` handling in `Server` struct.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Test Default Enabling of
    Context Variables in OAS APIs</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default and
    <br>respect explicit configuration.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove Hardcoded Context
    Variable Enabling in Root Extraction</code></dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Removed hardcoded enabling of `EnableContextVars`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Integrate Context Variables
    Handling in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added handling for <code>ContextVariables</code> in
    <code>Server</code> struct.<br> <li> Implemented <code>Fill</code> and
    <code>ExtractTo</code> methods for <code>ContextVariables</code>.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Default Enable Context
    Variables for OAS APIs</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    <li>Added default enabling of context variables for OAS APIs if not
    <br>explicitly set.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add JSON
    Schema for Context Variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Added schema definition for `ContextVariables`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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 6b7c9ad)
    @tykbot

    tykbot Bot commented May 23, 2024

    Copy link
    Copy Markdown

    @titpetric Succesfully merged PR

    titpetric pushed a commit that referenced this pull request May 23, 2024
    …abled (#6281)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    - add x-tyk-api-gateway.servers.contextVariables.enabled
    - enable context variables by default for OAS APIs if not explicitly
    configured otherwise.
    
    <!-- Describe your changes in detail -->
    Parent: https://tyktech.atlassian.net/browse/TT-11954
    Subtask: https://tyktech.atlassian.net/browse/TT-12155
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    <!-- Why is this change required? What problem does it solve? -->
    
    <!-- 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. -->
    
    <!-- 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)
    
    <!-- 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
    
    ___
    
    enhancement
    
    ___
    
    - Added handling and configuration for context variables in the OAS
    server structure.
    - Removed hardcoded enabling of context variables, now configurable via
    JSON.
    - Updated tests to reflect new logic and added new tests for context
    variable configuration.
    - Updated JSON schema to include new `ContextVariables` definition.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update OAS Test to
    Reflect Context Variable Changes</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add Tests for Context
    Variables in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` handling in `Server` struct.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Test Default Enabling of
    Context Variables in OAS APIs</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default and
    <br>respect explicit configuration.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove Hardcoded Context
    Variable Enabling in Root Extraction</code></dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Removed hardcoded enabling of `EnableContextVars`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Integrate Context Variables
    Handling in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added handling for <code>ContextVariables</code> in
    <code>Server</code> struct.<br> <li> Implemented <code>Fill</code> and
    <code>ExtractTo</code> methods for <code>ContextVariables</code>.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Default Enable Context
    Variables for OAS APIs</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    <li>Added default enabling of context variables for OAS APIs if not
    <br>explicitly set.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add JSON
    Schema for Context Variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Added schema definition for `ContextVariables`.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    titpetric pushed a commit that referenced this pull request May 23, 2024
    #6302)
    
    ### **User description**
    …abled (#6281)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    - add x-tyk-api-gateway.servers.contextVariables.enabled
    - enable context variables by default for OAS APIs if not explicitly
    configured otherwise.
    
    <!-- Describe your changes in detail -->
    Parent: https://tyktech.atlassian.net/browse/TT-11954 Subtask:
    https://tyktech.atlassian.net/browse/TT-12155 <!-- This project only
    accepts pull requests related to open issues. --> <!-- If suggesting a
    new feature or change, please discuss it in an issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    <!-- Why is this change required? What problem does it solve? -->
    
    <!-- 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. -->
    
    <!-- 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)
    
    <!-- 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
    
    ___
    
    enhancement
    
    ___
    
    - Added handling and configuration for context variables in the OAS
    server structure.
    - Removed hardcoded enabling of context variables, now configurable via
    JSON.
    - Updated tests to reflect new logic and added new tests for context
    variable configuration.
    - Updated JSON schema to include new `ContextVariables` definition.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update OAS Test to
    Reflect Context Variable Changes</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add Tests for Context
    Variables in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` handling in `Server` struct.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Test Default Enabling of
    Context Variables in OAS APIs</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default and
    <br>respect explicit configuration.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove Hardcoded Context
    Variable Enabling in Root Extraction</code></dd></summary> <hr>
    
    apidef/oas/root.go
    - Removed hardcoded enabling of `EnableContextVars`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Integrate Context Variables
    Handling in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added handling for <code>ContextVariables</code> in
    <code>Server</code> struct.<br> <li> Implemented <code>Fill</code> and
    <code>ExtractTo</code> methods for <code>ContextVariables</code>.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Default Enable Context
    Variables for OAS APIs</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr>
    
    gateway/api.go
    <li>Added default enabling of context variables for OAS APIs if not
    <br>explicitly set.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add JSON
    Schema for Context Variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Added schema definition for `ContextVariables`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## 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
    
    
    ___
    
    ### **PR Type**
    Enhancement, Tests
    
    
    ___
    
    ### **Description**
    - Added `ContextVariables` struct and related methods to manage context
    variables in OAS APIs.
    - Updated `Fill` and `ExtractTo` methods in `Server` to handle
    `ContextVariables`.
    - Enabled context variables by default for OAS APIs if not explicitly
    set to false.
    - Added tests to ensure context variables are enabled by default and can
    be explicitly disabled.
    - Updated schema to include `contextVariables` and defined
    `X-Tyk-ContextVariables`.
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Remove assertion for
    `EnableContextVars` in OAS test.</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add tests for
    ContextVariables in Server.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` in `Server`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Add tests for default and
    explicit enabling of context variables.</code></dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default.<br>
    <li> Added tests to ensure context variables can be explicitly
    disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove always enabling
    context variables in ExtractTo method.</code></dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Removed always enabling `EnableContextVars` in `ExtractTo` method.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Add ContextVariables struct
    and update Fill and ExtractTo methods.</code></dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added <code>ContextVariables</code> struct and related methods.<br>
    <li> Updated <code>Fill</code> and <code>ExtractTo</code> methods to
    handle <code>ContextVariables</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Enable context variables by
    default for OAS APIs.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    <li>Enabled context variables by default for OAS APIs if not explicitly
    <br>set.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add
    contextVariables to schema and define
    X-Tyk-ContextVariables.</code></dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    <li>Added <code>contextVariables</code> to the schema.<br> <li> Added
    <code>X-Tyk-ContextVariables</code> definition.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    
    ---------
    
    Co-authored-by: Jeffy Mathew <[email protected]>
    Co-authored-by: Tit Petric <[email protected]>
    nerdydread pushed a commit that referenced this pull request Sep 6, 2024
    …abled (#6281)
    
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    - add x-tyk-api-gateway.servers.contextVariables.enabled
    - enable context variables by default for OAS APIs if not explicitly
    configured otherwise.
    
    <!-- Describe your changes in detail -->
    Parent: https://tyktech.atlassian.net/browse/TT-11954
    Subtask: https://tyktech.atlassian.net/browse/TT-12155
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## 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
    
    
    ___
    
    ### **PR Type**
    enhancement
    
    
    ___
    
    ### **Description**
    - Added handling and configuration for context variables in the OAS
    server structure.
    - Removed hardcoded enabling of context variables, now configurable via
    JSON.
    - Updated tests to reflect new logic and added new tests for context
    variable configuration.
    - Updated JSON schema to include new `ContextVariables` definition.
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update OAS Test to
    Reflect Context Variable Changes</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add Tests for Context
    Variables in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` handling in `Server` struct.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Test Default Enabling of
    Context Variables in OAS APIs</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default and
    <br>respect explicit configuration.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove Hardcoded Context
    Variable Enabling in Root Extraction</code></dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Removed hardcoded enabling of `EnableContextVars`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Integrate Context Variables
    Handling in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added handling for <code>ContextVariables</code> in
    <code>Server</code> struct.<br> <li> Implemented <code>Fill</code> and
    <code>ExtractTo</code> methods for <code>ContextVariables</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Default Enable Context
    Variables for OAS APIs</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    <li>Added default enabling of context variables for OAS APIs if not
    <br>explicitly set.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add JSON
    Schema for Context Variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Added schema definition for `ContextVariables`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    edsonmichaque pushed a commit that referenced this pull request Feb 18, 2025
    #6302)
    
    ### **User description**
    …abled (#6281)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    - add x-tyk-api-gateway.servers.contextVariables.enabled
    - enable context variables by default for OAS APIs if not explicitly
    configured otherwise.
    
    <!-- Describe your changes in detail -->
    Parent: https://tyktech.atlassian.net/browse/TT-11954 Subtask:
    https://tyktech.atlassian.net/browse/TT-12155 <!-- This project only
    accepts pull requests related to open issues. --> <!-- If suggesting a
    new feature or change, please discuss it in an issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    <!-- Why is this change required? What problem does it solve? -->
    
    <!-- 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. -->
    
    <!-- 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)
    
    <!-- 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
    
    ___
    
    enhancement
    
    ___
    
    - Added handling and configuration for context variables in the OAS
    server structure.
    - Removed hardcoded enabling of context variables, now configurable via
    JSON.
    - Updated tests to reflect new logic and added new tests for context
    variable configuration.
    - Updated JSON schema to include new `ContextVariables` definition.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update OAS Test to
    Reflect Context Variable Changes</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add Tests for Context
    Variables in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` handling in `Server` struct.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Test Default Enabling of
    Context Variables in OAS APIs</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default and
    <br>respect explicit configuration.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove Hardcoded Context
    Variable Enabling in Root Extraction</code></dd></summary> <hr>
    
    apidef/oas/root.go
    - Removed hardcoded enabling of `EnableContextVars`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Integrate Context Variables
    Handling in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added handling for <code>ContextVariables</code> in
    <code>Server</code> struct.<br> <li> Implemented <code>Fill</code> and
    <code>ExtractTo</code> methods for <code>ContextVariables</code>.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Default Enable Context
    Variables for OAS APIs</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr>
    
    gateway/api.go
    <li>Added default enabling of context variables for OAS APIs if not
    <br>explicitly set.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add JSON
    Schema for Context Variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Added schema definition for `ContextVariables`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## 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
    
    
    ___
    
    ### **PR Type**
    Enhancement, Tests
    
    
    ___
    
    ### **Description**
    - Added `ContextVariables` struct and related methods to manage context
    variables in OAS APIs.
    - Updated `Fill` and `ExtractTo` methods in `Server` to handle
    `ContextVariables`.
    - Enabled context variables by default for OAS APIs if not explicitly
    set to false.
    - Added tests to ensure context variables are enabled by default and can
    be explicitly disabled.
    - Updated schema to include `contextVariables` and defined
    `X-Tyk-ContextVariables`.
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Remove assertion for
    `EnableContextVars` in OAS test.</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add tests for
    ContextVariables in Server.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` in `Server`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Add tests for default and
    explicit enabling of context variables.</code></dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default.<br>
    <li> Added tests to ensure context variables can be explicitly
    disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove always enabling
    context variables in ExtractTo method.</code></dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Removed always enabling `EnableContextVars` in `ExtractTo` method.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Add ContextVariables struct
    and update Fill and ExtractTo methods.</code></dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added <code>ContextVariables</code> struct and related methods.<br>
    <li> Updated <code>Fill</code> and <code>ExtractTo</code> methods to
    handle <code>ContextVariables</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Enable context variables by
    default for OAS APIs.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    <li>Enabled context variables by default for OAS APIs if not explicitly
    <br>set.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add
    contextVariables to schema and define
    X-Tyk-ContextVariables.</code></dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    <li>Added <code>contextVariables</code> to the schema.<br> <li> Added
    <code>X-Tyk-ContextVariables</code> definition.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    
    ---------
    
    Co-authored-by: Jeffy Mathew <[email protected]>
    Co-authored-by: Tit Petric <[email protected]>
    edsonmichaque pushed a commit that referenced this pull request Feb 18, 2025
    #6302)
    
    ### **User description**
    …abled (#6281)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    - add x-tyk-api-gateway.servers.contextVariables.enabled
    - enable context variables by default for OAS APIs if not explicitly
    configured otherwise.
    
    <!-- Describe your changes in detail -->
    Parent: https://tyktech.atlassian.net/browse/TT-11954 Subtask:
    https://tyktech.atlassian.net/browse/TT-12155 <!-- This project only
    accepts pull requests related to open issues. --> <!-- If suggesting a
    new feature or change, please discuss it in an issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    <!-- Why is this change required? What problem does it solve? -->
    
    <!-- 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. -->
    
    <!-- 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)
    
    <!-- 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
    
    ___
    
    enhancement
    
    ___
    
    - Added handling and configuration for context variables in the OAS
    server structure.
    - Removed hardcoded enabling of context variables, now configurable via
    JSON.
    - Updated tests to reflect new logic and added new tests for context
    variable configuration.
    - Updated JSON schema to include new `ContextVariables` definition.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update OAS Test to
    Reflect Context Variable Changes</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add Tests for Context
    Variables in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` handling in `Server` struct.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Test Default Enabling of
    Context Variables in OAS APIs</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default and
    <br>respect explicit configuration.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove Hardcoded Context
    Variable Enabling in Root Extraction</code></dd></summary> <hr>
    
    apidef/oas/root.go
    - Removed hardcoded enabling of `EnableContextVars`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Integrate Context Variables
    Handling in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added handling for <code>ContextVariables</code> in
    <code>Server</code> struct.<br> <li> Implemented <code>Fill</code> and
    <code>ExtractTo</code> methods for <code>ContextVariables</code>.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Default Enable Context
    Variables for OAS APIs</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr>
    
    gateway/api.go
    <li>Added default enabling of context variables for OAS APIs if not
    <br>explicitly set.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add JSON
    Schema for Context Variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Added schema definition for `ContextVariables`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## 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
    
    
    ___
    
    ### **PR Type**
    Enhancement, Tests
    
    
    ___
    
    ### **Description**
    - Added `ContextVariables` struct and related methods to manage context
    variables in OAS APIs.
    - Updated `Fill` and `ExtractTo` methods in `Server` to handle
    `ContextVariables`.
    - Enabled context variables by default for OAS APIs if not explicitly
    set to false.
    - Added tests to ensure context variables are enabled by default and can
    be explicitly disabled.
    - Updated schema to include `contextVariables` and defined
    `X-Tyk-ContextVariables`.
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Remove assertion for
    `EnableContextVars` in OAS test.</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add tests for
    ContextVariables in Server.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` in `Server`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Add tests for default and
    explicit enabling of context variables.</code></dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default.<br>
    <li> Added tests to ensure context variables can be explicitly
    disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove always enabling
    context variables in ExtractTo method.</code></dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Removed always enabling `EnableContextVars` in `ExtractTo` method.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Add ContextVariables struct
    and update Fill and ExtractTo methods.</code></dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added <code>ContextVariables</code> struct and related methods.<br>
    <li> Updated <code>Fill</code> and <code>ExtractTo</code> methods to
    handle <code>ContextVariables</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Enable context variables by
    default for OAS APIs.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    <li>Enabled context variables by default for OAS APIs if not explicitly
    <br>set.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add
    contextVariables to schema and define
    X-Tyk-ContextVariables.</code></dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    <li>Added <code>contextVariables</code> to the schema.<br> <li> Added
    <code>X-Tyk-ContextVariables</code> definition.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    
    ---------
    
    Co-authored-by: Jeffy Mathew <[email protected]>
    Co-authored-by: Tit Petric <[email protected]>
    edsonmichaque pushed a commit to edsonmichaque/tyk-1 that referenced this pull request Feb 18, 2025
    TykTechnologies#6302)
    
    ### **User description**
    …abled (TykTechnologies#6281)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    - add x-tyk-api-gateway.servers.contextVariables.enabled
    - enable context variables by default for OAS APIs if not explicitly
    configured otherwise.
    
    <!-- Describe your changes in detail -->
    Parent: https://tyktech.atlassian.net/browse/TT-11954 Subtask:
    https://tyktech.atlassian.net/browse/TT-12155 <!-- This project only
    accepts pull requests related to open issues. --> <!-- If suggesting a
    new feature or change, please discuss it in an issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    <!-- Why is this change required? What problem does it solve? -->
    
    <!-- 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. -->
    
    <!-- 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)
    
    <!-- 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
    
    ___
    
    enhancement
    
    ___
    
    - Added handling and configuration for context variables in the OAS
    server structure.
    - Removed hardcoded enabling of context variables, now configurable via
    JSON.
    - Updated tests to reflect new logic and added new tests for context
    variable configuration.
    - Updated JSON schema to include new `ContextVariables` definition.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update OAS Test to
    Reflect Context Variable Changes</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add Tests for Context
    Variables in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` handling in `Server` struct.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Test Default Enabling of
    Context Variables in OAS APIs</code>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default and
    <br>respect explicit configuration.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove Hardcoded Context
    Variable Enabling in Root Extraction</code></dd></summary> <hr>
    
    apidef/oas/root.go
    - Removed hardcoded enabling of `EnableContextVars`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Integrate Context Variables
    Handling in Server Struct</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added handling for <code>ContextVariables</code> in
    <code>Server</code> struct.<br> <li> Implemented <code>Fill</code> and
    <code>ExtractTo</code> methods for <code>ContextVariables</code>.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Default Enable Context
    Variables for OAS APIs</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr>
    
    gateway/api.go
    <li>Added default enabling of context variables for OAS APIs if not
    <br>explicitly set.<br>
    
    </details>
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add JSON
    Schema for Context Variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Added schema definition for `ContextVariables`.
    
    </details>
    
      </td> <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6281/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## 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
    
    
    ___
    
    ### **PR Type**
    Enhancement, Tests
    
    
    ___
    
    ### **Description**
    - Added `ContextVariables` struct and related methods to manage context
    variables in OAS APIs.
    - Updated `Fill` and `ExtractTo` methods in `Server` to handle
    `ContextVariables`.
    - Enabled context variables by default for OAS APIs if not explicitly
    set to false.
    - Added tests to ensure context variables are enabled by default and can
    be explicitly disabled.
    - Updated schema to include `contextVariables` and defined
    `X-Tyk-ContextVariables`.
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Remove assertion for
    `EnableContextVars` in OAS test.</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    - Removed assertion for `EnableContextVars` in `TestOAS`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server_test.go</strong><dd><code>Add tests for
    ContextVariables in Server.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/server_test.go
    - Added tests for `ContextVariables` in `Server`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-a194795077946243b2b6d04b30be360dbafff8e5eb03e6212081e45d1c72573f">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Add tests for default and
    explicit enabling of context variables.</code></dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Added tests to ensure context variables are enabled by default.<br>
    <li> Added tests to ensure context variables can be explicitly
    disabled.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+21/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Enhancement
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Remove always enabling
    context variables in ExtractTo method.</code></dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Removed always enabling `EnableContextVars` in `ExtractTo` method.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+0/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Add ContextVariables struct
    and update Fill and ExtractTo methods.</code></dd></summary>
    <hr>
    
    apidef/oas/server.go
    <li>Added <code>ContextVariables</code> struct and related methods.<br>
    <li> Updated <code>Fill</code> and <code>ExtractTo</code> methods to
    handle <code>ContextVariables</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-21857c42e8659f7980014e277c3c758703f29e9e5c0c40553f2584cddb870808">+41/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Enable context variables by
    default for OAS APIs.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    <li>Enabled context variables by default for OAS APIs if not explicitly
    <br>set.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+5/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Add
    contextVariables to schema and define
    X-Tyk-ContextVariables.</code></dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    <li>Added <code>contextVariables</code> to the schema.<br> <li> Added
    <code>X-Tyk-ContextVariables</code> definition.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6302/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>&nbsp;
    &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
    
    ---------
    
    Co-authored-by: Jeffy Mathew <[email protected]>
    Co-authored-by: Tit Petric <[email protected]>
    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