Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging to release-5.7: change swagger to add batch request (#5835) #5836

Merged

Conversation

buger
Copy link
Member

@buger buger commented Dec 19, 2024

User description

change swagger to add batch request (#5835)

  • change swagger to add batch request

PR Type

Documentation


Description

  • Introduced a new endpoint /{listen_path}/tyk/batch in the Swagger file to support batch requests.
  • Documented the batch request functionality, explaining its purpose, usage, and configuration.
  • Added sample request and response examples to illustrate the batch request usage.
  • Defined new schema components (BatchRequestStructure, BatchReplyUnit, and RequestDefinition) to support the batch request feature.
  • Updated schema references to use Tyk's repository for better alignment with internal definitions.

Changes walkthrough 📝

Relevant files
Documentation
gateway-swagger.yml
Add batch request endpoint and documentation in Swagger file.

tyk-docs/assets/others/gateway-swagger.yml

  • Added a new endpoint /{listen_path}/tyk/batch for handling batch
    requests.
  • Documented batch request functionality, including purpose, usage, and
    configuration.
  • Included sample request and response examples for batch requests.
  • Introduced new schema components: BatchRequestStructure,
    BatchReplyUnit, and RequestDefinition.
  • Updated schema references to align with Tyk's repository.
  • +296/-7 

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    * change swagger to add batch request
    
    (cherry picked from commit 4aad425)
    @buger buger enabled auto-merge (squash) December 19, 2024 16:59
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    5835 - Fully compliant

    Fully compliant requirements:

    • Add a new endpoint /{listen_path}/tyk/batch in the Swagger file.
    • Document the batch request functionality, including its purpose, usage, and configuration.
    • Provide sample request and response examples for batch requests.
    • Define new schema components (BatchRequestStructure, BatchReplyUnit, and RequestDefinition) to support the batch request feature.
    • Update schema references to use Tyk's repository for better alignment with internal definitions.

    Not compliant requirements:

    • None
    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Documentation Clarity
    Ensure that the documentation for the batch request functionality is clear and concise, especially the descriptions for the new endpoint, schema components, and examples.

    Schema Reference Update
    Verify that the updated schema references correctly point to Tyk's repository and are aligned with internal definitions.

    Batch Request Endpoint
    Validate the implementation of the new /{listen_path}/tyk/batch endpoint, including its parameters, request body, and responses.

    Schema Definitions
    Review the newly added schema components (BatchRequestStructure, BatchReplyUnit, and RequestDefinition) for correctness and completeness.

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Security
    Mask sensitive API keys or tokens in example requests to prevent accidental exposure

    Ensure that the authorization header in the sample request examples does not expose
    sensitive API keys or tokens, as this could lead to security vulnerabilities.

    tyk-docs/assets/others/gateway-swagger.yml [111]

    -"authorization": "1dbc83b9c431649d7698faa9797e2900f"
    +"authorization": "REDACTED"
    Suggestion importance[1-10]: 9

    Why: Masking sensitive API keys in example requests is a critical security improvement to prevent accidental exposure of sensitive information. This suggestion is highly relevant and directly addresses a potential vulnerability in the documentation.

    9
    Possible issue
    Enforce required fields in the BatchRequestStructure schema to prevent malformed requests

    Validate that the BatchRequestStructure schema properly enforces required fields and
    constraints to avoid malformed requests being processed.

    tyk-docs/assets/others/gateway-swagger.yml [5553-5561]

     BatchRequestStructure:
       properties:
         requests:
           items:
             $ref: '#/components/schemas/RequestDefinition'
    -      nullable: true
    +      nullable: false
           type: array
         suppress_parallel_execution:
           type: boolean
    +  required:
    +    - requests
       type: object
    Suggestion importance[1-10]: 8

    Why: Adding constraints to enforce required fields in the BatchRequestStructure schema improves the robustness of the API by ensuring that only well-formed requests are processed. This is a significant enhancement to the schema's validation logic.

    8
    General
    Add validation for the code property in the BatchReplyUnit schema to ensure it represents valid HTTP status codes

    Ensure that the BatchReplyUnit schema includes validation for the code property to
    restrict it to valid HTTP status codes.

    tyk-docs/assets/others/gateway-swagger.yml [5542-5551]

     BatchReplyUnit:
       properties:
         body:
           type: string
         code:
           type: integer
    +      minimum: 100
    +      maximum: 599
         headers:
           $ref: '#/components/schemas/HttpHeader'
         relative_url:
           type: string
       type: object
    Suggestion importance[1-10]: 7

    Why: Restricting the code property to valid HTTP status codes enhances the schema's accuracy and prevents invalid data from being accepted. While not critical, this is a valuable improvement to the API's response validation.

    7

    Copy link

    netlify bot commented Dec 19, 2024

    PS. Pls add /docs/nightly to the end of url

    Name Link
    🔨 Latest commit 1437ec8
    🔍 Latest deploy log https://app.netlify.com/sites/tyk-docs/deploys/676450d929f2ea00084bc214
    😎 Deploy Preview https://deploy-preview-5836--tyk-docs.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    @buger buger merged commit ec8e5eb into release-5.7 Dec 19, 2024
    9 checks passed
    @buger buger deleted the merge/release-5.7/4aad425ad656e2358de1e2640543662a6d6c4bd1 branch December 19, 2024 17:01
    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.

    2 participants