Comments (18)
My builds are fixed. Thanks the the quick response.
from openapi3-ts.
Hi @BryanHunt
Please note we needed to change the way classes are exported, see #104 to check the changes you need to do in your imports.
from openapi3-ts.
I did change my imports. This is what I'm using now ...
import { MediaTypeObject } from 'openapi3-ts/src/model/openapi31';
Am I missing something else?
from openapi3-ts.
If you don't have additional import errors it will be fine.
from openapi3-ts.
Sorry, I'm not following. What will be fine?
from openapi3-ts.
I meant, if there are no more import errors, its complete. You don't need to change anything else.
from openapi3-ts.
With that import in my comment above, I get the build failure that I originally reported.
from openapi3-ts.
Updated the original comment to make this more clear.
from openapi3-ts.
Ok. I see. Extension names are now checked to be starting with the prefix x-
(per the spec)
See: specification-extension.ts
export type IExtensionName = `x-${string}`;
export type IExtensionType = any;
export type ISpecificationExtension = {
[extensionName: IExtensionName]: IExtensionType;
};
If you need to force the types to bypass the check, you can do:
return obj[extensionName as IExtensionName];
Or use the static methods to retrieve and set the extensions:
export class SpecificationExtension implements ISpecificationExtension {
[extensionName: IExtensionName]: any;
static isValidExtension(extensionName: string): boolean {
return /^x-/.test(extensionName);
}
getExtension(extensionName: string): any {
if (!SpecificationExtension.isValidExtension(extensionName)) {
throw new Error(
`Invalid specification extension: '${extensionName}'. Extensions must start with prefix 'x-`
);
}
if (this[extensionName]) {
return this[extensionName];
}
return null;
}
addExtension(extensionName: string, payload: any): void {
if (!SpecificationExtension.isValidExtension(extensionName)) {
throw new Error(
`Invalid specification extension: '${extensionName}'. Extensions must start with prefix 'x-`
);
}
this[extensionName] = payload;
}
...
from openapi3-ts.
I'm not using extensions. One of my modules that fails to build is using these two exact imports:
import { MediaTypeObject } from 'openapi3-ts/src/model/openapi31';
import { SecuritySchemeObject } from 'openapi3-ts/src/model/openapi31';
from openapi3-ts.
Ok. What version of typescript are you using?
tsc --version
Can you verify it with v. 5.0.2
Looks like https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html is a new feature of the tsc compiler, introduced from TS 4.1
from openapi3-ts.
We are using 5.0.2
from openapi3-ts.
Can you share a minimal repro sample? I will try to debug and diagnose.
from openapi3-ts.
I'll see if I can put something together.
from openapi3-ts.
https://github.com/BryanHunt/openapi-test
from openapi3-ts.
Thank you very much for the sample @BryanHunt
Root cause
The difference is in the setting in tsconfig.json:
- you have
"noImplicitAny": true,
- the library have
"noImplicitAny": false,
When importing the sources, the errors appears only in your side given the configuration.
I am going to prepare a fix in the lib making tsconfig.json more strict.
from openapi3-ts.
Package publishing is now down on npmjs. I will publish v. 4.0.3
with the fix in #106 as soon as is back to live again.
from openapi3-ts.
Published as https://www.npmjs.com/package/openapi3-ts/v/4.0.3
Feel free to reopen the issue if you detect any other problem. Thanks @BryanHunt
from openapi3-ts.
Related Issues (20)
- import { OpenAPIObject } from "openapi3-ts/src/model/openapi31" doesn't work with mocha and ESM HOT 2
- Cannot import `oas31` using ESM in `[email protected]` HOT 5
- importing mjs fails in node HOT 3
- API Parameter description output to wrong place HOT 3
- Validation error: `examples` must be an array HOT 5
- OAS 3.1: Support for const keyword HOT 1
- Source files are published in the package HOT 2
- An in-range update of @types/chai is breaking the build 🚨 HOT 7
- Add "isDereferencedObject" helper method HOT 1
- When using oneOf with objects that have different properties, typescript assumes the list type and breaks HOT 4
- Uniftying with `@types/json-schema`? HOT 1
- Usage question HOT 1
- how to remove/update a path? HOT 1
- Documentation HOT 5
- exclusiveMinimum/Maximum should not be booleans
- v3.0: __exportStar is not defined HOT 10
- v3.0: `exclusiveMaximum` must be a boolean HOT 12
- Targeting certain OpenAPI versions HOT 5
- 4.0: the module exports OAS 3.1 only HOT 6
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 openapi3-ts.