Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LagomScala] Add Scala API generator for lagomframework #6900 #6901

Merged
merged 7 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixed compile issue and improved formatting
  • Loading branch information
gmkumar2005 committed Nov 14, 2017
commit eb5f0ec05950cdd3869bb6e6e6249e440c3d8bb9
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,21 @@ trait {{classname}} extends Service {
{{#operation}}
{{#hasQueryParams}}
{{#queryParams}}{{#isContainer}}

// {{{paramName}}}:{{dataType}} -- not yet supported Seq PathParamSerializers for multi value query parameters https://github.com/lagom/lagom/issues/643
{{/isContainer}}{{/queryParams}}
{{/hasQueryParams}}
{{#hasFormParams}}{{#allParams}}
{{/isContainer}}{{/queryParams}}{{/hasQueryParams}}{{#hasFormParams}}{{#allParams}}
{{#isFormParam}}

// {{{paramName}}}:{{dataType}} -- not yet supported x-www-form-urlencoded
{{/isFormParam}}{{/allParams}}{{/hasFormParams}}

// {{{paramName}}}:{{dataType}} -- not yet supported x-www-form-urlencoded{{/isFormParam}}{{/allParams}}{{/hasFormParams}}{{#hasHeaderParams}}{{#allParams}}
{{#isHeaderParam}}
// {{{paramName}}}:{{dataType}} -- not yet supported heder params{{/isHeaderParam}}{{/allParams}}{{/hasHeaderParams}}
/**
* {{summary}}
* {{notes}}
* {{#allParams}} {{^isBodyParam}}
* @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/isBodyParam}}{{/allParams}}
* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}{{#bodyParams}} Body Parameter {{description}} {{/bodyParams}}
*/
def {{operationId}}({{#queryParams}}{{^isContainer}}{{^isEnum}}{{paramName}}:{{#required}}{{dataType}}{{#defaultValue}} /* = {{{defaultValue}}}*/{{/defaultValue}}{{/required}} {{^required}} Option[{{dataType}}]{{#defaultValue}} /* = {{{defaultValue}}}*/{{/defaultValue}}{{^defaultValue}} = None{{/defaultValue}}{{/required}}{{#hasMore}},{{/hasMore}}{{/isEnum}}{{/isContainer}}{{#isEnum}}{{{paramName}}}: Option[{{classname}}{{enumName}}.{{classname}}{{enumName}}]{{/isEnum}}{{/queryParams}}{{#pathParams}}{{^isEnum}}{{paramName}}: {{#required}}{{dataType}}{{#defaultValue}} /* = {{{defaultValue}}}*/{{/defaultValue}}{{/required}}{{^required}}Option[{{dataType}}]{{#defaultValue}} /* = {{{defaultValue}}}*/{{/defaultValue}}{{^defaultValue}} = None{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/isEnum}}{{#isEnum}}{{{paramName}}}: Option[{{classname}}{{enumName}}.{{classname}}{{enumName}}]{{/isEnum}}{{/pathParams}}): ServiceCall[{{#bodyParams}}{{dataType}}{{/bodyParams}}{{^hasBodyParam}}NotUsed{{/hasBodyParam}} ,{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Done{{/returnType}}]{{/operation}}{{/operations}}
def {{operationId}}({{#queryParams}}{{^isContainer}}{{^isEnum}}{{paramName}}:{{#required}}{{dataType}}{{#defaultValue}} /* = {{{defaultValue}}}*/{{/defaultValue}}{{/required}} {{^required}} Option[{{dataType}}]{{#defaultValue}} /* = {{{defaultValue}}}*/{{/defaultValue}}{{^defaultValue}} = None{{/defaultValue}}{{/required}}{{#hasMore}},{{/hasMore}}{{/isEnum}}{{/isContainer}}{{#isEnum}}{{{paramName}}}: Option[{{classname}}{{enumName}}.{{classname}}{{enumName}}]{{/isEnum}}{{/queryParams}}{{#pathParams}}{{^isEnum}}{{paramName}}: {{#required}}{{dataType}}{{#defaultValue}} /* = {{{defaultValue}}}*/{{/defaultValue}}{{/required}}{{^required}}Option[{{dataType}}]{{#defaultValue}} /* = {{{defaultValue}}}*/{{/defaultValue}}{{^defaultValue}} = None{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/isEnum}}{{#isEnum}}{{{paramName}}}: Option[{{classname}}{{enumName}}.{{classname}}{{enumName}}]{{/isEnum}}{{/pathParams}}): ServiceCall[{{#bodyParams}}{{dataType}}{{/bodyParams}}{{^hasBodyParam}}NotUsed{{/hasBodyParam}} ,{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Done{{/returnType}}]
{{/operation}}{{/operations}}

{{#operations}}
{{#operation}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ trait PetApi extends Service {
).withAutoAcl(true)
}



/**
* Add a new pet to the store
*
*
* @return void Body Parameter Pet object that needs to be added to the store
*/
def addPet(): ServiceCall[Pet ,Done]
def addPet(): ServiceCall[Pet ,Done]


// apiKey:String -- not yet supported heder params
/**
* Deletes a pet
*
Expand All @@ -57,58 +58,50 @@ trait PetApi extends Service {
* @param apiKey (optional)
* @return void
*/
def deletePet(petId: Long): ServiceCall[NotUsed ,Done]

def deletePet(petId: Long): ServiceCall[NotUsed ,Done]
// status:Seq[String] -- not yet supported Seq PathParamSerializers for multi value query parameters https://github.com/lagom/lagom/issues/643



/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
*
* @param status Status values that need to be considered for filter
* @return Seq[Pet]
*/
def findPetsByStatus(status: Option[PetApiStatusEnum.PetApiStatusEnum]): ServiceCall[NotUsed ,Seq[Pet]]

def findPetsByStatus(status: Option[PetApiStatusEnum.PetApiStatusEnum]): ServiceCall[NotUsed ,Seq[Pet]]
// tags:Seq[String] -- not yet supported Seq PathParamSerializers for multi value query parameters https://github.com/lagom/lagom/issues/643



/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*
* @param tags Tags to filter by
* @return Seq[Pet]
*/
def findPetsByTags(): ServiceCall[NotUsed ,Seq[Pet]]

def findPetsByTags(): ServiceCall[NotUsed ,Seq[Pet]]
/**
* Find pet by ID
* Returns a single pet
*
* @param petId ID of pet to return
* @return Pet
*/
def getPetById(petId: Long): ServiceCall[NotUsed ,Pet]

def getPetById(petId: Long): ServiceCall[NotUsed ,Pet]
/**
* Update an existing pet
*
*
* @return void Body Parameter Pet object that needs to be added to the store
*/
def updatePet(): ServiceCall[Pet ,Done]

def updatePet(): ServiceCall[Pet ,Done]

// name:String -- not yet supported x-www-form-urlencoded


// status:String -- not yet supported x-www-form-urlencoded


/**
* Updates a pet in the store with form data
*
Expand All @@ -118,15 +111,11 @@ trait PetApi extends Service {
* @param status Updated status of the pet (optional)
* @return void
*/
def updatePetWithForm(petId: Long): ServiceCall[NotUsed ,Done]

def updatePetWithForm(petId: Long): ServiceCall[NotUsed ,Done]

// additionalMetadata:String -- not yet supported x-www-form-urlencoded


// file:File -- not yet supported x-www-form-urlencoded


/**
* uploads an image
*
Expand All @@ -137,6 +126,7 @@ trait PetApi extends Service {
* @return ApiResponse
*/
def uploadFile(petId: Long): ServiceCall[NotUsed ,ApiResponse]


object PetApiStatusEnum extends Enumeration {
val available, pending, sold = Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ trait StoreApi extends Service {
).withAutoAcl(true)
}



/**
* Delete purchase order by ID
Expand All @@ -42,32 +41,33 @@ trait StoreApi extends Service {
* @param orderId ID of the order that needs to be deleted
* @return void
*/
def deleteOrder(orderId: String): ServiceCall[NotUsed ,Done]

def deleteOrder(orderId: String): ServiceCall[NotUsed ,Done]
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
*
* @return Map[String, Int]
*/
def getInventory(): ServiceCall[NotUsed ,Map[String, Int]]

def getInventory(): ServiceCall[NotUsed ,Map[String, Int]]
/**
* Find purchase order by ID
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
*
* @param orderId ID of pet that needs to be fetched
* @return Order
*/
def getOrderById(orderId: Long): ServiceCall[NotUsed ,Order]

def getOrderById(orderId: Long): ServiceCall[NotUsed ,Order]
/**
* Place an order for a pet
*
*
* @return Order Body Parameter order placed for purchasing the pet
*/
def placeOrder(): ServiceCall[Order ,Order]


}

Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,49 @@ trait UserApi extends Service {
).withAutoAcl(true)
}



/**
* Create user
* This can only be done by the logged in user.
*
* @return void Body Parameter Created user object
*/
def createUser(): ServiceCall[User ,Done]

def createUser(): ServiceCall[User ,Done]
/**
* Creates list of users with given input array
*
*
* @return void Body Parameter List of user object
*/
def createUsersWithArrayInput(): ServiceCall[Seq[User] ,Done]

def createUsersWithArrayInput(): ServiceCall[Seq[User] ,Done]
/**
* Creates list of users with given input array
*
*
* @return void Body Parameter List of user object
*/
def createUsersWithListInput(): ServiceCall[Seq[User] ,Done]

def createUsersWithListInput(): ServiceCall[Seq[User] ,Done]
/**
* Delete user
* This can only be done by the logged in user.
*
* @param username The name that needs to be deleted
* @return void
*/
def deleteUser(username: String): ServiceCall[NotUsed ,Done]

def deleteUser(username: String): ServiceCall[NotUsed ,Done]
/**
* Get user by user name
*
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
def getUserByName(username: String): ServiceCall[NotUsed ,User]


def getUserByName(username: String): ServiceCall[NotUsed ,User]

/**
* Logs user into the system
*
Expand All @@ -90,16 +88,16 @@ trait UserApi extends Service {
* @param password The password for login in clear text
* @return String
*/
def loginUser(username:String ,password:String ): ServiceCall[NotUsed ,String]

def loginUser(username:String ,password:String ): ServiceCall[NotUsed ,String]
/**
* Logs out current logged in user session
*
*
* @return void
*/
def logoutUser(): ServiceCall[NotUsed ,Done]

def logoutUser(): ServiceCall[NotUsed ,Done]
/**
* Updated user
* This can only be done by the logged in user.
Expand All @@ -108,6 +106,7 @@ trait UserApi extends Service {
* @return void Body Parameter Updated user object
*/
def updateUser(username: String): ServiceCall[User ,Done]


}