<commit_before>//
//  SwiftCodegen.swift
//  SwagGen
//
//  Created by <NAME> on 3/12/2016.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

class SwiftFormatter: CodeFormatter {

    override var disallowedTypes: [String] {
        return [
            "Type",
            "Class",
            "Struct",
            "Enum",
            "Protocol",
            "Set",
        ]
    }

    override func getValueType(_ value: Value) -> String {

        if value.enumValues != nil && value.name != "" {
            return getEnumName(value)
        }

        if let format = value.format {
            switch format.lowercased() {
            case "date-time": return "Date"
            default: break
            }
        }

        switch value.type.lowercased() {
        case "int", "integer", "int32", "int64": return "Int"
        case "string": return "String"
        case "number", "double": return "Double"
        case "date": return "Date"
        case "boolean": return "Bool"
        case "file": return "Data"
        case "object":
            if let definition = value.dictionaryDefinition {
                return "[String: \(getModelName(definition))]"
            } else if let value = value.dictionaryValue {
                return "[String: \(getValueType(value))]"
            } else {
                return "[String: Any]"<commit_msg>add uri format support<commit_after>//
//  SwiftCodegen.swift
//  SwagGen
//
//  Created by <NAME> on 3/12/2016.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

class SwiftFormatter: CodeFormatter {

    override var disallowedTypes: [String] {
        return [
            "Type",
            "Class",
            "Struct",
            "Enum",
            "Protocol",
            "Set",
        ]
    }

    override func getValueType(_ value: Value) -> String {

        if value.enumValues != nil && value.name != "" {
            return getEnumName(value)
        }

        if let format = value.format {
            switch format.lowercased() {
            case "date-time": return "Date"
            default: break
            }
        }

        switch value.type.lowercased() {
        case "int", "integer", "int32", "int64": return "Int"
        case "string":
            if value.format == "uri" {
                return "URL"
            }
            return "String"
        case "number", "double": return "Double"
        case "date": return "Date"
        case "boolean": return "Bool"
        case "file": return "Data"
        case "object":
            if let definition = value.dictionaryDefinition {
                return "[String: \(getModelName(definition))]"
            } else if let value = value.dictionaryValue {
                return "[String: \(getValueType(value))]"
            } else {
                return "[String: Any]"
{'fraction_non_alphanumeric': 0.1250435388366423, 'fraction_numerical': 0.01044932079414838, 'mean_word_length': 1.5990950226244345, 'pattern_counts': {'":': 16, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4199483', 'n_tokens_mistral': 805, 'n_tokens_neox': 749, 'n_words': 219}