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

All operation parameters are incorrectly marked as enums #97

Closed
devplayer0 opened this issue Jun 12, 2018 · 0 comments
Closed

All operation parameters are incorrectly marked as enums #97

devplayer0 opened this issue Jun 12, 2018 · 0 comments

Comments

@devplayer0
Copy link
Contributor

Any parameter to an operation will have x-is-enum and x-is-list-container set on it, regardless of whether or not the parameter actually represents an enum.

The following OpenAPI and swift4 snippets illustrate this:

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  description: A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification
  termsOfService: http:https://swagger.io/terms/
  contact:
    name: Swagger API Team
    email: [email protected]
    url: http:https://swagger.io
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: http:https://petstore.swagger.io/api
paths:
  /pets/{id}:
    get:
      description: Returns a user based on a single ID, if the user does not have access to the pet
      operationId: find pet by id
      parameters:
        - name: id
          in: path
          description: ID of pet to fetch
          required: true
          schema:
            type: integer
            format: int64
      responses:
        '200':
          description: pet response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
  /stuff/{stuffType}:
    delete:
      tags:
        - 'stuff'
      description: "Delete the stuff"
      operationId: "deleteStuff"
      parameters:
        - name: "stuffType"
          in: "path"
          required: true
          schema:
            type: 'string'
            enum:
              - ASD
              - FGH
              - JKL
      responses:
        '200':
          description: 'A response'

Generated code:

/**
 * enum for parameter _id
 */
public enum _findPetById: Int64 { 
}

/**
     
 - parameter _id: (path) ID of pet to fetch 
 - parameter completion: completion handler to receive the data and the error objects
 */
open class func findPetById(_id: _findPetById, completion: @escaping ((_ data: Pet?,_ error: Error?) -> Void)) {
    findPetByIdWithRequestBuilder(_id: _id).execute { (response, error) -> Void in
        completion(response?.body, error)
    }
}

/**
 * enum for parameter stuffType
 */
public enum StuffType_deleteStuff: String { 
    case asd = "ASD"
    case fgh = "FGH"
    case jkl = "JKL"
}

/**
 
 - parameter stuffType: (path)  
 - parameter completion: completion handler to receive the data and the error objects
 */
open class func deleteStuff(stuffType: StuffType_deleteStuff, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
    deleteStuffWithRequestBuilder(stuffType: stuffType).execute { (response, error) -> Void in
       completion(response?.body, error)
    }
}

While the generated code for deleteStuff has the correct inline enum, findPetById generates a nonsense blank enum instead.

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

No branches or pull requests

1 participant