Skip to content
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

enum is not generated properly #32

Open
rattkin opened this issue Nov 10, 2020 · 3 comments
Open

enum is not generated properly #32

rattkin opened this issue Nov 10, 2020 · 3 comments

Comments

@rattkin
Copy link
Contributor

rattkin commented Nov 10, 2020

Hi I looked at past issues and saw that enums should now be implemented... Also saw some manual types, but where do I put them? all the TI files are regularly overwritten

This is the openapi fragment:

Address:
    description: Address data for shipping or billing
    type: object
    properties:

        AddressTypeID:
            type: string
            enum:
                - BA
                - EX
            description: BA - Billing Address, EX - Expedition

This is the output from ts-interface-builder:

/**
 * This module was automatically generated by `ts-interface-builder`
 */
import * as t from "ts-interface-checker";
// tslint:disable:object-literal-key-quotes

export const Address = t.iface([], {
  "AddressTypeID": t.enumlit("Address", "AddressTypeID"),
});

const exportedTypeSuite: t.ITypeSuite = {
  Address,
};
export default exportedTypeSuite;
@dsagal
Copy link
Member

dsagal commented Nov 11, 2020

What's the typescript file being compiled?

@rattkin
Copy link
Contributor Author

rattkin commented Nov 12, 2020

To make a more consistent example I'm posting this YAML

AddressTMP:
    description: Address data for shipping or billing
    type: object
    properties:
        AddressTypeID:
            type: string
            enum:
                - BA
                - EX
            description: BA - Billing Address, EX - Expedition

This is the typescript interface:

/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

/**
 * Address data for shipping or billing
 */
export interface AddressTMP {
    /**
     * BA - Billing Address, EX - Expedition
     */
    AddressTypeID?: AddressTMP.AddressTypeID;
}

export namespace AddressTMP {

    /**
     * BA - Billing Address, EX - Expedition
     */
    export enum AddressTypeID {
        BA = 'BA',
        EX = 'EX',
    }


}

Generated AddressTMP-ti.ts:

/**
 * This module was automatically generated by `ts-interface-builder`
 */
import * as t from "ts-interface-checker";
// tslint:disable:object-literal-key-quotes

export const AddressTMP = t.iface([], {
  "AddressTypeID": t.opt(t.enumlit("AddressTMP", "AddressTypeID")),
});

const exportedTypeSuite: t.ITypeSuite = {
  AddressTMP,
};
export default exportedTypeSuite;

@dsagal
Copy link
Member

dsagal commented Nov 12, 2020

So this mainly seems a problem with ts-interface-builder lacking support for namespaces (perhaps would be fixed by #28?) The use of enumlit seems out of place, so that may be a separate problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants