acacode / acacode/swagger-typescript-api

Don't include $ref definitions when path is relative

Đang mở
#209 4 bình luận 2 reaction 1 người được giao Được @js2me nhận Xem trên GitHub
enhancement
Ngôn ngữ chính
TypeScript
Star
4.1k
Fork
436
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I've stumble across a problem when splitting my huge openapi spec file in pieces.
We decided to take apart some definitions into different files and reference them from our main definition with `$ref` ([as this guide recommends](https://swagger.io/docs/specification/using-ref/)).

Turns out that output definition file does not include that schema, put `any` instead. I will show you an example:

openapi.yml
```
openapi: 3.0.0
info:
title: Sample API
description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
version: 0.1.9
servers:
- url: http://api.example.com/v1
description: Optional server description, e.g. Main (production) server
- url: http://staging-api.example.com
description: Optional server description, e.g. Internal staging server for testing
paths:
/users:
get:
summary: Returns a list of users.
description: Optional extended description in CommonMark or HTML.
responses:
'200': # status code
description: A JSON array of user names
content:
application/json:
schema:
type: array
items:
$ref: "reference.yaml#/account_base"

```

reference.yaml
```
account_base:
type: "object"
properties:
id:
type: "string"
description: "User's ID"
example: "26345b2f-3125-11eb-87d8-801234232f4e"
email:
type: "string"
description: "User's Email"
example: "a@a.com"
format: "email"
```

Run cli command: `swagger-typescript-api -p ./openapi.yaml -n output.d.ts --no-client --route-types --responses --union-enums`

output.d.ts
```
/* eslint-disable */
/* tslint:disable */
/*
* ---------------------------------------------------------------
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
* ## ##
* ## AUTHOR: acacode ##
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
* ---------------------------------------------------------------
*/

export namespace users {
/**
* @description Optional extended description in CommonMark or HTML.
* @name UsersList
* @summary Returns a list of users.
* @request GET:/users
* @response `200` `(any)[]` A JSON array of user names
*/
export namespace UsersList {
export type RequestParams = {};
export type RequestQuery = {};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = any[]; //<- this should be AccountBase
}
}

```

Is this something i can fix by setting a parameter?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.