## Description
Add OAS trafficLogs
Traffic logs would be enabled by default during OAS API import.
During create, it would respect what it is specified in the API
definition.
## Related Issue
Parent: https://tyktech.atlassian.net/browse/TT-11914
Subtask: https://tyktech.atlassian.net/browse/TT-12101
## 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)
- [x] 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 functionality to enable traffic logs by default during OAS API
import.
- Introduced `TrafficLogs` struct in middleware to handle API level log
analytics.
- Updated JSON schema to support traffic logs configuration.
- Updated unit tests to ensure traffic logs are enabled by default.
___
### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>migration.go</strong><dd><code>Set DoNotTrack flag to
true by default</code>
</dd></summary>
<hr>
apidef/migration.go
- Added `DoNotTrack` flag set to true in `APIDefinition` struct.
</details>
</td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6287/files#diff-e1d9b55a26f9d6225d56d6f0161959217308e5ad4d6934e7d7df4595d9c2a130">+2/-0</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>default.go</strong><dd><code>Enable traffic logs by
default on OAS import</code>
</dd></summary>
<hr>
apidef/oas/default.go
<li>Added a new function call to enable traffic logs by default during
OAS <br>API import.
</details>
</td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6287/files#diff-83c3a85bdd05785178ee519b05b1fe2008435dc4ae9448d72b080b5f67c491ad">+1/-0</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>middleware.go</strong><dd><code>Implement traffic log
analytics configuration</code>
</dd></summary>
<hr>
apidef/oas/middleware.go
<li>Added <code>TrafficLogs</code> struct to handle API level log
analytics.<br> <li> Implemented methods to fill and extract traffic log
settings from <br><code>APIDefinition</code>.
</details>
</td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6287/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+29/-0</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>root.go</strong><dd><code>Conditionally enable traffic
logs in middleware</code>
</dd></summary>
<hr>
apidef/oas/root.go
<li>Added method to conditionally enable traffic logs if they are not
<br>already configured.
</details>
</td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6287/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+18/-0</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>default_test.go</strong><dd><code>Update tests to
verify traffic logs are enabled</code>
</dd></summary>
<hr>
apidef/oas/default_test.go
<li>Updated unit tests to check for enabled traffic logs in the
middleware <br>configuration.
</details>
</td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6287/files#diff-ab6848f71731083885a9d7d7970faa68a6783a98477c78413ae3979cb5add7db">+66/-4</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Configuration
changes</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>x-tyk-api-gateway.json</strong><dd><code>Update JSON
schema for traffic logs configuration</code>
</dd></summary>
<hr>
apidef/oas/schema/x-tyk-api-gateway.json
- Updated JSON schema to include `trafficLogs` configuration.
</details>
</td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6287/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+14/-0</a>
</td>
</tr>
</table></td></tr></tr></tbody></table>
___
> 💡 **PR-Agent usage**:
>Comment `/help` on the PR to get a list of all available PR-Agent tools
and their descriptions
Description
Add OAS trafficLogs
Traffic logs would be enabled by default during OAS API import.
During create, it would respect what it is specified in the API definition.
Related Issue
Parent: https://tyktech.atlassian.net/browse/TT-11914
Subtask: https://tyktech.atlassian.net/browse/TT-12101
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Enhancement
Description
TrafficLogsstruct in middleware to handle API level log analytics.Changes walkthrough 📝
migration.go
Set DoNotTrack flag to true by defaultapidef/migration.go
DoNotTrackflag set to true inAPIDefinitionstruct.default.go
Enable traffic logs by default on OAS importapidef/oas/default.go
API import.
middleware.go
Implement traffic log analytics configurationapidef/oas/middleware.go
TrafficLogsstruct to handle API level log analytics.APIDefinition.root.go
Conditionally enable traffic logs in middlewareapidef/oas/root.go
already configured.
default_test.go
Update tests to verify traffic logs are enabledapidef/oas/default_test.go
configuration.
x-tyk-api-gateway.json
Update JSON schema for traffic logs configurationapidef/oas/schema/x-tyk-api-gateway.json
trafficLogsconfiguration.