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

Test src/openapi3/handleJson.test.ts fails #126

Closed
ricfio opened this issue Dec 1, 2022 · 0 comments · Fixed by #127
Closed

Test src/openapi3/handleJson.test.ts fails #126

ricfio opened this issue Dec 1, 2022 · 0 comments · Fixed by #127

Comments

@ricfio
Copy link

ricfio commented Dec 1, 2022

API Doc Parser version(s) affected: 0.5.0

Description

Test src/openapi3/handleJson.test.ts fails

How to reproduce

yarn install
yarn run test

Possible Solution

Fixing typescript code.

Additional Context

tsc -v

Version 4.8.4

yarn run test

yarn run v1.22.19
$ NODE_OPTIONS=--experimental-vm-modules jest
(node:8739) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
 PASS  src/swagger/handleJson.test.ts
 PASS  src/hydra/fetchJsonLd.test.ts
 PASS  src/utils/getResources.test.ts
 FAIL  src/openapi3/handleJson.test.ts
  ● Test suite failed to run

    src/openapi3/handleJson.ts:14:15 - error TS2322: Type 'T | ReferenceObject' is not assignable to type 'object'.
      Type 'T' is not assignable to type 'object'.

    14   !("$ref" in maybeRef);
                     ~~~~~~~~

      src/openapi3/handleJson.ts:13:16
        13 const isRef = <T>(maybeRef: T | OpenAPIV3.ReferenceObject): maybeRef is T =>
                          ~
        This type parameter might need an `extends object` constraint.
    src/openapi3/handleJson.ts:180:10 - error TS2352: Conversion of type 'undefined' to type 'SchemaObject' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    180       ? (get(
                 ~~~~
    181           editOperation,
        ~~~~~~~~~~~~~~~~~~~~~~~~
    182           "requestBody.content.application/json.schema"
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    183         ) as OpenAPIV3.SchemaObject)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 FAIL  src/hydra/parseHydraDocumentation.test.ts
  ● Test suite failed to run

    src/hydra/parseHydraDocumentation.ts:149:26 - error TS2352: Conversion of type 'undefined' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    149       const onProperty = get(
                                 ~~~~
    150         range,
        ~~~~~~~~~~~~~~
    151         '["http://www.w3.org/2002/07/owl#equivalentClass"][0]["http://www.w3.org/2002/07/owl#onProperty"][0]["@id"]'
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    152       ) as string;
        ~~~~~~~~~~~~~~~~~
    src/hydra/parseHydraDocumentation.ts:153:29 - error TS2352: Conversion of type 'undefined' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    153       const allValuesFrom = get(
                                    ~~~~
    154         range,
        ~~~~~~~~~~~~~~
    155         '["http://www.w3.org/2002/07/owl#equivalentClass"][0]["http://www.w3.org/2002/07/owl#allValuesFrom"][0]["@id"]'
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    156       ) as string;
        ~~~~~~~~~~~~~~~~~
    src/hydra/parseHydraDocumentation.ts:256:37 - error TS2352: Conversion of type 'undefined' to type 'ExpandedRdfProperty' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    256           const supportedProperty = get(
                                            ~~~~
    257             supportedProperties,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    258             '["http://www.w3.org/ns/hydra/core#property"][0]'
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    259           ) as ExpandedRdfProperty;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/hydra/parseHydraDocumentation.ts:261:25 - error TS2352: Conversion of type 'null' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    261           const range = get(
                                ~~~~
    262             supportedProperty,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ... 
    264             null
        ~~~~~~~~~~~~~~~~
    265           ) as string;
        ~~~~~~~~~~~~~~~~~~~~~

Test Suites: 2 failed, 3 passed, 5 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        3.349 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ricfio@LENOVO:~/projects/api-platform/api-doc-parser$ yarn run test
yarn run v1.22.19
$ NODE_OPTIONS=--experimental-vm-modules jest
(node:8874) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
 PASS  src/swagger/handleJson.test.ts
 PASS  src/hydra/fetchJsonLd.test.ts
 PASS  src/utils/getResources.test.ts
 FAIL  src/openapi3/handleJson.test.ts
  ● Test suite failed to run

    src/openapi3/handleJson.ts:14:15 - error TS2322: Type 'ReferenceObject | T' is not assignable to type 'object'.
      Type 'T' is not assignable to type 'object'.

    14   !("$ref" in maybeRef);
                     ~~~~~~~~

      src/openapi3/handleJson.ts:13:16
        13 const isRef = <T>(maybeRef: T | OpenAPIV3.ReferenceObject): maybeRef is T =>
                          ~
        This type parameter might need an `extends object` constraint.
    src/openapi3/handleJson.ts:180:10 - error TS2352: Conversion of type 'undefined' to type 'SchemaObject' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    180       ? (get(
                 ~~~~
    181           editOperation,
        ~~~~~~~~~~~~~~~~~~~~~~~~
    182           "requestBody.content.application/json.schema"
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    183         ) as OpenAPIV3.SchemaObject)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 FAIL  src/hydra/parseHydraDocumentation.test.ts
  ● Test suite failed to run

    src/hydra/parseHydraDocumentation.ts:149:26 - error TS2352: Conversion of type 'undefined' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    149       const onProperty = get(
                                 ~~~~
    150         range,
        ~~~~~~~~~~~~~~
    151         '["http://www.w3.org/2002/07/owl#equivalentClass"][0]["http://www.w3.org/2002/07/owl#onProperty"][0]["@id"]'
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    152       ) as string;
        ~~~~~~~~~~~~~~~~~
    src/hydra/parseHydraDocumentation.ts:153:29 - error TS2352: Conversion of type 'undefined' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    153       const allValuesFrom = get(
                                    ~~~~
    154         range,
        ~~~~~~~~~~~~~~
    155         '["http://www.w3.org/2002/07/owl#equivalentClass"][0]["http://www.w3.org/2002/07/owl#allValuesFrom"][0]["@id"]'
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    156       ) as string;
        ~~~~~~~~~~~~~~~~~
    src/hydra/parseHydraDocumentation.ts:256:37 - error TS2352: Conversion of type 'undefined' to type 'ExpandedRdfProperty' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    256           const supportedProperty = get(
                                            ~~~~
    257             supportedProperties,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    258             '["http://www.w3.org/ns/hydra/core#property"][0]'
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    259           ) as ExpandedRdfProperty;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/hydra/parseHydraDocumentation.ts:261:25 - error TS2352: Conversion of type 'null' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

    261           const range = get(
                                ~~~~
    262             supportedProperty,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ... 
    264             null
        ~~~~~~~~~~~~~~~~
    265           ) as string;
        ~~~~~~~~~~~~~~~~~~~~~

Test Suites: 2 failed, 3 passed, 5 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        3.679 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
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

Successfully merging a pull request may close this issue.

1 participant