-
Clone the swagger-codegen repo, checkout the branch "2.3.0"
-
mvn clean package
-
Create a shell script to make it easier to run your version of swagger-codegen:
/usr/local/bin/swagger-codegen-2.3.0 #!/bin/bash exec java -jar ~/Code/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar "$@"
-
Navigate to your swagger specification
-
Create a config file for swagger-codegen. It will specify the name and metadata of the generated library. I called mine
swagger-codegen.config.json
{ "podSummary": "PetstoreClient", "podHomepage": "https://github.com/petshopboys/PetstoreClient-swift", "podAuthors": "Pet Shop Boys", "projectName": "PetstoreClient" }
-
Generate your code. Put it in its own repository and put it in the root of your xcode project. I will not judge you.
swagger-codegen-2.3.0 generate -l swift3 -i swagger.yaml -c swagger-codegen.config.json -o ~/Code/PetstoreClient
-
Add an entry to your project's Podfile to add your client library to your project.
pod "PetstoreClient", :path => "./PetstoreClient/"
Change the path parameter to point to the directory where the generated code was output. The path in the example above works when the code has been placed in the root directory of the project.
-
I thought the Podfile path would be "./". How come I had to specify the directory?
-
What about the tests? Something about setting inherit_paths.