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

Replace dataType with baseType+containerType to fix compilation error in AkkaHttpServerCodegen #386

Merged

Conversation

karolchmist
Copy link

Current version of scala-akka-http-server generator doesn't produce correct code if the response type is array. For example, for petstore it produces

def findPetsByStatus200(responseList[Pet]: List[Pet])
(implicit toEntityMarshallerList[Pet]: ToEntityMarshaller[List[Pet]]): Route =
   complete((200, responseList[Pet]))

This code is not valid because responseList[Pet] etc contains the type with brackets ({{dataType}} in api.mustache templates).

This PR fixes this by using {{baseType}}{{containerType}} instead, which produces:

def findPetsByStatus200(responsePetarray: List[Pet])
(implicit toEntityMarshallerPetarray: ToEntityMarshaller[List[Pet]]): Route =  
   complete((200, responsePetarray))

I had to change the type of complexReturnTypes from Set<String> to List<CodegenResponse>, which is necessary as far as I understand the code.

I'm not a Java developer, and it's the first time I use this project, so please let me know if something can be improved.

@karolchmist karolchmist changed the title Replace dataType with baseType+containerType to fix compilation error… Replace dataType with baseType+containerType to fix compilation error in AkkaHttpServerCodegen May 21, 2019
@karolchmist karolchmist force-pushed the fix-akka-http-server-array-response branch from 25631e5 to 5b02bb9 Compare May 22, 2019 06:50
@HugoMario HugoMario merged commit c49d703 into swagger-api:master Jun 3, 2019
@HugoMario
Copy link
Contributor

merged!!! thanks again @karolchmist !

@karolchmist karolchmist deleted the fix-akka-http-server-array-response branch June 4, 2019 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants