Forum Discussion

millseyK's avatar
millseyK
New Contributor
3 years ago

GitHub integration - controller keeps getting blown away

Hi,

We have set up integration with the version control system for our nodejs server in GitHub. Under Fully Managed Paths, I have put a reference to my controller which was previously generated from the openapi.yml file during my nodejs server stub generation (see attached file).

So my Fully Managed Paths looks like this:

api/*

controllers/FeaturesController.js

 

And my open api spec states that it needs this FeaturesController via:

x-swagger-router-controller: FeaturesController
x-eov-operation-handler: controllers/FeaturesController

But in GitHub, my FeaturesController keeps getting blown away whenever I synch my code. We just want it to stay in synch with the openapi.yml file. What are we doing wrong please?

Many thanks,

Katie

 

 

3 Replies

  • Hey millseyK; can you try putting the reference to the controller in Ignored Paths instead? Ignored paths will remain as is and will not be changed in any way by the integration, while Fully Managed Paths may still be overwritten. I think this could be the problem, but let me know if the controller is still getting overwritten when it's an Ignored Path and we'll see what we can do. Thanks!

    • millseyK's avatar
      millseyK
      New Contributor

      Hey joejoyce,

      Thanks so much for your reply. The issue is I actually want the controller file to be altered/regenerated when the API spec changes. Here is the essential question: can this tool regenerate the controller/routes definition file (depending on your web server implementation) when the API spec changes? Obviously the code is going to get out of synch with the yaml API spec otherwise. Or can the SwaggerHub tool not do this? Just need to know either way so I can plan for an alternative but it must be automated.

      Cheers,

      Katie

      • joejoyce's avatar
        joejoyce
        Staff

        Thanks for the clarification! So, given the way that the SCM synchs work, this should be possible:

         

        1: Spec changes in SwaggerHub, user presses save/triggers the integration.

        2: The SCM integration uses codegen to generate whatever new stubs are needed and pushes them to the specified repo. 

         

        This can be configured to happen every time the spec changes, thus making sure that the stub code in your SCM is always reflecting the spec. Have I understood your use case correctly? Some links here that might be useful:

         

        https://support.smartbear.com/swaggerhub/docs/apis/generating-code/server-stub.html

        https://support.smartbear.com/swaggerhub/docs/integrations/github-sync.html

         

        Let me know via direct message if you think a quick call/ screen-share would be helpful to get to the bottom of this if you still have questions!

         

        Joe