Comments (4)
🎉 This issue has been resolved in version 1.5.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
from typeconv.
Input:
index.ts
export interface Bar {
name: 'bar';
}
export interface Foo {
bar: Bar;
}
Command:
typeconv -f ts -t oapi --oapi-format yaml --oapi-version 3 './**/*.ts'
Converted 2 types in 1 files, in 0.0s
Output (Wrong):
openapi: 3.0.0
info:
title: Converted from index.yaml with typeconv
version: '3'
paths: {}
$id: index.yaml
$comment: >-
Generated from index.ts by core-types-json-schema
(https://github.com/grantila/core-types-json-schema) on behalf of typeconv
(https://github.com/grantila/typeconv)
components:
schemas:
Bar:
properties:
name:
const: bar
type: string
required:
- name
additionalProperties: false
type: object
Foo:
properties:
bar:
$ref: '#/components/schema/Bar'
required:
- bar
additionalProperties: false
type: object
Expected Output:
openapi: 3.0.0
info:
title: Converted from index.yaml with typeconv
version: '3'
paths: {}
$id: index.yaml
$comment: >-
Generated from index.ts by core-types-json-schema
(https://github.com/grantila/core-types-json-schema) on behalf of typeconv
(https://github.com/grantila/typeconv)
components:
schemas:
Bar:
properties:
name:
const: bar
type: string
required:
- name
additionalProperties: false
type: object
Foo:
properties:
bar:
$ref: '#/components/schemas/Bar'
required:
- bar
additionalProperties: false
type: object
Temporary solution:
find . -type f -name '*.yaml' -print0 | xargs -0 sed -i '' -e 's/components\/schema/components\/schemas/g'
from typeconv.
Just wanted to say that I think this library it a really awesome piece of code. Its saved me hours and hours so far.
Ive also noticed this problem, and a little further one as well (but I think related)
references from other files dont have the filename.
if I have
//foo.d.ts
export type Thingy = {
a: number
}
//top-level.d.ts
import {Thingy} from './foo.d.ts'
export Flubber = {
flub: Thingy
}
when these are converted to openAPI schema the reference within Flubber is
bar:
$ref: '#/components/schema/Thingy'
but I expect it should be
bar:
$ref: 'foo.yaml#/components/schema/Thingy'
from typeconv.
Interesting, I'll certainly look into this.
The last example, I'm afraid there's no plan to support typescript referencing other files. That escalates quickly into something pretty complex, needing to really understand how TypeScript handles types, rather than "just" extracting them from a single-file AST. Perhaps there are tools that can bundle this for you as a pre-processing step?
from typeconv.
Related Issues (20)
- Add option to read stdin
- OpenAPI -> TypeScript adds wildcard prop to each type HOT 2
- TypeScript to OpenApi HOT 1
- TypeScript nonExported to cli options HOT 2
- [gql] `input` type is not getting converted
- [ts-to-oapi] Enums are not generated during conversion. HOT 3
- Is it possible to export all types into one file from different directories?
- Unable to convert `keyof typeof something` HOT 1
- Executing typeconv from nmp-scripts or within bash script does not work HOT 4
- TS -> OAPI single example
- OpenAPI version 2 HOT 1
- JsonSchema => GraphQL: only "AllOf" schema is used HOT 2
- TS -> OAPI - ignores interfaces inheritance
- Convert interfaces/types that implements generic types HOT 2
- Nested interfaces ignored when declared in other files (Typescript -> OpenAPI) HOT 3
- Overlapping attributes in inherited types fails to convert HOT 2
- [jsc-to-ts] enum with null value throws
- Type 'any' not supported
- Cyclic -> Circular Dependencies?
- Cannot read undefined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeconv.