-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: main
Are you sure you want to change the base?
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)
There was a problem hiding this 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"], |
There was a problem hiding this comment.
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 @@ | |||
{ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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', { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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 + ') ...'); |
There was a problem hiding this comment.
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.'); |
There was a problem hiding this comment.
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?
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)