Skip to content

All operation parameters are incorrectly marked as enums #97

@devplayer0

Description

@devplayer0

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://swagger.io/terms/
  contact:
    name: Swagger API Team
    email: [email protected]
    url: http://swagger.io
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: http://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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions