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.

TypeError: json_1.extractPointerFromRef is not a function

See original GitHub issue

Describe the bug Rule ‘oas3-unused-components-schema’ causes an error.

To Reproduce

  1. Given this OpenAPI document:
openapi: 3.0.1
info:
  title: Test
  version: v1
  description: "Description"
  license:
    name: None
    url: https://www.google.com/legal
servers:
  - description: Prism mock server
    url: http://localhost:4010
tags:
  - name: sessions
paths:
  /sessions:
    description: Desc
    post:
      operationId: createSession
      description: Creates a new session
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                device:
                  description: Device information
                  type: string
              required:
                - device
      responses:
        '201':
          description: Session has been created successfully
          headers:
            x-rds-context:
              description: Session context data that is shared by all future requests
              schema:
                type: string
      tags:
      - sessions
components:
  schemas:
    ErrorItem:
      $ref: https://pastebin.com/raw/8YRYeFUY
  1. Run this CLI command: spectral lint openapi.yaml
  2. See error message:
OpenAPI 3.x detected
Encountered error when running rule 'oas3-unused-components-schema' on node at path '$,components,schemas':
TypeError: json_1.extractPointerFromRef is not a function
 
undefined
2:6   warning  info-contact  Info object should contain `contact` object.
43:15    error  oas3-schema   `ErrorItem` property type should be object
 
✖ 2 problems (1 error, 1 warning, 0 infos, 0 hints)

Expected behavior No type errors in the output and something better than undefined below it would be nice.

Environment:

  • Library version: 5.0.0

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
nulltokencommented, Feb 11, 2020

@lehphyro Below the output when running the provided openapi spec against the development branch:

$ yarn cli lint repro/openapi.yaml
yarn run v1.19.2
$ node -r ts-node/register -r tsconfig-paths/register src/cli/index.ts lint repro/openapi.yaml
[...snipped development warnings...]
OpenAPI 3.x detected
[...snipped development warnings...]

h:/spectral/repro/openapi.yaml
  2:6   warning  info-contact                   Info object should contain `contact` object.
 43:15  warning  oas3-unused-components-schema  Potentially unused components schema has been detected.

✖ 2 problems (0 errors, 2 warnings, 0 infos, 0 hints)

Looks like the undefined thingie has been fixed as well (Probably by #900)

0reactions
lehphyrocommented, Mar 29, 2020

No, it’s not, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

uncaught TypeError: undefined is not a function when using ...
mymood is undefined so you are not able to do a forEach of something that doesn't exist. Try validating things and avoid null...
Read more >
TypeError: response.json is not a function in JavaScript
The "response. json is not a function" error occurs when we call the json() method on an object that is not the Response...
Read more >
typeof - JavaScript - MDN Web Docs - Mozilla
The typeof operator returns a string indicating the type of the operand's value.
Read more >
Interacting with code — Emscripten 3.1.26-git (dev ...
EXPORTED_FUNCTIONS tells the compiler what we want to be accessible from the compiled code (everything else might be removed if it is not...
Read more >
RFC 6901: JavaScript Object Notation (JSON) Pointer
Code Components extracted from this document must include Simplified BSD License text as described ... RFC 6901 JSON Pointer April 2013 Table of...
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