Skip to content

Cannot find name 'ref' #345

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

Closed
Diokuz opened this issue Oct 27, 2020 · 1 comment · Fixed by #383
Closed

Cannot find name 'ref' #345

Diokuz opened this issue Oct 27, 2020 · 1 comment · Fixed by #383
Labels
bug Something isn't working

Comments

@Diokuz
Copy link

Diokuz commented Oct 27, 2020

Same as #265

I have an OpenAPI json like that:

{
  "swagger": "2.0",
  "definitions": {
    "Messages": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/Message"
      }
    },
    "Message": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer"
        },
        "text": {
          "type": "string"
        }
      }
    }
  }
}

Which results in typescript:

export interface definitions {
  Messages: { [key: string]: ref }
  Message: { code?: number; text?: string }
}

It is not valid, because of ref. What is ref, and why it is not defined?

 openapi-typescript --version
✨ openapi-typescript 2.2
@drwpow
Copy link
Contributor

drwpow commented Nov 9, 2020

Ah seems like a bug. Will investigate this week!

@drwpow drwpow added the bug Something isn't working label Nov 9, 2020
atlefren added a commit to atlefren/swagger-to-ts that referenced this issue Nov 24, 2020
drwpow pushed a commit that referenced this issue Nov 26, 2020
* handle case where additionalRef is a ref (fixes #345)

* move isOpenAPI2Reference to utils, as build-script crashes when it is in /types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants