question-mark
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.

AsOf schema names

See original GitHub issue

What are the steps to reproduce this issue?

Generate client using spec:

openapi: '3.0.0'
info:
  version: 1.0.0
  title: Test
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /colors:
    get:
      summary: List colors
      operationId: listColors
      tags:
        - colors
      responses:
        '200':
          description: An array of colors
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Color'
components:
  schemas:
    ColorType:
      type: string
      enum:
        - red
        - green
        - blue
    Color:
      type: object
      required:
        - color
      properties:
        type:
          allOf:
            - $ref: '#/components/schemas/ColorType'

What happens?

The result is:

export type ColorType = 'red' | 'green' | 'blue';


export const ColorType = {
  red: 'red' as ColorType,
  green: 'green' as ColorType,
  blue: 'blue' as ColorType,
};

export type ColorType = ColorType

export const ColorType = {...ColorType};

export interface Color {
  type?: ColorType;
}

The second type-const pair uses the same name as the first pair, resulting in Cannot redeclare block-scoped variable 'ColorType'.ts (2451)

What were you expecting to happen?

Some other name of the second type. Maybe keep ColorTypeAllOf?

Any other comments?

I traced the issue to here: https://github.com/anymaniax/orval/blob/master/src/core/resolvers/value.ts#L22 And noticed that the name parameter to resolveValue is ColorTypeAllOf, but the returned name from resolveRef is ColorType.

What versions are you using?

49290694a8e072ee4f7311c0a04ee92da9cfef35

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
dennisrochecommented, Nov 6, 2021

@anymaniax is this up-for-grabs?

0reactions
anymaniaxcommented, Dec 2, 2021

Closing this issue since it’s normally fixed. Don’t hesitate if you have any problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Names | Databricks on AWS
In this article: Catalog name; Schema name; Database name; Table name; View name; Column name; Field name; Function name; Parameter name; Table ...
Read more >
Reserved schema names and reserved words - IBM
It is strongly recommended that schema names never begin with the 'SYS' prefix, because 'SYS', by convention, is used to indicate an area...
Read more >
What Is a Schema in SQL and Advantages of Using Schema
In a SQL database, a schema is a list of logical structures of data. A database user owns the schema, which has the...
Read more >
How do I list all tables in a schema in Oracle SQL?
To see all tables in another schema, you need to have one or more of the following system privileges: SELECT ANY DICTIONARY (SELECT...
Read more >
CREATE SCHEMA | CockroachDB Docs
The CREATE SCHEMA statement creates a new user-defined schema. ... The schema name must be unique within its database and follow these identifier...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found