metadevpro / openapi3-ts

TS Model & utils for creating and exposing OpenAPI 3.x contracts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Publishing types

donaldpipowitch opened this issue · comments

Hi! Nice project.

I was wondering if you could just publish the OpenAPI types so others can import and re-use them? That would be really useful for other TS-based projects.

Thanks.

Thanks Donald!

Some aspects are modeled as interfaces just because there was no current need for a class (structural typing was enough, so far).
Everything is exported, including interfaces, and a index.d.ts file is also provided in the npm package, so reuse in other TS-based project shouldn't be a problem.

Take a look to the DSL folder for sample usage. Or see the following example about how to consume an interface from another TS project and also have all the benefits of strongly typing (including code completion in your IDE):

npm init
npm i --save-dev typescript
npm i --save openapi3-ts

sample.ts

import { InfoObject } from 'openapi3-ts';

let info: InfoObject = {
    title: 'ACME API',
    version : '13.0.4'
};

In any case, if you have a more concrete use case, feel free to further explain.

Okay, thank you. I only need the interfaces, nothing more. But because openapi3-ts has no dependencies and is quite small I think I can just use directly. Thanks :)