swagger-api / swagger-api/swagger-codegen
TypeScript object definition with any typed key
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
How to create a swagger definition of an object with any keys, which all are of a defined type?
What I have
definitions:
Language:
type: object
properties:
foo:
type: object
items:
$ref: "#/definitions/Foo"
Foo:
type: object
additionalProperties:
$ref: "#definitions/Bar"
Bar:
type: object
properties:
a:
type: string
b:
type: number
What I want
export interface Language {
foo?: Foo
}
export interface Foo {
[key: string]: Bar
}
export interface Bar{
a?: string
b?: number;
}
What I currently receive
export interface Language {
foo?: any
}
export interface Foo extends null<String, any> {
}
export interface Bar{
a?: string
b?: number;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files, tests, or entry points are named. Start by tracing the TypeScript generator output for the shown additionalProperties definition and compare it with the requested index signature; done means Foo uses string keys mapped to Bar and Language.foo is typed as Foo rather than any.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100