Oats doesn't populate referenced types (just `any`)
- Dominant language
- TypeScript
- Stars
- 14
- Forks
- 5
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 1
Description
When making swagger more friendly for better code generators, it was noticed that oats drops types of referenced parameters/schemas and instead defines them as `any`.
Given this swagger, oats generates the following typescript.
```yaml
openapi: 3.0.0
info:
title: Test API
version: 0.0.0
servers:
- url: ''
paths:
/a:
post:
parameters:
- in: query
name: range
schema:
type: string
enum:
- 24h
- 7d
- 30d
default: 24h
responses:
'200':
description: Success
/b:
post:
parameters:
- in: query
name: range
schema:
$ref: '#/components/schemas/TimeRange'
responses:
'200':
description: Success
components:
schemas:
TimeRange:
type: string
enum:
- 24h
- 7d
- 30d
default: 24h
```
```ts
export interface PostAParams {
query?: {
range?: string;
};
}
export interface PostBParams {
query?: {
range?: any;
};
}
```
Contributor guide
Research direction
Start with the supplied OpenAPI example and trace how the generator handles the $ref on the /b query parameter. Add regression coverage for the referenced schema case and verify the generated TypeScript uses the TimeRange type instead of any.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100