Conversation
support multiple output files One file per key in the spec definitions. The SwaggerParser library does not show results when the swagger file is large (>10000 lines)
martinmcwhorter
left a comment
There was a problem hiding this comment.
needs a some work
| }, | ||
| "definitions": { | ||
| "AddressModel": { | ||
| "required": ["firstName", "lastName", "address", "city", "postalCode", "emailAddress", "country"], |
There was a problem hiding this comment.
We are losing the validation rules here.
| @@ -0,0 +1,17 @@ | |||
| { | |||
There was a problem hiding this comment.
Exclude this file in the .gitignore
|
|
||
| Run the following from the `/demo` directory: | ||
|
|
||
| open https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml |
There was a problem hiding this comment.
We don't wan't manual steps here.
The petstore swagger is lacking in validation rules, making it inadequate for the demo.
| @@ -0,0 +1,819 @@ | |||
| openapi: 3.0.2 | |||
There was a problem hiding this comment.
Not sure why this is here, accidental commit?
| description: 'Generated file name', | ||
| type: 'string' | ||
| }) | ||
| .option('multiplefiles', { |
There was a problem hiding this comment.
This should be hyphenated multiple-files
| .alias('help', 'h').argv; | ||
|
|
||
| const spec = await loadSpec(argv['input-spec']); | ||
| const args = new Args( |
There was a problem hiding this comment.
A factory literal is probably better than a class here.
const args = { inputSpec: argv['input-spec'], output: argv.output, fileName: argv['fileName'], multipleFiles: argv['multiple-files'] };
If you want to use a class, keep it simple:
export class Args {
constructor(
public inputSpec: string,
public output: string,
public fileName: string,
public multipleFiles: string
) {}
}
Actually, we shouldn't need to do any of this. Yargs returns a static type for us https://github.com/yargs/yargs/blob/main/docs/typescript.md
| ); | ||
| //const inputfile=args.inputspec; | ||
| const inputfile=argv['input-spec']; | ||
| console.log('start load spec(' + inputfile + ') ...'); |
There was a problem hiding this comment.
Too busy on the console.logs
| } | ||
|
|
||
| await saveFile(file, fileName); | ||
| console.log((success)?'Completed.':'Finished with errors.'); |
There was a problem hiding this comment.
We would never get here on an error. Did you mean to do a try/catch?
Support multiple output files
One file per key in the spec definitions.
Discovered feature: works fine on PetStor, but the SwaggerParser library does not show results when the swagger file is large (>10000 lines)