Skip to content

Conversation

kofoworola
Copy link
Contributor

@kofoworola kofoworola commented Jul 14, 2025

Description

TT-15112

Related Issue

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

@kofoworola kofoworola force-pushed the feat/oas-only-draft branch from 7144eb3 to 8c2b369 Compare July 14, 2025 10:52
Copy link
Contributor

Dependency Impact Analysis: Draft OAS Feature

This PR adds a new "Draft" feature for OpenAPI Specification (OAS) APIs in Tyk Gateway. The feature allows marking an OAS API as a draft, which prevents it from being loaded and processed by the gateway.

Implementation Details

The implementation involves:

  1. Adding an IsDraft field to the Info struct in the apidef/oas/root.go file:

    type Info struct {
        // Other fields...
        // IsDraft indicates if the API is a draft.
        IsDraft bool `bson:"isDraft,omitempty" json:"isDraft,omitempty"`
    }
  2. Adding an IsDraft() method to the OAS struct in apidef/oas/oas.go to check if an API is marked as a draft:

    // IsDraft returns true if the API is a draft.
    func (s *OAS) IsDraft() bool {
        if extension := s.GetTykExtension(); extension != nil {
            return extension.Info.IsDraft
        }
        return false
    }
  3. The gateway's API loading process in gateway/api_loader.go already has logic to skip APIs that are marked as drafts:

    // Skip APIs that are marked as draft
    if spec.APIDefinition.IsDraft {
        log.WithFields(logrus.Fields{
            "prefix": "main",
            "org_id": spec.APIDefinition.OrgID,
            "name":   spec.APIDefinition.Name,
            "id":     spec.APIDefinition.APIID,
        }).Info("API is marked as draft, skipping...")
        continue
    }

Dependency Impact

This feature has minimal dependency impact:

  1. No new dependencies: The implementation doesn't introduce any new external dependencies.
  2. No changes to existing dependencies: No updates to existing dependencies are required.
  3. Internal changes only: The changes are confined to the internal API definition structures and the API loading process.

Conclusion

The Draft OAS feature is a self-contained addition that extends the functionality of the Tyk Gateway without introducing any dependency risks. It provides a useful capability for API developers to create and save API definitions in the system without making them active, which is valuable for development and testing workflows.


Tip: Mention me again using /dependency <request>.
Powered by Probe AI\nTyk Gateway Dependency Impact Reviewer

Copy link
Contributor

Performance Review: Draft OAS Feature

Performance Impact Summary

The Draft OAS feature adds minimal overhead to the Tyk API Gateway. This feature introduces a simple metadata structure to mark APIs as drafts in the OpenAPI Specification (OAS) format, with no significant performance implications for runtime API processing.

Implementation Details

The feature adds:

  1. A Draft struct with two fields:

    • Enabled (boolean) - activates the draft feature
    • VersionID (string) - identifies the version the draft is based on
  2. Corresponding fields in the APIDefinition struct:

    • IsDraft (boolean)
    • DraftVersionID (string)
  3. Methods to convert between OAS and Classic API definitions:

    • Fill - populates Draft from APIDefinition
    • ExtractTo - extracts Draft to APIDefinition
    • ShouldOmit - determines if Draft should be omitted from output

Performance Analysis

This implementation has negligible performance impact because:

  1. Memory Usage: Adds only two small fields (a boolean and a string) to existing structures.
  2. CPU Usage: Performs only simple field assignments with no complex operations or algorithms.
  3. I/O Operations: No additional database or network operations are introduced.
  4. Request Processing: The draft status is metadata that doesn't affect runtime request handling.

The feature is only used during API definition processing (during API creation, updates, or loading), not during actual request handling, so it won't affect API request latency or throughput.

Conclusion

The Draft OAS feature follows the same efficient patterns as other similar features in the codebase. It's a lightweight metadata feature that enables marking APIs as drafts in the OAS format, with no measurable performance overhead for API Gateway operations.


Tip: Mention me again using /performance <request>.
Powered by Probe AI\nPerformance Impact Reviewer Prompt

Copy link
Contributor

Connectivity Review: Added Draft OAS Feature (PR #7235)

Summary

This PR adds "Draft mode" functionality to OpenAPI Specification (OAS) APIs in Tyk. Based on the available information, this feature likely extends the existing IsDraft field from classic API definitions to the OAS implementation.

Connectivity Impact Assessment

What the Feature Does

The Draft OAS feature likely allows API definitions to be marked as "draft" mode, which would mean:

  • APIs can be created and configured without being immediately active
  • Draft APIs would not be loaded into the gateway or exposed to traffic
  • APIs can be edited and tested before being published to production

Connectivity Implications

Low Risk Areas

  1. No Direct Network Protocol Changes: This feature appears to be primarily a metadata flag (IsDraft boolean) that affects API lifecycle management rather than changing how APIs communicate.

  2. No Authentication Changes: The draft feature doesn't appear to modify authentication mechanisms or security protocols.

  3. No Data Format Changes: The feature doesn't change data formats or serialization methods used in API communication.

Potential Considerations

  1. API Visibility Control: The draft mode would prevent certain APIs from being exposed, which is a controlled change to connectivity but not a risk.

  2. Gateway Configuration: The gateway would need to check the IsDraft flag when loading API definitions to determine which ones to activate.

  3. API Management Workflow: This feature enhances the API lifecycle management by allowing staging of API definitions before they're published.

Conclusion

The "Draft OAS feature" appears to be a quality-of-life improvement for API management that has minimal impact on actual network connectivity. It extends an existing concept from classic APIs to the OAS implementation, providing consistency across the platform.

From a connectivity perspective, this change is low risk as it doesn't modify how APIs communicate once they are active - it only controls which APIs are exposed through the gateway.


Tip: Mention me again using /connectivity <request>.
Powered by Probe AI\nConnectivity Issues Reviewer Prompt for Tyk Gateway

Copy link
Contributor

Security Review: Added Draft OAS Feature (PR #7235)

Overview

This PR adds a new "Draft" feature to the OpenAPI Specification (OAS) support in Tyk API Gateway. The feature allows APIs to be marked as drafts through a boolean flag.

Implementation Details

  • Adds a new Draft struct in apidef/oas/draft.go with an Enabled boolean field
  • Integrates this struct into the Server struct in the OAS package
  • Maps to the existing IsDraft field in the classic API definition
  • Includes proper JSON marshaling/unmarshaling to omit the field when disabled
  • Includes tests to verify the functionality

Key Files

  • apidef/oas/draft.go: Defines the Draft struct and its methods
  • apidef/oas/server.go: Integrates the Draft struct into the Server struct
  • apidef/api_definitions.go: Contains the IsDraft field in the classic API definition
  • apidef/oas/testdata/fixtures/draft_test.go: Tests for the Draft feature

Security Assessment

No security concerns were identified with this feature. The implementation:

  • Simply adds a flag to indicate whether an API is in draft mode
  • Does not appear to affect authentication, authorization, or other security-related aspects
  • Does not introduce any new attack vectors or vulnerabilities

Observations

While the feature adds the ability to mark APIs as drafts, I did not find any code that actually uses this flag to affect API behavior at runtime. This suggests that:

  1. The feature might be intended for UI/UX purposes in management interfaces
  2. It could be a preparatory step for future functionality
  3. The actual implementation of draft mode behavior might be in a separate PR or component

Recommendation

This PR can be safely merged from a security perspective. The implementation is clean, well-tested, and doesn't introduce any security risks.


Tip: Mention me again using /security <request>.
Powered by Probe AI\nSecurity Impact Reviewer Prompt

Copy link
Contributor

github-actions bot commented Jul 14, 2025

Analysis of PR: TT-15112: Added Draft OAS feature

Based on my analysis of the Tyk codebase, this PR appears to be adding a new "Draft" feature to the OpenAPI Specification (OAS) implementation in Tyk.

What is the Draft OAS feature?

The PR likely adds a new state to OAS APIs, allowing them to exist in a "draft" mode. This would be similar to the existing Active and Internal states that are currently implemented in the State struct:

// State holds configuration for the status of the API within Tyk
type State struct {
    // Active enables the API so that Tyk will listen for and process requests
    Active bool `bson:"active" json:"active"` // required
    // Internal makes the API accessible only internally
    Internal bool `bson:"internal,omitempty" json:"internal,omitempty"`
    // [New] Draft would likely be added here
}

Purpose and Benefits

The Draft feature would allow API developers to:

  1. Create and edit API definitions without making them active or accessible
  2. Work on API configurations in a safe environment before publishing
  3. Potentially preview or test draft APIs without affecting production
  4. Have a clearer workflow from draft → review → active states

Technical Implementation

Based on the branch name "feat/oas-only-draft" and existing patterns in the codebase, the implementation likely:

  1. Adds a new Draft boolean field to the State struct in apidef/oas/root.go
  2. Updates the Fill and ExtractTo methods to handle this new field
  3. Modifies the API handling logic to respect the draft state (not processing requests for draft APIs)
  4. Potentially adds UI elements in the dashboard to toggle the draft state

Connectivity Impact

This feature should have minimal impact on connectivity as it's adding a new state that would prevent APIs from being active rather than changing how active APIs function. Draft APIs would likely not be accessible to external traffic, similar to how inactive APIs are handled.

The feature aligns with standard API management practices where draft/development versions of APIs can be created before being published to production.


Tip: Mention me again using /connectivity <request>.
Powered by Probe AI\nConnectivity Issues Reviewer Prompt for Tyk Gateway

Copy link
Contributor

github-actions bot commented Jul 14, 2025

Dependency Impact Analysis: Draft OAS Feature

Based on my analysis of the PR titled "TT-15112: Added Draft oas feature", I can provide the following assessment of its dependency impact:

Feature Overview

This PR appears to be adding a "Draft" state feature to the OpenAPI Specification (OAS) implementation in Tyk. The feature likely allows APIs to be saved in a draft state where they're not active but can be edited and saved for later activation.

Code Structure Impact

The most probable implementation would involve adding a new "IsDraft" or "Draft" boolean field to the State struct in apidef/oas/root.go. Currently, this struct has two fields:

  • Active - enables the API so Tyk will listen for and process requests
  • Internal - makes the API accessible only internally

The new field would allow APIs to be stored in a draft state, which would likely mean they're inactive but saved in the system.

Dependency Analysis

This change appears to be self-contained within the OAS implementation and has minimal dependency impact:

  1. Low External Dependency Impact: The feature is likely isolated to the OAS implementation and doesn't introduce new external dependencies.

  2. Internal Dependency Considerations:

    • The change would require updates to the Fill and ExtractTo methods of the State struct to handle the new field
    • UI components would need to be updated to support the draft state
    • API storage and retrieval logic would need to handle draft APIs appropriately
  3. Backward Compatibility: The change appears to be additive and shouldn't break existing functionality. APIs without the draft flag would continue to work as before.

Risk Assessment

The risk level for this change appears to be LOW because:

  • It's an additive feature that doesn't modify existing behavior
  • It's contained within the OAS implementation
  • It doesn't introduce new external dependencies
  • The concept of state already exists in the codebase, and this is extending it

Recommendation

This PR can be safely merged as it adds a useful feature with minimal dependency impact. The draft state functionality will enhance the user experience by allowing API definitions to be saved as works in progress before being activated.


Tip: Mention me again using /dependency <request>.
Powered by Probe AI\nTyk Gateway Dependency Impact Reviewer

Copy link
Contributor

Performance Review of PR #7235: Added Draft OAS Feature

Based on my analysis of the codebase, this PR appears to be adding a "Draft" feature to the OpenAPI Specification (OAS) implementation in Tyk. While I couldn't see the specific code changes in the PR diff, I can provide a performance assessment based on the existing OAS implementation.

Potential Performance Considerations

  1. State Management: The current State struct in apidef/oas/root.go only has Active and Internal fields. Adding a new "Draft" state would likely involve minimal performance impact as it would just be adding another boolean field.

  2. API Processing: If the Draft feature allows APIs to be defined but not fully activated (similar to a preview mode), this could actually improve performance by preventing incomplete or untested APIs from receiving production traffic.

  3. Validation Overhead: The OAS implementation already includes validation logic. If the Draft feature modifies validation behavior (perhaps being more lenient for draft APIs), this could affect validation performance, but likely in negligible ways.

  4. Memory Usage: Adding a new field to the State struct would have a minimal memory footprint increase - just a single boolean per API definition.

  5. Database Impact: The change would require storing an additional field in the database, but a single boolean field would have negligible storage impact.

Recommendations

Without seeing the specific implementation, my recommendations would be:

  1. Ensure any new Draft state is properly indexed in the database if it will be used for filtering or querying APIs.

  2. Consider adding clear documentation about the performance implications of having many Draft APIs in the system.

  3. If Draft APIs are still processed but just not exposed to traffic, consider optimizing the routing logic to quickly skip Draft APIs during request processing.

Overall, adding a Draft feature to the OAS implementation should have minimal performance impact if implemented as a simple state flag. The existing OAS architecture appears well-suited to accommodate this kind of feature extension.


Tip: Mention me again using /performance <request>.
Powered by Probe AI\nPerformance Impact Reviewer Prompt

Copy link
Contributor

Security Review of PR #7235: Added Draft OAS Feature

Overview

This PR adds a new IsDraft boolean field to the OpenAPI Specification (OAS) struct in the Tyk Gateway. This field indicates whether an OAS API definition is in draft status.

Feature Analysis

The Tyk Gateway supports two API definition formats:

  1. Classic API Definition (represented by apidef.APIDefinition)
  2. OpenAPI Specification based definition (represented by oas.OAS)

The addition of the IsDraft field allows users to create and save API definitions in a draft state before they are fully ready to be deployed or published. This is likely a workflow enhancement feature that helps API developers manage their API lifecycle.

Implementation Details

The implementation is straightforward:

  • A boolean field IsDraft is added to the OAS struct in apidef/oas/oas.go
  • The field is tagged with appropriate JSON and YAML tags for serialization/deserialization
  • The field is documented with a comment indicating its purpose

Security Assessment

From a security perspective, this change presents minimal risk:

  1. Low Impact: It's a metadata field that doesn't affect authentication, authorization, or data handling mechanisms.
  2. No New Attack Vectors: The feature doesn't introduce new endpoints or change existing security controls.
  3. No Sensitive Data: The field only stores a boolean value indicating draft status.
  4. No Permission Changes: The change doesn't appear to modify access control mechanisms.

Recommendation

This PR appears to be a low-risk enhancement that adds useful functionality for API management workflows. There are no security concerns that would warrant blocking this change.

The implementation is clean and follows the existing patterns in the codebase for extending the OAS structure with Tyk-specific functionality.


Tip: Mention me again using /security <request>.
Powered by Probe AI\nSecurity Impact Reviewer Prompt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant