Coder Social home page Coder Social logo

openapistack / openapicmd Goto Github PK

View Code? Open in Web Editor NEW
42.0 4.0 6.0 2.65 MB

The CLI for all things OpenAPI and Swagger

Home Page: https://openapistack.co

License: MIT License

JavaScript 0.61% Batchfile 0.04% TypeScript 99.06% HTML 0.28%
openapi swagger cli hacktoberfest

openapicmd's Introduction

OpenAPI Command Line Tool

CI License npm version npm downloads npm type definitions Buy me a coffee

openapicmd - The CLI for all things OpenAPI and Swagger

Install

npm install -g openapicmd
openapi help

Features

  • Read and convert local and remote JSON/YAML OpenAPI definition files
  • Generate TypeScript types from OpenAPI definitions
  • Use as a CLI client to easily call API endpoints
  • Run Local Mock APIs
  • Automate API tests and validate specs
  • Run Swagger UI or ReDoc locally
  • Bundle static Swagger UI or ReDoc sites
  • Run Swagger Editor locally
  • Convert Swagger to OpenAPI

Commands

openapi help [COMMANDS]

Display help for openapi.

USAGE
  $ openapi help [COMMANDS] [-n]

ARGUMENTS
  COMMANDS  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for openapi.

See code: @oclif/plugin-help

Commercial support

For assistance with using openapicmd in your company, reach out at [email protected].

Contributing

openapicmd is Free and Open Source Software. Issues and pull requests are more than welcome!

openapicmd's People

Contributors

anttiviljami avatar d2s avatar dependabot[bot] avatar hannupekka avatar sureshkumars avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openapicmd's Issues

Error while generating types

Hi, thanks for the project!

I'm trying to generate types with bellow command, but I'm getting an error using the latest release.

npx openapicmd typegen https://developer.bling.com.br/build/assets/openapi-d5b45145.json > src/types/bling-openapi.d.ts

> npx openapicmd typegen bling-openapi-definition.json > src/types/bling-openapi.d.ts

DeprecationWarning: 'createTypeAliasDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createModuleDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createInterfaceDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
Error: unknown type: int
    at Object.toTSType (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/utils.js:33:19)
    at DtsGenerator.generateTypeName (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:431:30)
    at DtsGenerator.generateType (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:415:25)
    at DtsGenerator.generateTypeProperty (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:306:25)
    at DtsGenerator.generateArrayTypeProperty (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:367:31)
    at DtsGenerator.generateTypeName (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:450:25)
    at DtsGenerator.generateType (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:415:25)
    at DtsGenerator.generateTypeProperty (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:306:25)
    at DtsGenerator.generateProperties (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:258:84)
    at DtsGenerator.generateDeclareType (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapi-client-axios-typegen/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:232:34)

Outdated packages like @oclif/*, cli-ux, koa-proxy, and some more

Hi, thank you for this nice package!

Optimization Request

I'd like to discuss the possibility of automatically upgrading packages using a Github Actions (GHA) integration like Mend Renovate. Personally I have a lot of positive experience with this approach. One requirement is that GHA does run tests to ensure that the upgraded package does not break.

Please let me know your thoughts, and share if you see alternative approaches or if the proposed path is not suitable for your repository (and what is the impediment).

Context

When installing it I was a bit suprised to notice that a lot of packages are included, among which many are also not supported anymore. From my understanding the openapicmd CLI tool has a lot of features, so from my point of view its important to keep it up-to-date.

Expected result

When installing openapi-client-axios-typegen I was confronted with the fact that it only accepted JSON input. It was throwing (unclear) errors when I programatically called it with .yaml / .yml input. Of course, that is not related to this package.
It did mention in the README of said package that openapicmd typegen was a tool for calling openapi-client-axios-typegen. However when installing openapicmd as a dev dependency, my node_modules increased by about 40 to 50 MB and I got a lot of deprecation warnings. That's a bit much for simply a yaml to json conversion.

I guess I expected there to be yaml compatibility in openapi-client-axios-typegen using ts-yaml or js-yaml. It could be true that this CLI tool does much more than that, maybe a package split is better?

Installation output

This is the output when installing the CLI tool:
image

Total install size (Windows): 134 MB

And this is the list of (in-)direct dependencies:

info Direct dependencies
└─ [email protected]
info All dependencies
├─ @ampproject/[email protected]
├─ @apidevtools/[email protected]
├─ @apidevtools/[email protected]
├─ @apidevtools/[email protected]
├─ @apidevtools/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @bcoe/[email protected]
├─ @colors/[email protected]
├─ @cspotcode/[email protected]
├─ @exodus/[email protected]
├─ @isaacs/[email protected]
├─ @istanbuljs/[email protected]
├─ @jest/[email protected]
├─ @jest/[email protected]
├─ @jest/[email protected]
├─ @jest/[email protected]
├─ @jridgewell/[email protected]
├─ @jridgewell/[email protected]
├─ @jridgewell/[email protected]
├─ @koa/[email protected]
├─ @nodelib/[email protected]
├─ @nodelib/[email protected]
├─ @nodelib/[email protected]
├─ @npmcli/[email protected]
├─ @npmcli/[email protected]
├─ @npmcli/[email protected]
├─ @npmcli/[email protected]
├─ @npmcli/[email protected]
├─ @npmcli/[email protected]
├─ @npmcli/[email protected]
├─ @oclif/[email protected]
├─ @oclif/[email protected]
├─ @oclif/[email protected]
├─ @oclif/[email protected]
├─ @oclif/[email protected]
├─ @oclif/[email protected]
├─ @oclif/[email protected]
├─ @oclif/[email protected]
├─ @pkgjs/[email protected]
├─ @sigstore/[email protected]
├─ @sigstore/[email protected]
├─ @sinclair/[email protected]
├─ @sinonjs/[email protected]
├─ @sinonjs/[email protected]
├─ @tootallnate/[email protected]
├─ @tsconfig/[email protected]
├─ @tsconfig/[email protected]
├─ @tsconfig/[email protected]
├─ @tsconfig/[email protected]
├─ @tufjs/[email protected]
├─ @tufjs/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]

Package typegen missing from cli

How to reproduce?
Openapicmd version: 2.0.0-rc17
npm install -g openapicmd
openapi typegen
Error generated:

ModuleLoadError: [MODULE_NOT_FOUND] require failed to load /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/lib/commands/typegen.js: Cannot find module 'openapi-client-axios-typegen'
Require stack:

  • /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/lib/commands/typegen.js
  • /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/module-loader.js
  • /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/help/index.js
  • /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/flags.js
  • /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/cli-ux/styled/table.js
  • /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/cli-ux/styled/index.js
  • /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/cli-ux/index.js
  • /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/index.js
    at loadWithDataFromManifest (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/module-loader.js:113:19)
    at fetch (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/config/plugin.js:182:74)
    at Plugin.findCommand (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/config/plugin.js:200:27)
    at Object.load (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/config/plugin.js:244:36)
    at Config.runCommand (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/config/config.js:397:33)
    at run (/home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/node_modules/@oclif/core/lib/main.js:85:29)
    at async /home/leo/.nvm/versions/node/v18.15.0/lib/node_modules/openapicmd/bin/run.js:6:3

It only worked when I installed npm i -g openapi-client-axios-typegen

But typegen documentation says:

Tip: It's recommended to use openapicmd typegen to generate types instead of directly installing the openapi-client-axios-typegen package.

openapicmd call issue with param ?

i am trying to check out this project but having problem trying to call petstore example with a param, no matter what command line arguments i try the outgoing params:{} always stays empty, any ideas?

`
API=https://petstore3.swagger.io/api/v3/openapi.json ; npx -y openapicmd call -V -v -i --operation findPetsByStatus --param=status=sold

{
"method": "get",
"url": "/pet/findByStatus",
"params": {},
"headers": {
"Accept": "application/json, text/plain, /",
"Content-Type": "text/plain"
}
}
findPetsByStatus
GET /pet/findByStatus
RESPONSE META:
{
"code": 400,
"status": "Bad Request",
"headers": {
"date": "Sun, 17 Dec 2023 02:49:33 GMT",
"content-type": "application/json",
"content-length": "30",
"connection": "close",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET, POST, DELETE, PUT",
"access-control-allow-headers": "Content-Type, api_key, Authorization",
"access-control-expose-headers": "Content-Disposition",
"server": "Jetty(9.4.9.v20180320)"
}
}
RESPONSE BODY:
"No status provided. Try again?"
`

Remove referenced components after dereferencing

After a openapi read ./foo.json -f json -D > bar.json, parameters, schemas, requestBodies, responses and examples are still present in components. They are useless, since they have been dereferenced.

I dereferenced a 1500 lines file, and it gave me 9700 lines. After removing useless components, I went back to 4000 lines (which is a lot better).

read --strip openapi_client_axios should preserve responses

Hello and thank you for these repositories!

Following the documentation (for openapi-client-axios) and running:

npx openapicmd read --strip openapi_client_axios --format json openapi.json > openapi-runtime.json

Results in a definition file with stripped responses, due to removeResponses: true in PRESETS.openapi_client_axios.

const ALL: StripOptions = {
replaceInfo: true,
removeTags: true,
removeDescriptions: true,
removeExamples: true,
removeExtensions: true,
removeReadOnly: true,
removeSchemas: true,
removeSecuritySchemes: true,
removeServers: true,
replaceResponses: true,
removeResponses: true,
}

openapi_client_axios: {
...ALL,
removeServers: false, // openapi-client-axios uses servers
firstServerOnly: true, // openapi-client-axios only uses first server
},

Trying to use this definition file in openapi-client-axios like this:

import definitionJson from "./openapi-runtime.json";

import { OpenAPIClientAxios, OpenAPIV3 } from "openapi-client-axios";
 
 
let definition: OpenAPIV3.Document = definitionJson as OpenAPIV3.Document; 

const api = new OpenAPIClientAxios({
  definition,
});

Results in an error:

error TS2352: Conversion of type '{ openapi: string; info: { title: string; version: string; }; paths: { "/one_url": { post: { operationId: string; }; }; }; components: {}; }' to type 'Document<{}>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Types of property 'paths' are incompatible.
    Type '{ "/one_url": { post: { operationId: string; }; }; }' is not comparable to type 'PathsObject<{}, {}>'.
      Property '"/one_url"' is incompatible with index signature.
        Type '{ post: { operationId: string; }; }' is not comparable to type '{ $ref?: string | undefined; summary?: string | undefined; description?: string | undefined; servers?: ServerObject[] | undefined; parameters?: (ReferenceObject | ParameterObject)[] | undefined; } & { ...; }'.
          Type '{ post: { operationId: string; }; }' is not comparable to type '{ get?: { tags?: string[] | undefined; summary?: string | undefined; description?: string | undefined; externalDocs?: ExternalDocumentationObject | undefined; ... 7 more ...; servers?: ServerObject[] | undefined; } | undefined; ... 6 more ...; trace?: { ...; } | undefined; }'.
            Types of property 'post' are incompatible.
              Property 'responses' is missing in type '{ operationId: string; }' but required in type '{ tags?: string[] | undefined; summary?: string | undefined; description?: string | undefined; externalDocs?: ExternalDocumentationObject | undefined; ... 7 more ...; servers?: ServerObject[] | undefined; }'.

6 let definition: OpenAPIV3.Document = definitionJson as OpenAPIV3.Document;
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So essentially: Property 'responses' is missing in type. This is due to the open-api package (which is a dependency for openapi-client-axios) defining it as required since 2 years back.

https://github.com/kogosoftwarellc/open-api/blob/09fed6d77536b3d7d1d38a2630a096041da773ee/packages/openapi-types/index.ts#L356

  export type OperationObject<T extends {} = {}> = {
    tags?: string[];
    summary?: string;
    description?: string;
    externalDocs?: ExternalDocumentationObject;
    operationId?: string;
    parameters?: (ReferenceObject | ParameterObject)[];
    requestBody?: ReferenceObject | RequestBodyObject;
    responses: ResponsesObject;
    callbacks?: { [callback: string]: ReferenceObject | CallbackObject };
    deprecated?: boolean;
    security?: SecurityRequirementObject[];
    servers?: ServerObject[];
  } & T;

I see the warning: this will break validation when digging in the code of this repository, but this is very confusing as a first time user of these libraries. I assumed my definition file was somehow bad.

I'm submitting a PR where I add removeResponses: false to PRESETS.openapi_client_axios. I understand if you don't agree on that solution; some alternatives could be:

  • Update the docs to reflect that the stripping breaks validation in TypeScript (and advise the usage of ts-ignore or something else)
  • Provide your own overrides / types in openapi-client-axios that make responses optional again

Being a first time user, I might of course be mistaken in my assumptions...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.