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

adding nodejs-v2 and python3-v2 #28

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

SamWSoftware
Copy link
Collaborator

Adding two basic repos. I've tested these and they will both compile and run sls offline to show the swagger.

Later it would be cool to generate the swagger then to do some tests on it to make sure that everything is where it's supposed to be. Kind of like smoke tests.

@SamWSoftware SamWSoftware requested a review from bfaulk96 February 5, 2022 17:52
@SamWSoftware
Copy link
Collaborator Author

I need to work out why things are breaking in Node 12 and 14

@SamWSoftware SamWSoftware marked this pull request as draft February 6, 2022 13:00
@bfaulk96
Copy link
Collaborator

bfaulk96 commented Feb 7, 2022

It's a little sneaky, but looks like the generation itself is failing in GH Actions..

generating swagger files in all test repos...error

count: {
required: false,
type: 'integer',
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

We will probably want an additional parameter to cover the optional required param:

Suggested change
},
},
notRequired: {
type: 'string',
description: 'this param should be optional'
},

authorisation: {
required: true,
description: 'the authorisation token',
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, should cover the other branches of implicit and explicit required === false

Suggested change
},
},
explicitOptional: {
required: false,
description: 'this header is optional',
},
implicitOptional: {
description: 'this header is implicitly optional',
},

"license": "ISC",
"devDependencies": {
"serverless-auto-swagger": "file:../../../serverless-auto-swagger",
"serverless-offline": "^7.1.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't these also point to the root folder? Would be better to have serverless-offline installed at the root as a devDep once than for each of Node and Python serverless to install the same version separately

"license": "ISC",
"devDependencies": {
"serverless-auto-swagger": "file:../../../serverless-auto-swagger",
"serverless-offline": "^7.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same q here

expect(paths.length).toEqual(3);

const definitions = Object.keys(swaggerJson.definitions);
expect(definitions.length).toEqual(4);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably make a TODO or file an Issue to add actual parameter validation here instead of simply checking the lengths, right?

Comment on lines +8 to +9
swaggerJson = JSON.parse(fileText.slice(60));
// change the 60 char if the comment at the start of the swagger.py file changes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you explain this one to me? There's probably a simpler way to do this, i.e. slicing the file at the index where we find whatever the python comment is

Copy link
Collaborator

Choose a reason for hiding this comment

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

That way it would always be dynamic

process.stdout.write('generating swagger files in all test repos...');

// could add some logic in here to decide whether to run the swagger generate or not
// Only required when running the smoke tests. so ignote when running unit tests
Copy link
Collaborator

Choose a reason for hiding this comment

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

😄

Suggested change
// Only required when running the smoke tests. so ignote when running unit tests
// Only required when running the smoke tests. so ignore when running unit tests

Comment on lines +16 to +17
console.log('error');
resolve(1);
Copy link
Collaborator

@bfaulk96 bfaulk96 Feb 7, 2022

Choose a reason for hiding this comment

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

Don't we want this to reject on error?

Suggested change
console.log('error');
resolve(1);
console.error('Error generating swagger', err);
reject(err);

Comment on lines +21 to +23
console.log('stderr');
resolve(1);
return;
Copy link
Collaborator

@bfaulk96 bfaulk96 Feb 7, 2022

Choose a reason for hiding this comment

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

Same question here

Suggested change
console.log('stderr');
resolve(1);
return;
console.log('Error generating swagger', stderr);
reject(stderr);
return;

@bfaulk96 bfaulk96 force-pushed the master branch 3 times, most recently from 043c27b to 32d78d6 Compare February 9, 2022 15:22
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