Skip to content

Commit

Permalink
Merge pull request #21 from macisamuele/maci-add-title-fallback
Browse files Browse the repository at this point in the history
Update SharedCodegen to fallback to title usage if x-model is not present
  • Loading branch information
cortinico committed Mar 17, 2019
2 parents 74d2a2b + e2772a3 commit 08a09e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugin/src/main/java/com/yelp/codegen/SharedCodegen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
}

/**
* Returns the x-model alternative name if it was defined
* Returns the x-model alternative name if it was defined.
* If the x-model alternative name is not found then the call will
* use the defined title, if any, or returns the input name
*/
fun matchXModel(name: String): String {
return xModelMatches[name] ?: name
return xModelMatches[name] ?: (
this.swagger?.definitions?.get(name)?.title ?: name
)
}

/**
Expand Down

0 comments on commit 08a09e3

Please sign in to comment.