Skip to content

[ObjC] Generated code is not actual with JSONModel library #4129

@RomanTruba

Description

@RomanTruba
Description

Generated objective-c code uses old JSONModel library method for init, which is deprecated.

SwaggerClient/Model/SWGSearchModel.m:20:33: 'initWithDictionary:' is deprecated: use initWithModelToJSONDictionary:
Swagger-codegen version

2.2.1

Swagger declaration file content or url
swagger: '2.0'

info:
  version: "1"
  title: "Hello warning"

basePath : "/api/v1"
produces:
  - application/json
schemes:
  - https
        
paths:
  /categories:
    get:
      description: get categories
      responses:
        200:
          description: Successful response
          schema:
            type: array
            items:
              $ref: '#/definitions/UserSkill'
           
definitions:
  Category:
    description: Some category for user
    type: object
    properties:
      id:
        type: integer
        format: int64
      alias:
        type: string
      localized_name:
        type: string
  UserSkill:
    description: User skill description based on category
    allOf:
      - $ref: '#/definitions/Category'
      - properties: 
          year_started:
            description: Year since user has that skill
            type: integer
Command line used for generation

swagger-codegen generate -i ./swagger.yaml -l objc -o ./SwaggerClient

Steps to reproduce
  1. Generate code
  2. Create a test project, create Podfile with contents:
use_frameworks!
platform :ios, '9.0'

target 'TestSwagger' do
    pod 'SwaggerClient', :path => './SwaggerClient'
end
  1. Run pod install
  2. Build project
Suggest a Fix

Use a suggested method initWithModelToJSONDictionary

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions