Skip to content

feat: discriminated union support in openapi.yml through flags#2

Open
nimarb wants to merge 1 commit intovercel-labs:mainfrom
nimarb:feat/discriminated-union-body-flags
Open

feat: discriminated union support in openapi.yml through flags#2
nimarb wants to merge 1 commit intovercel-labs:mainfrom
nimarb:feat/discriminated-union-body-flags

Conversation

@nimarb
Copy link

@nimarb nimarb commented Feb 23, 2026

Adds discriminated union support and array/object body flags

generateBodyFlags() returned [] for schemas using oneOf/allOf/anyOf, making endpoints with discriminated unions unusable without --data. array and typeless object properties were silently skipped.

This PR change flattens composition keywords into merged property sets before flag generation, and adds array/json flag types so fields like labels: array and config: object produce usable CLI flags.

Before, an endpoint with a oneOf request body showed no flags at all:

myapi prompts create --help
# Only showed: --curl, --json, --server, --bearer-token, -h
# No body flags — users had to use raw JSON:
myapi prompts create --data '{"name":"greet","type":"text","prompt":"hello","labels":["prod"]}'

# Now individual flags are generated from the merged union branches:
myapi prompts create --help
# Shows: --name, --type, --prompt, --labels, --config, ...

myapi prompts create --name greet --type text --prompt hello --labels prod,staging --config '{"temperature":0.7}'

currently, we have to patch our OpenAPI.yml file to flatten it before we use specli which is a bit annoying :). Hope the PR works / open to feedback etc !

Thank you for providing this software!

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