Skip to content

Possible Bug: Missing Schema in Generated Output #336

@heinsenberg82

Description

@heinsenberg82

Hi,

I'm experimenting with what I believe might be a bug: one of my schemas, TradeStrategyDto, is not being properly generated by openapi-zod-client.

OpenAPI Schema Snippet:

"components": {
  "schemas": {
    "TradeStrategyDto": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": { "type": "string" },
        "symbol": { "type": "string" },
        "order_price": { "type": "number", "format": "decimal" },
        "order_side": { "$ref": "#/components/schemas/OrderSide" },
        "order_duration_ms": { "type": "integer", "format": "int32", "nullable": true },
        "strategy_duration_ms": { "type": "integer", "format": "int32", "nullable": true },
        "started": { "type": "boolean" }
      }
    },
   "OrderSide": {
        "type": "string",
        "description": "Side of an order",
        "x-enumNames": [
          "Buy",
          "Sell"
        ],
        "enum": [
          "Buy",
          "Sell"
        ]
      },
      "Request": {
        "type": "object",
        "additionalProperties": false
      },
      "FireOrStopStrategyEndpointResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "success": {
            "type": "boolean"
          },
          "error_message": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "FireStrategyCommandOfStealthOrderStrategy": {
        "type": "object",
        "example": {
          "symbol": "ETH-WHATEVER",
          "price": 200.5,
          "quantity": 20.0,
          "order_side": "Buy",
          "order_duration_ms": 200,
          "strategy_duration": 300
        },
        "additionalProperties": false,
        "properties": {
          "symbol": {
            "type": "string",
            "nullable": true,
            "example": "ETH-WHATEVER"
          },
          "price": {
            "type": "number",
            "format": "decimal",
            "example": 200.5
          },
          "quantity": {
            "type": "number",
            "format": "decimal",
            "example": 20.0
          },
          "order_side": {
            "example": "Buy",
            "$ref": "#/components/schemas/OrderSide"
          },
          "order_duration_ms": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "example": 200
          },
          "strategy_duration": {
            "type": "integer",
            "format": "int32",
            "example": 300
          }
        }
      },
      "StopStrategyCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          }
        }
      },
    ...
"components": {
    "schemas": {
      "TradeStrategyDto": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "order_price": {
            "type": "number",
            "format": "decimal"
          },
          "order_side": {
            "$ref": "#/components/schemas/OrderSide"
          },
          "order_duration_ms": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "strategy_duration_ms": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "started": {
            "type": "boolean"
          }
        }
      },
      "OrderSide": {
        "type": "string",
        "description": "Side of an order",
        "x-enumNames": [
          "Buy",
          "Sell"
        ],
        "enum": [
          "Buy",
          "Sell"
        ]
      },
      "Request": {
        "type": "object",
        "additionalProperties": false
      },
      "FireOrStopStrategyEndpointResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "success": {
            "type": "boolean"
          },
          "error_message": {
            "type": "string",
            "nullable": true
          }
        }
      },
  }
}

Generated schemas:

export const schemas = {
  OrderSide,
  FireStrategyCommandOfStealthOrderStrategy,
  FireOrStopStrategyEndpointResponse,
  StopStrategyCommand,
};

As shown above, TradeStrategyDto is present in the OpenAPI schema, but it's missing from the generated schemas export.

Command used:
openapi-zod-client "http://localhost:5156/swagger/v1/swagger.json" --group-strategy=tag-file -o lib/api/generated --export-schemas=true --export-types=true --strict-objects

Let me know if you need any further information or if I'm missing something in the setup.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions