Skip to content

Conversation

@Explorer1092
Copy link

Summary

  • Fix panic when OpenAPI spec has non-string default value for string type parameter
  • Add safe type conversion for array[string] elements as well

Problem

When an OpenAPI spec defines a string type parameter with an integer default value (e.g., MoviePilot API), the direct type assertion def.(string) in AddFlag would cause a panic:

panic: interface conversion: interface {} is int, not string

Solution

  • Use type assertion first, fall back to fmt.Sprintf("%v", def) only when needed
  • Apply the same pattern to array[string] handling for consistency and safety

Test plan

  • Tested with MoviePilot API which has integer defaults for string parameters
  • Verified existing string defaults still work correctly

🤖 Generated with Claude Code

When an OpenAPI spec has an integer default value for a string type
parameter, the direct type assertion `def.(string)` would panic.

This fix:
- Uses type assertion first, falls back to fmt.Sprintf if needed
- Also fixes array[string] handling for non-string elements
- Prevents panic when encountering type mismatches in OpenAPI specs
  (e.g., MoviePilot API)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nomagicln
Copy link

Nice~

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.

2 participants