create-client icon indicating copy to clipboard operation
create-client copied to clipboard

Can't generate code from demo resource (React + OpenAPI3)

Open jfoliveira opened this issue 5 years ago • 2 comments

API Platform version(s) affected: latest, retrieved using npx

Description
Example command in README fails to execute when pointing to demo server using openapi3 format.

How to reproduce

  1. Create a new empty project following the steps in the documentation
  2. After the app is created, run the code generation command: npx @api-platform/client-generator https://demo.api-platform.com/docs.json src/ --resource Book --format openapi3

Expected result: React code would be generated

Actual result: An Exception has been raised:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at /Users/{myuser}/.npm/_npx/10629/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/handleJson.js:19:34
    at Array.map (<anonymous>)
    at Object.default_1 [as default] (/Users/{myuser}/.npm/_npx/10629/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/handleJson.js:16:27)
    at /Users/{myuser}/.npm/_npx/10629/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/parseOpenApi3Documentation.js:12:45

Possible Solution

Additional Context

jfoliveira avatar Feb 08 '20 04:02 jfoliveira

Same here.

bolner avatar Feb 20 '20 11:02 bolner

+1

ishapkin avatar Mar 14 '20 11:03 ishapkin

OpenAPI 3 support has been greatly improved in the client generator (and the underlying library) since https://github.com/api-platform/api-doc-parser/pull/108. There should no be major issue now.

alanpoulain avatar Aug 23 '22 13:08 alanpoulain