Stoobly / stoobly-agent

Record, mock, and test HTTP/HTTPS requests. CLI agent for Stoobly.
Other
6 stars 0 forks source link

Fix bug where required query params were not being marked #218

Closed tylerbhadra closed 2 months ago

tylerbhadra commented 2 months ago

Changes Made

Added a required field to the literal_query_param object so that the SchemaBuilder can correctly parse the required property value for a query parameter when calling the __convert_literal_component_param helper function.

Expected Benefits

Should fix the bug where the required tag is not marked correctly for query_params (#215)

New output w/ changes

Given:

{
  "openapi": "3.0.1",
  "info": {
    "version": "v1"
  },
  "paths": {
    "/v1/transactions": {
      "get": {
        "parameters": [
          {
            "name": "userId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "locationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "nullable": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
}

Expect: userId and locationId should be marked as required

Result:

Screen Shot 2024-04-08 at 4 11 30 PM

Additional Notes:

The required field is optional for query parameters and its default value is false. Query parameters should only be marked as required if the required property is explicitly set to true

Context: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.1.md#parameter-objec