@hey-api/schemas should support inline schemas
Description
When using the @hey-api/schemas plugin, I found that it only creates types for the schemas defined in #/components/schemas.
However, many openapi.json files also include "inline" schemas, that can be found directly in the parameters field of a path. These schemas do not use a $ref reference to #/components/schemas but are defined in place. OpenAPI spec allows this and I would expect the @hey-api/schemas plugin to also pick up these inline schemas and generate types for them.
The input validation usecase described in your docs (https://heyapi.dev/openapi-ts/output/json-schema) is what my team is looking for. But, our openapi.json is generated by FastAPI which uses these "inplace schemas" for the request parameters and thus they will not be included in the generated code. FastAPI currently does not support placing parameter schemas in #/components/schemas.
Hi @hlgrondijs I think it would be great if you can provide an example of the OpenAPI spec generated by FastAPI.
here's a repro
I added an inline parameter at the pathItem and operation. Additionally, I added an example of using content to cover both schema and content scenarios
openapi: 3.1.0
info:
title: 2295
version: v1
paths:
/things:
parameters:
- name: $count
description: OData V4 $count query parameter
in: query
schema:
type: boolean
required: false
get:
parameters:
- name: $filter
description: OData V4 $filter query parameter
in: query
schema:
type: string
required: false
- name: test
in: query
content:
'application/json':
schema:
type: object
additionalProperties: false
required:
- name
properties:
name:
type: string
age:
type: number
required: false
responses:
'200':
description: OK
content:
'application/json':
schema: {}