Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enum definitions with a single item are not included as referenced.

See original GitHub issue

When referencing an enum with only a single value, the associated property is missing from the generated type.

I’ve attached an example directory that has a simple swagger.yaml and client output. Any help or known workarounds would be greatly appreciated.

The command run to create the client was:

cd output
autorest --typescript --add-credentials=true --input-file=../swagger.yaml --generate-metadata=true --output-folder=client --package-name="enum-single-item" --package-version=0.0.1

The output of that command, showing versions:

AutoRest code generation utility [version: 2.0.4283; node: v8.9.4]
(C) 2018 Microsoft Corporation.
   Loading AutoRest core      '/Users/bluecamel/.autorest/@microsoft.azure_autorest-core@2.0.4283/node_modules/' (2.0.4283)
   Loading AutoRest extension '' (~2.0.12->2.0.304)
   Loading AutoRest extension '' (2.1.23->2.1.23)

The relevant model definitions:

      name: Thing
    type: string
      - thinger

        type: string
        $ref: '#/definitions/Thing'
      - message
      - thing

The enum is generated correctly:

 * Defines values for Thing.
 * Possible values include: 'thinger'
 * @readonly
 * @enum {string}
export enum Thing {
  Thinger = 'thinger',

However, the property is missing from the generated interface that references the enum:

 * @interface
 * An interface representing Stuff.
export interface Stuff {
   * @member {string} message
  message: string;

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

RikkiGibsoncommented, Oct 1, 2018

I’ll consider this resolved as by-design. Please follow up if you have any additional questions.

RikkiGibsoncommented, Sep 27, 2018

We had a need to be able to define constant-valued properties and parameters from an API design perspective and we adapted single-case enums to do so. See

If you poke around in ms-rest-js’s serviceClient or serializer you’ll see that at runtime we add the default values for the constant properties for you.

re x-ms-enum: you might be able to get the modeler to treat it as a user-visible string property if you want by providing modelAsString: true. Haven’t tried it myself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enumeration types - C# reference - Microsoft Learn
You use an enumeration type to represent a choice from a set of mutually exclusive values or a combination of choices. To represent...
Read more >
Handbook - Enums - TypeScript
a reference to previously defined constant enum member (which can originate from a different enum); a parenthesized constant enum expression; one of the...
Read more >
typescript - Enum type not defined at runtime - Stack Overflow
I now get 'const' enums can only be used in property or index access expressions or the right hand side of an import...
Read more >
Enumeration declaration -
An enumeration is a distinct type whose value is restricted to a range of values (see below for details), which may include several ......
Read more >
Enums - Swagger
You can use the enum keyword to specify possible values of a request parameter or a model property. For example, the sort parameter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found