Skip to content

Instantly share code, notes, and snippets.

View cortinico's full-sized avatar
♦️
Reticulating splines...

Nicola Corti cortinico

♦️
Reticulating splines...
View GitHub Profile
@cortinico
cortinico / DefaultApi.kt
Created October 30, 2019 09:43
Example of a common parameter swapping scenario with swagger-gradle-codegen
interface DefaultApi {
/**
* Find a Business by its owner name and surname.
*/
@GET("/business/owner")
fun getBusinessByOwner(
@retrofit2.http.Query("surname") surname: String
@retrofit2.http.Query("name") name: String
): Single<List<Business>>
}
@cortinico
cortinico / IdToInfoForPhotoUploadSuggestionMapToBusinessReviewMap.kt
Created October 30, 2019 09:42
Example of a generated name for a data class
data class IdToInfoForPhotoUploadSuggestionMapToBusinessReviewMap(
// ...
)
@cortinico
cortinico / build.gradle
Created October 30, 2019 09:42
Implementation dependencies for swagger-gradle-codegen generated artifacts
implementation "com.yelp.android.apis:mobileapi:13.20191020212515.0"
implementation "com.yelp.android.apis:bizapp:13.20191020212515.0"
@cortinico
cortinico / DefaultApi.kt
Created October 30, 2019 09:41
Generated Retrofit interface from swagger-gradle-codegen
interface DefaultApi {
/**
* Find business by ID
* Returns a single Business by its ID
* @param businessId ID of Business to return (required)
*/
@GET("/business/{businessId}")
fun getBusinessById(
@retrofit2.http.Path("businessId") businessId: Long
): Single<Business>
@cortinico
cortinico / Business.kt
Created October 30, 2019 09:40
Generated Business class from swagger-gradle-codegen
/**
* Represents a specific Business on Yelp
* @property category Optional category of the business
* @property id Unique ID of this Business
* @property name Name of this specific Business
* @property photoUrls Photo URls for this Business
* @property status Status of this Business on Yelp
*/
data class Business (
@Json(name = "id") var id: Long,
@cortinico
cortinico / Category.kt
Created October 30, 2019 09:40
Generated Category classes from swagger-gradle-codegen
/**
* A Category used to group businesses on Yelp
* @property id Unique ID of the Category
* @property name Name of this category
*/
data class Category(
@Json(name = "id") var id: Long? = null,
@Json(name = "name") var name: String? = null
)
@cortinico
cortinico / build.gradle
Created October 30, 2019 09:39
swagger-gradle-codegen Configuring generate swagger to depend on preBuild
preBuild.dependsOn(tasks.getByName(“generateSwagger"))
@cortinico
cortinico / build.gradle
Created October 30, 2019 09:37
swagger-gradle-codegen Gradle Configuration Block
plugins {
id("com.yelp.codegen.plugin") version "<latest_version>"
}
generateSwagger {
platform = "kotlin"
packageName = "com.yelp.codegen.samples"
inputFile = file("./sample_specs.json")
outputDir = file("./src/main/java/")
}
@cortinico
cortinico / sample-yelp-api-specs.json
Created October 21, 2019 16:14
Sample Swagger Spec for a Yelp API
{
"definitions": {
"Category": {
"description": "A Category used to group businesses",
"properties": {
"id": {
"description": "Unique ID of the Category",
"format": "int64",
"type": "integer"
},
@cortinico
cortinico / Makefile
Last active January 28, 2019 13:52
Circle CI setup for builing and publishing LaTeX files
CC = xelatex
SRC_DIR = "."
OUT_DIR = "."
SRC = $(shell find $(SRC_DIR) -name '*.tex')
# Build All
build: $(SRC)
$(CC) -output-directory=$(OUT_DIR) $<