Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multifile arg #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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

@@ -4,6 +4,12 @@ Be sure to build the ngx-form-generator tool first by running `npm run build` in

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?

@@ -30,6 +33,11 @@ async function main(): Promise<void> {
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

@@ -38,17 +46,68 @@ async function main(): Promise<void> {
.example('npx ngx-form-generator -i swagger.json -o project/form/src/lib')
.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