-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor to better export oas30 and oas31 compatible with cjs #103
Conversation
…reak compatibility in the way we export)
I hope so. |
``` | ||
|
||
### To use version 3.0 import | ||
|
||
From Typescript you can consume it from the library: | ||
|
||
```typescript | ||
import { OpenAPIObject } from "openapi3-ts/model/openapi30"; | ||
import { OpenApiBuilder } from "openapi3-ts/dsl/openapi-builder30"; | ||
import { oas30 } from "openapi3-ts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this approach does not work for some reason
TS2614: Module '"openapi3-ts"' has no exported member 'oas30'. Did you mean to use 'import oas30 from "openapi3-ts"' instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe need to clean cache... please wait....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Looks like a typo on my side.
Can you confirm this works for you?
import oas30 from "openapi3-ts";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the reason, see my suggestion below, @pjmolina
const oas30 = { ...model.oas30, ...dsl.oas30 }; | ||
const oas31 = { ...model.oas31, ...dsl.oas31 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these two guys should also be exported (not within the "default"), then they will be importable individually, @pjmolina
const oas30 = { ...model.oas30, ...dsl.oas30 }; | |
const oas31 = { ...model.oas31, ...dsl.oas31 }; | |
export const oas30 = { ...model.oas30, ...dsl.oas30 }; | |
export const oas31 = { ...model.oas31, ...dsl.oas31 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to try it locally and then I'll confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, this does not solve the import problem for types (from model)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to take a bit time to prepare a better suggestion
Ok. I have a proprosition that I believe solves everything. Without namespaces, but using the power of modules. The approach is based on a different way of combining entities comparing to the one you have currently.
export * from './dsl/openapi-builder30';
export * from './model/openapi30';
export { Server, ServerVariable } from './model/server';
export { IExtensionName, IExtensionType, ISpecificationExtension } from './model/specification-extension';
export * from './dsl/openapi-builder31';
export * from './model/openapi31';
export { Server, ServerVariable } from './model/server';
export { IExtensionName, IExtensionType, ISpecificationExtension } from './model/specification-extension';
export * as oas30 from "./oas30";
export * as oas31 from "./oas31";
export { Server, ServerVariable } from "./model/server" no default export, only |
Maybe I should create another PR for that? |
Sure! Feel free. I will review and comment tomorrow. Thanks |
Rejecting this PR in favour of: PR #104 by @RobinTail |
Refactor to better export oas30 and oas31 compatible with cjs
(it will break compatibility in the way we export).
Can you take a look @RobinTail is this solves your use case?