Giter Club home page Giter Club logo

Comments (18)

BryanHunt avatar BryanHunt commented on May 23, 2024 1

My builds are fixed. Thanks the the quick response.

from openapi3-ts.

pjmolina avatar pjmolina commented on May 23, 2024

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.

BryanHunt avatar BryanHunt commented on May 23, 2024

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.

pjmolina avatar pjmolina commented on May 23, 2024

If you don't have additional import errors it will be fine.

from openapi3-ts.

BryanHunt avatar BryanHunt commented on May 23, 2024

Sorry, I'm not following. What will be fine?

from openapi3-ts.

pjmolina avatar pjmolina commented on May 23, 2024

I meant, if there are no more import errors, its complete. You don't need to change anything else.

from openapi3-ts.

BryanHunt avatar BryanHunt commented on May 23, 2024

With that import in my comment above, I get the build failure that I originally reported.

from openapi3-ts.

BryanHunt avatar BryanHunt commented on May 23, 2024

Updated the original comment to make this more clear.

from openapi3-ts.

pjmolina avatar pjmolina commented on May 23, 2024

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.

BryanHunt avatar BryanHunt commented on May 23, 2024

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.

pjmolina avatar pjmolina commented on May 23, 2024

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.

BryanHunt avatar BryanHunt commented on May 23, 2024

We are using 5.0.2

from openapi3-ts.

pjmolina avatar pjmolina commented on May 23, 2024

Can you share a minimal repro sample? I will try to debug and diagnose.

from openapi3-ts.

BryanHunt avatar BryanHunt commented on May 23, 2024

I'll see if I can put something together.

from openapi3-ts.

BryanHunt avatar BryanHunt commented on May 23, 2024

https://github.com/BryanHunt/openapi-test

from openapi3-ts.

pjmolina avatar pjmolina commented on May 23, 2024

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.

pjmolina avatar pjmolina commented on May 23, 2024

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.

pjmolina avatar pjmolina commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.