openapi-typescript-codegen
openapi-typescript-codegen copied to clipboard
Model's fields generated from component schemas are empty.
Using this 3.0 openapi spec:
openapi: "3.0.0"
info:
version: 1.0.0
title: Authenticated API Example
description: An example API which uses bearer token scopes and JWT auth
paths:
/things:
get:
operationId: listThings
description: |
Returns a list of things. Because this endpoint doesn't override the
global security, it requires a JWT for authentication.
responses:
200:
description: a list of things
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ThingWithID"
post:
operationId: addThing
description: |
Adds a thing to the list of things. This endpoints overrides the global
security scheme and requires a `things:w` scope in order to perform a
write.
security:
- BearerAuth:
- "things:w"
requestBody:
description: A thing to insert. Returns the inserted thing with an ID
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Thing"
responses:
201:
description: The inserted Thing with a unique ID
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ThingWithID"
components:
schemas:
Thing:
properties:
name:
type: string
required:
- name
ThingWithID:
allOf:
- $ref: "#/components/schemas/Thing"
- properties:
id:
type: integer
format: int64
required:
- id
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
description: Error code
message:
type: string
description: Error message
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
security:
- BearerAuth: []
produces:
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type Thing = {
};
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { Thing } from './Thing';
export type ThingWithID = Thing;
The Thing
and ThingWithID
types are both empty.
![Screen Shot 2022-08-03 at 2 52 46 PM](https://user-images.githubusercontent.com/1073892/182687077-414e02b5-f34a-4531-b7ca-65c3b9c1994a.png)
Also, ThingWithID
should be:
export type ThingWithID = Thing & { id: number }
Or something similar, but I'm assuming this has to do with the fact that neither type is being read properly.
Is there anything new on this one? I'm still having that issue and have no idea on how to continue. Like this the package is unusable.
Also having a similar issue. Does it have something to do with allOf
? I did not have this problem with another spec that doesn't use allOf
.