ebowman / api-first-hand

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

The names for the enum members are not valid scala identifiers #38

Closed slavaschmidt closed 7 years ago

slavaschmidt commented 8 years ago

The example spec:

swagger: '2.0'
info:
  title: Failing spec
  description: Failing spec
  version: '0.0.2'
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json

paths:
  /:
    get:
      responses:
        '200':
          description: 200
          schema:
            type: string
            enum: [ "Status One", "Status Two", "Status Three" ]
slavaschmidt commented 8 years ago

The same specification demonstrates that the generated result type is wrong as well:

    def Get200(resultP: Enum[String])(implicit writerP: String => Option[Writeable[Enum[String]]]) = success(new GetType[Enum[String]] { val statusCode = 200; val result = resultP; val writer = writerP })
    def Get200(resultF: Future[Enum[String]])(implicit writerP: String => Option[Writeable[Enum[String]]]) = resultF map { resultP => (new GetType[Enum[String]] { val statusCode = 200; val result = resultP; val writer = writerP }) }
    def Get200(resultP: GetResponses200)(implicit writerP: String => Option[Writeable[GetResponses200]]) = success(new GetType[GetResponses200] { val statusCode = 200; val result = resultP; val writer = writerP })
    def Get200(resultF: Future[GetResponses200])(implicit writerP: String => Option[Writeable[GetResponses200]]) = resultF map { resultP => (new GetType[GetResponses200] { val statusCode = 200; val result = resultP; val writer = writerP }) }
slavaschmidt commented 7 years ago

Fixed on 0.2