Add oas30 and yaml files to upload - #4
Conversation
|
@babyhuey - thanks for the PR.. do you think it'll be better to ask from the user in the config that what swagger doc he/she would like rather than just uploading all the types to s3? |
|
@rrahul963 Yea, I was thinking about that after making the pull request. I'm still super new to JS, so I will give it a try and update the pull request. |
…iles. Renamed getBucketAndKey to getServerlessOptions.
|
Ok, I took a swing at it. I added 2 new optional settings for the serverless file, and I tested it on my software and it seems to work correctly. |
| const { bucket, key } = getBucketAndKey(serverless) | ||
| const { bucket, key, openapi, yaml } = getServerlessOptions(serverless) | ||
| const apiName = await getApiName(serviceName, stage, region, awsCredentials) | ||
| const swagger = await getSwagger(apiName, stage, region, awsCredentials) |
There was a problem hiding this comment.
@babyhuey i think we should check for the new options here itself
if (openapi) {
if (yaml) {
//get yaml openapi and upload it
} else {
//get json openapi and upload it
}
} else {
if (yaml) {
//get swagger yaml and upload it
} else {
//get swagger json and upload it
}
}
There was a problem hiding this comment.
Hmm. I set it up the way I did because I wanted all 4 styles uploaded. If I understand this correctly, it will only upload one file, correct?
There was a problem hiding this comment.
yes my update will upload only one version, is there a reason why one would need all the versions uploaded?
| const oas30yaml = await getOpenapiYaml(apiName, stage, region, awsCredentials) | ||
| const swaggerKey = `${key}-swagger.json` | ||
| await uploadSwaggerToS3(swagger, bucket, swaggerKey, region, awsCredentials) | ||
| if (typeof openapi !== 'undefined') { |
There was a problem hiding this comment.
rather than checking for !== 'undefined' can you change this to === true.. do this everywhere you are checking
Not sure if this is something you would like merged back into your repo, but I have added the open api 3.0 files and also upload of json+yaml.
If you do not want this merged back into your project, would you be ok with me releasing this as a new plugin for serverless?