Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Skip all Documentation Parts overwriting in case of shared API Gateway usage. #121

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

YurgenUA
Copy link

tackling this problem: #106.

As of today plugin removes all doc-parts before deploying modified changed documentation. While this approach works ok in majority cases, it fails when API Gateway instance is reused by many sls deployments (and this scheme is more frequent approach as developers build more complicated APIs).
This PR introduce a piece of functionality which helped me to keep up with API documentation functionality having roughly dozen individual serverless.yml deploying under one API Gateway.

New function _isSharedApi() uses serverless.yml information to return if API is being deployed is in standalone mode (which are any deployment so far, since plugin correctly refreshed Documentation for that cases) or uses (shares) pre-existing API Gateway per https://serverless.com/framework/docs/providers/aws/events/apigateway#share-api-gateway-and-api-resources.

If deploying API is standalone, execution logic stays the same, i.e. all doc-parts removed and than recreated from deployment.
If deploying API is shared, only those doc-parts which belongs to current service (new property 'serverless-service' saved with each doc-part) removed and recreated. Thus, all other doc-parts, belonging to main service, or other dependent services are left untouched.

@codecov-io
Copy link

codecov-io commented Aug 19, 2019

Codecov Report

Merging #121 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #121   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           8      8           
  Lines         437    453   +16     
  Branches       60     63    +3     
=====================================
+ Hits          437    453   +16
Impacted Files Coverage Δ
src/documentation.js 100% <100%> (ø) ⬆️
src/models.spec.js 100% <0%> (ø) ⬆️
src/downloadDocumentation.spec.js 100% <0%> (ø) ⬆️
src/downloadDocumentation.js 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78a81be...d3c6373. Read the comment docs.

@tchock
Copy link
Contributor

tchock commented Nov 12, 2019

Hey @YurgenUA,
thanks for contributing!
Can you add tests for this one please?
Then I can merge it

@YurgenUA
Copy link
Author

@tchock I added unit test to invoke code changes and return coverage to 100% back.
Hope PR is possible to merge.... we use this in our production for couple months without problem.

@AYM1607
Copy link

AYM1607 commented Jan 7, 2020

Any plans of merging this?

@PatrykMilewski
Copy link

@tchock Can you please merge it and release a new version?

@PatrykMilewski
Copy link

If anyone is interested, the workaround is to clone repo with pull request and provide it as local serverless plugin, more details here:
https://serverless.com/framework/docs/providers/aws/guide/plugins#service-local-plugin

@YurgenUA
Copy link
Author

Another possible workaround is to reference git repository directly in project.json, like

"serverless-aws-documentation": "https://github.com/YurgenUA/serverless-aws-documentation.git",

both npm & yarn support it. Even specific git commit can be specified

@gcampionpae
Copy link

@tchock I am also now using this fork and it would be great if this could be merged! Thanks @YurgenUA for the great work, this saved my day :)

@sime
Copy link

sime commented May 26, 2020

Hi!
We at Delivery Hero are not longer using this plugin.

Willing to hand it over to someone who is willing to carry the torch.

@gcampionpae
Copy link

HI @sime If I can ask, what did you switch to?

@sime
Copy link

sime commented May 27, 2020

Our swagger is now auto generated from our application.

https://docs.nestjs.com/recipes/swagger#openapi-swagger

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants