Skip to content

Add oas30 and yaml files to upload - #4

Open
babyhuey wants to merge 5 commits into
rrahul963:masterfrom
babyhuey:master
Open

Add oas30 and yaml files to upload#4
babyhuey wants to merge 5 commits into
rrahul963:masterfrom
babyhuey:master

Conversation

@babyhuey

Copy link
Copy Markdown

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?

@rrahul963

rrahul963 commented Feb 27, 2019

Copy link
Copy Markdown
Owner

@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?
Also, can you please update the version in package.json and package-lock.json.

@babyhuey

Copy link
Copy Markdown
Author

@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.

Justin Lyons added 2 commits February 27, 2019 09:46
@babyhuey

Copy link
Copy Markdown
Author

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.

Comment thread src/index.js
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)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@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
  }
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

yes my update will upload only one version, is there a reason why one would need all the versions uploaded?

Comment thread src/index.js
const oas30yaml = await getOpenapiYaml(apiName, stage, region, awsCredentials)
const swaggerKey = `${key}-swagger.json`
await uploadSwaggerToS3(swagger, bucket, swaggerKey, region, awsCredentials)
if (typeof openapi !== 'undefined') {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

rather than checking for !== 'undefined' can you change this to === true.. do this everywhere you are checking

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