Skip to content

Conversation

OzBob
Copy link

@OzBob OzBob commented Jul 28, 2022

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)

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)
Copy link
Contributor

@martinmcwhorter martinmcwhorter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a some work

},
"definitions": {
"AddressModel": {
"required": ["firstName", "lastName", "address", "city", "postalCode", "emailAddress", "country"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are losing the validation rules here.

@@ -0,0 +1,17 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is here, accidental commit?

description: 'Generated file name',
type: 'string'
})
.option('multiplefiles', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be hyphenated multiple-files

.alias('help', 'h').argv;

const spec = await loadSpec(argv['input-spec']);
const args = new Args(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + ') ...');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too busy on the console.logs

}

await saveFile(file, fileName);
console.log((success)?'Completed.':'Finished with errors.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would never get here on an error. Did you mean to do a try/catch?

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 this pull request may close these issues.

2 participants