ebowman / api-first-hand

API-First bootstrapping tool for building RESTful web services from a Swagger/OpenAPI spec
MIT License
142 stars 22 forks source link

Type Naming of Basic Types #67

Closed jona7o closed 7 years ago

jona7o commented 7 years ago

Hi zalando-team,

i used a swagger file of a current project to evaluate the plugin for this project. It's very awesome, but i have got a problem with the type names and i don't know how to fix it.

When i have optional basic types the plugin creates something like this:

type CompanyFinancialInstitution = Option[String] type AddressPostalCode = Option[Int] type CorrespondenceIncoming = Option[Boolean]

Now when i create another Definition with a lot of optional properties the case class looks horrible. It would be very nice, when the Basic Optional Types would look like this or are regenerated every time for every parameter

type OptionalString = Option[String] type OptionalInt = Option[Int] type OptionalBoolean = Option[Boolean]

e.g. this snippet TodoTask: type: object properties: guid: type: string responsible: type: string todoTaskDate: type: string format: date activity: type: string notes: type: string description: at work attachment: type: string description: at work owningCompanyGuid: type: string owningPersonGuid: type: string created: type: string format: datetime modified: type: string format: datetime

generates a horrible case class:

case class TodoTask(owningCompanyGuid: CompanyFinancialInstitution, guid: CompanyFinancialInstitution, responsible: CompanyFinancialInstitution, owningPersonGuid: CompanyFinancialInstitution, modified: CompanyFinancialInstitution, attachment: CompanyFinancialInstitution, notes: CompanyFinancialInstitution, todoTaskDate: CorrespondenceCorrespondenceDate, activity: CompanyFinancialInstitution, created: CompanyFinancialInstitution)

Greetings from South-Germany Tobias

s12v commented 7 years ago

@jona7o, same issue here: https://github.com/zalando/api-first-hand/issues/58. We're working on a PR now, the idea is to have no type aliases for things like Option[T]