ThumbWorks / DeckOfCards

1 stars 1 forks source link

Automate the yaml -> swift 5 generation -> update this repo #2

Open rodericj opened 4 years ago

rodericj commented 4 years ago

The current process to update this repo is the following:

  1. From swaggerhub, I was going to “export -> swift 5”.
  2. Extract the zip (could probably be done in commandline but i was double clicking in finder)
  3. cp ~/Downloads/swift5-client-generated/SwaggerClient/Classes/Swaggers/* ~/dev/DeckOfCards/Sources/DeckOfCards/
  4. git diff // To verify changes
  5. git add .
  6. git commit
  7. git push origin master
rodericj commented 4 years ago

One possibility is to use GitHub sync provided by swagger hub. https://app.swaggerhub.com/help/integrations/github-sync

It can push any saves to a branch. We can use these branches as a staging area before merging to master then tagging a release version. This is currently set up to use a branch called swaggerstaging: https://github.com/ThumbWorks/DeckOfCards/tree/Swaggerstaging.

Not bad. I did this on mobile and the file structure is different (master currently has a subset of what sync does) so we would need to test this out before merging this in.

rodericj commented 4 years ago

I've attempted to build the framework in the Swaggerstaging branch but with SPM the files all need to be in a specific directory:

'DeckOfCards' /Users/roderic/dev/DeckOfCards: error: Source files for target DeckOfCards should be located under 'Sources/DeckOfCards', or a custom sources path can be set with the 'path' property in Package.swift.

The issue is that the generator ends up putting all of the files into swift5/SwaggerGenerated or similar. Will need to reach out on the swagger hub forum https://community.smartbear.com/t5/SwaggerHub/ct-p/SwaggerHub

rodericj commented 4 years ago

Relevant, the json API can be downloaded like this: curl https://api.swaggerhub.com/apis/Thumbworks/DeckOfCards/1.0.0

We could set up a simple service which pulls that down, then follows the steps here: https://github.com/swagger-api/swagger-codegen#homebrew, then does the simple moving of the code into the correct format, then pushing to the repo. This would be awesome

rodericj commented 4 years ago

I've got a local server running this command: swagger-codegen generate -i https://api.swaggerhub.com/apis/Thumbworks/DeckOfCards/1.0.0/swagger.json -l swift5 -o /tmp/generatedCode/ I'm going to create a different repo for this and I'll likely be able to close this ticket.

rodericj commented 4 years ago

I've got a bit of a server working over here: https://github.com/ThumbWorks/DeckOfCardsServer. Currently this will fetch the yaml, generate the server code, then move it to the correct directory. It likely won't work on the server as I don't have access to install swagger-codegen