sw2dts
sw2dts copied to clipboard
"Error: There is no schema in the input contents." openapi v3 only
Hello @mstssk ,
I'm trying to use your wrapper; however, it's erroring out when I try to use it to consume OpenAPI files of version 3. I used this one: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
Here is the error:
Error: There is no schema in the input contents. at SchemaConvertor.buildSchemaMergedMap (/private/tmp/sd/node_modules/dtsgenerator/dist/core/schemaConvertor.js:68:19) at DtsGenerator.
(/private/tmp/sd/node_modules/dtsgenerator/dist/core/dtsGenerator.js:25:46) at step (/private/tmp/sd/node_modules/tslib/tslib.js:136:27) at Object.next (/private/tmp/sd/node_modules/tslib/tslib.js:117:57) at fulfilled (/private/tmp/sd/node_modules/tslib/tslib.js:107:62) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:745:11) at startup (internal/bootstrap/node.js:279:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)
EDIT:
OK, so it kinda works if the -w
flag is used. However, even then, the result is incomplete: many paths are missing from the result.
For example, here's a version 3 example from US National Weather Service: https://api.weather.gov/openapi.json
export interface Alerts {
active?: any;
start?: any;
end?: any;
status?: any;
message_type?: any;
event?: any;
code?: any;
region_type?: any;
point?: any;
region?: any;
area?: any;
zone?: any;
urgency?: any;
severity?: any;
certainty?: any;
limit?: any;
cursor?: any;
}
export interface AlertsActive {
status?: any;
message_type?: any;
event?: any;
code?: any;
region_type?: any;
point?: any;
region?: any;
area?: any;
zone?: any;
urgency?: any;
severity?: any;
certainty?: any;
limit?: any;
}
export interface Products {
location?: any;
start?: any;
end?: any;
office?: any;
wmoid?: any;
type?: any;
limit?: any;
}
export interface Stations {
id?: any;
state?: any;
limit?: any;
}
export interface Zones {
id?: any;
area?: any;
region?: any;
type?: any;
point?: any;
include_geometry?: any;
effective?: any;
}
Thank you for your report! @paxperscientiam Sorry. sw2dts does not support OpenAPI v3 currently.
I published beta version for support OpenAPI v3 experimentally. [email protected] Could you try this beta version? I hope your problem will be solved with this.
However this version is just workaround. And I'm busy at work recently. So I don't have enough time to make sw2dts is supports OpenAPI v3 correctly. 🙇
Thank you for the clarification, @mstssk . I will surely give the beta a shot. Take care.
OK, so the beta does kinda work. One problem, however, is that variable paths are bypassed.
EG:. "/alerts/{id}"
from the NWS openapi file: https://gist.github.com/paxperscientiam/97a6e8f120797cefd18440400f58f120
+1 , pls support Open API version3. I used this tool to convert open api3 to swagger v2
@mstssk for me the beta version has this error :
Error: unknown type: string|null
at Object.toTSType (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/utils.js:24:19)
at DtsGenerator.generateTypeName (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:296:28)
at DtsGenerator.generateType (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:279:18)
at DtsGenerator.generateTypeProperty (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:206:18)
at DtsGenerator.generateProperties (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:157:26)
at DtsGenerator.generateTypeName (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:302:18)
at DtsGenerator.generateType (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:279:18)
at DtsGenerator.generateTypeProperty (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:206:18)
at DtsGenerator.generateArrayTypeProperty (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:231:18)
at DtsGenerator.generateTypeName (/USER/.nvm/versions/node/v10.16.1/lib/node_modules/sw2dts/node_modules/dtsgenerator/dist/core/dtsGenerator.js:306:18)