Delightful code generation for OpenAPI specs for Swift written in Swift

Overview

Create API

Delightful code generation for OpenAPI specs for Swift written in Swift.

  • Fast: processes specs with 100K lines of YAML in less than a second
  • Smart: generates Swift code that looks like it's written by hand
  • Reliable: tested on 500K lines of publically available OpenAPI specs producing correct code every time
  • Customizable: offers a ton of customization options

Powered by OpenAPIKit

Status: pre-release

Arguments

ARGUMENTS:
  <input>                 The OpenAPI spec input file in either JSON or YAML format

OPTIONS:
  --output <output>       The output folder (default: ./.create-api/)
  --config <config>       The path to configuration. If not present, the command will look
                          for .createAPI file in the current folder. (default: /.create-api.yml)
  -s, --split             Split output into separate files
  -v, --verbose           Print additional logging information
  --strict                Throws an error if it fails to generate any of the constructs from
                          the input spec
  --watch                 Monitor changes to both the spec and the configuration file and
                          automatically re-generated input
  --package <package>     Generates a complete package with a given name
  --module <module>       Use the following name as a module name
  --vendor <vendor>       Enabled vendor-specific logic (supported values: "github")
  --generate <generate>   Specifies what to generate (default: paths, entities)
  --filename-template <filename-template>
                          Example: "%0.generated.swift" will produce files with the following names:
                          "Paths.generated.swift". (default: %0.swift)
  --single-threaded       By default, saturates all available threads. Pass this option
                          to turn all parallelization off.
  --measure               Measure performance of individual operations
  -h, --help              Show help information.

Configuration

CreateAPI supports a massive number of customization options with more to come. You can use either YAML or JSON as configuration files.

An example configuration file featuring all available options set to the default parameters.

# Modifier for all generated declarations
access: public
# Add @available(*, deprecated) attributed
isAddingDeprecations: true
# Generate enums for strings
isGeneratingEnums: true
# Example: "enabled" -> "isEnabled"
isGeneratingSwiftyBooleanPropertyNames: true
# Any schema that can be conveted to a type identifier.
# Example: "typealias Pets = [Pet], is inlined as "[Pet]".
isInliningTypealiases: true
# Example: "var sourcelUrl" becomes "var sourceURL"
isReplacingCommonAcronyms: true
# Acronyms to add to the default list
addedAcronyms: []
# Acronyms to remove from the default list
ignoredAcronyms: []
# Example: "var file: [File]" becomes "var files: [File]"
isPluralizationEnabled: true
# Available values: ["spaces", "tabs"]
indentation: spaces
# By default, 4
spaceWidth: 4
# Parses dates (e.g. "2021-09-29") using `NaiveDate` (https://github.com/kean/NaiveDate)
isNaiveDateEnabled: true
# If enabled, uses `Int64` or `Int32` when specified.
isUsingIntegersWithPredefinedCapacity: false
# Disableds SwiftLint
isSwiftLintDisabled: true
# Overrides file
fileHeader: null

entities:
  # Skipped entities, e.g. ["SimpleUser"]
  skip: []
  # Generates entities as structs
  isGeneratingStructs: true
  # Generate the following entities as classes
  entitiesGeneratedAsClasses: []
  # Generate the following entities as structs
  entitiesGeneratedAsClasses: []
  # Makes classes final
  isMakingClassesFinal: true
  # Base class for entities generated as classes
  baseClass: null
  # Protocols adopted by entities
  protocols: ["Codable"]
  # Generate initializers for all entities
  isGeneratingInitializers: true
  # If disabled, will use strings as coding keys
  isGeneratingCustomCodingKeys: true
  # By default, the order matches the order in the spec
  isSortingPropertiesAlphabetically: false
  # Add defaults values for booleans and other types when specified
  isAddingDefaultValues: true
  # For `allOf` inline properties from references
  isInliningPropertiesFromReferencedSchemas: false
  # Changes how unspecified additional properties are interpreted
  isAdditionalPropertiesOnByDefault: true

paths:
  # Skipped paths, e.g. ["/gists/{gist_id}/commits"]
  skip: []
  # Available options:
  #   - "rest" - generate structs to represent path components
  #   - "operations" - generate a plain list of operatinos
  style: rest
  # Namespace for all generated paths
  namespace: "Paths"
  # Generate response headers using https://github.com/kean/HTTPHeaders
  isGeneratingResponseHeaders: true
  # Add operation id to each request
  isAddingOperationIds: false
  # The types to import, by default uses "Get" (https://github.com/kean/Get)
  imports: ["Get"]
  # Example, "- empty: Void"
  overrideResponses: {}
  # Overrides the query parameter encoders, example:
  #   - Date: "ISO8601DateFormatter().string(from: self)"
  queryParameterEncoders: null
  # Inline simple requests, like the ones with a single parameter 
  isInliningSimpleRequests: true
  # Inline simple parametesr with few arguments.
  isInliningSimpleQueryParameters: true
  # Threshold from which to start inlining query parameters
  simpleQueryParametersThreshold: 2
  # Tries to remove redundant paths
  isRemovingRedundantPaths: true

rename:
  # Rename properties, example:
  #   - name: firstName
  #   - SimpleUser.name: firstName
  properties: {}
  # Rename query parameters
  parameters: {}
  # Rename enum cases
  enumCases: {}
  # Rename entities
  entities: {}
  # Rename operation when "paths.style: operations" is used
  operations: {}
  # Rename anynomous collection elements. By default, use
  # a singularized form of the property name
  collectionElements: {}

comments:
  # Generate comments
  isEnabled: true
  # Generate titles
  isAddingTitles: true
  # Generate description 
  isAddingDescription: true
  # Generate examples
  isAddingExamples: true
  # Add links to the external documenatation
  isAddingExternalDocumentation: true
  # Auto-capitalizes comments
  isCapitalizationEnabled: true

Adding Specs

If you are using CreateAPI and want your spec to be part of the regression testing - open a PR adding it to GenerateTests test suite and provide your configuration.

OpenAPI Support

The following features are not suppored (yet):

  • External References
  • allowReserved and allowEmptyValue option in query parameters
  • spaceDelimited, pipeDelimited, and deepObject query parameters style values, form encoding only supports primitive types

Upcoming:

  • An improved way to generate patch parameters. Support for JSON Patch.
  • OpenAPI 3.1 support.
Comments
  • Generated code does not compile with Xcode 14/Swift 5.7

    Generated code does not compile with Xcode 14/Swift 5.7

    pension_plan_kit/.build/checkouts/Get/Sources/Get/DataLoader.swift:156:50: error: incorrect argument label in call (have ':didCreateTask:', expected ':taskIsWaitingForConnectivity:') handlers[task]?.delegate?.urlSession?(session, didCreateTask: task)

    opened by haydgately 16
  • requestOperationIdExtension adds private extension making it inaccessible if in a separate file

    requestOperationIdExtension adds private extension making it inaccessible if in a separate file

    In Templates.swift, requestOperationIdExtension adds a private extension.

    If generation creates separate files, the private extension is also in its own file Paths+Extensions which makes it inaccessible to use in other files.

    bug good first issue 
    opened by andrea-gradecak 11
  • Update Generated extension names to better reflect their contents

    Update Generated extension names to better reflect their contents

    • followup for #60

    When looking at the generated output, I didn't get the feeling that the extension files were named very naturally.

    For example, a file containing the StringCodingKey type is named Entities+CodingKey.swift which to me feels a bit disconnected. If I was naming it myself, I'd have gone with StringCodingKey.swift instead.

    In the end, I decided to rename the all of the files to better reflect their contents:

    Before|After ---|--- Entities+CodingKey.swift|StringCodingKey.swift Entities+AnyJSON.swift|AnyJSON.swift Paths+Extensions.swift|Paths.swift (actually options.paths.namespace)

    WDYT @LePips ?

    opened by liamnichols 9
  • Support custom mappings between schema formats and Swift types

    Support custom mappings between schema formats and Swift types

    Edit: differs from the original to a single global override instead of individual properties and I forgot parameter types. I think that we can start with a global override and somebody can request this fine tuning later.


    Introduce a config option to override the Swift type when they are parsed and written:

    # schema
    Pet:
      properties:
        id:
          type: string
        tag:
          type: string
          format: uuid
    
    # config
    swiftTypeOverrides:
      UUID: String # any occurrences of UUID are replaced with String, so `Pet.tag: String`
    

    Config name open for improvement. Obviously, a developer might override to a type that cannot be decoded from/encoded to the original type, like UUID: Int or a type that does not exist, like UUID: qwerty. So, it is a developer responsibility to make sure that overriding types can be properly decoded/encoded and that they are a proper Swift type.


    This can be further enhanced with imports as we should be trivially able to set an imported type after https://github.com/CreateAPI/CreateAPI/issues/85 is figured out. Using NaiveDate as an example removing the useNaiveDate option, we include the package as an import in the config and then set the type override:

    # schema
    Pet:
      properties:
        birth_date:
          type: string
          format: date
    
    # config
    swiftTypeOverrides:
      Date: NaiveDate # any occurrences of Date are replaced with NaiveDate
    

    Obviously, imported objects should be expected to properly decode/encode but that's an implementation detail of the imported type.

    opened by LePips 9
  • Data Type Override

    Data Type Override

    • Depends on https://github.com/CreateAPI/CreateAPI/pull/135
    • Closes https://github.com/CreateAPI/CreateAPI/issues/114

    What

    As described in #114, a Swift type override can be very powerful when working together with packages.dependencies and entites/paths.imports. The encoding/decoding caveats and developer responsibilities are in the issue.

    This PR differs in the format now being:

    dataTypeOverrides:
      data-type.format: SwiftType
    

    The power comes from format being an open value on numbers, integers, and strings. Users can now use different built in types or create and import their own custom types for corresponding labels or a global override.

    Examples:

    • string.uuid: String
    • number.float: Float80
    • integer.Int64: Int, assuming useFixWidthIntegers = true and one wants to use Int32/Int
    • string.password: MyPasswordType, assuming custom import
    • string: MyStringType, assuming custom import

    Using imports would require at least the following:

    dataTypeOverrides:
      string.password: MyPasswordType
    entities:
      import: MyPasswordType
    packages:
      dependencies:
      - url: # MyPasswordTypeURL
      # rest of the dependency configuration
    

    Again, it is a developer responsibility that these types are properly encoded/decoded, that they exist, and that it is proper within the context of their API.

    TODO

    • [x] Remove useNaiveDate
      • Leaving in for this implementation.

    However, we can recommend NaiveDate and other packages that can enhance the experience in the documentation!

    • [x] Interplay with useFixWidthIntegers.
      • ~~Should this or overrides take precedence?~~ Consensus reached to remove this and width types can be set here.
    • [ ] Documentation
      • Overall example usage, noting that this is Advanced configuration.
    • [x] Dictionary/array types (edited after some thought)
      • These are not "types" but "objects". This can be a future feature request. There can be a use case for this where: 1 - string.first_name: MyFirstNameType, custom format first_name 2 - An array object in the schema represents an array of first_name-formatted strings. So we want [MyFirstNameType]. This isn't configurable in the schema so this is something that developers should know within the context of their API.
    • [ ] Split per entities/paths?
      • A use case I just thought of is where somebody would want to use their entities with something like string.uuid: String for convenience but when making calls that would then require an entity UUID as a parameter they want to enforce at runtime that the type is correct. This would increase to possibly three flags: globalDataTypeOverrides, entites.dataTypeOverrides, and paths.dataTypeOverrides. I say we ignore this and can be an enhancement later on if requested as it's somewhat similar to the individual property type override idea from the original issue.
    opened by LePips 8
  • All command line arguments that alter output should be configurable in config file

    All command line arguments that alter output should be configurable in config file

    Currently, we have a very vast amount of configuration options that must be included in the create-api.yaml file, but we also have some other options that also alter how the tool generates the output code that must be passed via CLI args. This includes the following:

    • -s, --split - Split output into separate files
    • --package <package> - Generates a complete package with a given name
    • --module <module> - Use the following name as a module name
    • --vendor <vendor> - Enabled vendor-specific logic (supported values: "github")
    • --generate <generate> - Specifies what to generate (default: paths, entities)
    • --filename-template <filename-template> - Example: "%0.generated.swift" will produce files with the following names: "Paths.generated.swift". (default: %0.swift)
    • --entityname-template <entityname-template> - Example: "%0Generated" will produce entities with the following names: "EntityGenerated". (default: %0)

    This means that there are two sources to dig through when altering configuration, which has the potential to cause confusion. It also makes it hard to invoke create-api from multiple different places without either copying the desired arguments or wrapping the invocation in a script.

    Firstly, I'd like to understand if there is a good reason that these options should be separate to the options in the configuration file?

    If we agree that isn't the case, I'd like to start making them available in the configuration instead.

    Unless there is a good reason to keep the arguments as overrides to configuration options, my suggestion would be to deprecate them now and remove them in a future release. Printing a warning when used until they are removed.

    enhancement breaking 
    opened by liamnichols 8
  • Introduce replacement entity type configurations

    Introduce replacement entity type configurations

    • Closes #100

    Before this change, to customise generation between structs, classes and classes marked as final, you would use the following options:

    • isGeneratingStructs - to switch between structs and classes as the default
    • isMakingClassesFinal - to make classes final if they were generated
    • entitiesGeneratedAsClasses to provide overrides that should always generate as a class
    • entitiesGeneratedAsStructs to provide overrides that should always generate as a struct

    For the 0.1 release, we want to simplify this into two properties:

    • defaultType - ([struct, class, finalClass]) the preferred type used for all entities when generating
    • typeOverrides - A dictionary map of entity names and the type that they should be (from the list above)

    This reduces overhead in the config file and also gives you more flexibility when choosing between class and final class.

    In addition, we want to simplify the mutable property flags by going from the following:

    • isGeneratingMutableClassProperties (true or false)
    • isGeneratingMutableStructProperties (true or false)

    to

    • mutableProperties ([], [structs, classes], [structs] or [classes])

    In #111 I also updated the config deserialiser so that it is capable of processing true, false or a single element when working with array/set based options. For example in YAML/JSON, mutableProperties: true would be considered the same as mutableProperties: [structs, classes].

    opened by liamnichols 6
  • Any docs on how to actually use the generated code?

    Any docs on how to actually use the generated code?

    I am just lost on how to actually consume my generated API.

    What I've done is generate the the Entities.swift and Paths.swift drag an drop it into the project. Add Get and URLQueryEncoder via SPM. But now I'm faced with a bunch of Cannot find type 'api' in scope

    image

    Any info on what to do next would be nice. Thank you!

    documentation 
    opened by soemarko 6
  • Unstable order when reading spec from `.json` file

    Unstable order when reading spec from `.json` file

    https://github.com/kean/CreateAPI/blob/87ba65d28a657ef7b94a758697cbf68d6075dbb9/Sources/CreateAPI/Generate.swift#L159-L160

    In addition to not being thread-safe, JSONDecoder also does not appear to guarantee any explicit order of object keys.

    Spec
    {
      "openapi": "3.0.0",
      "info": {
        "version": "1.0.0",
        "title": "Order"
      },
      "paths": {
        "/container": {
          "get": {
            "responses": {
              "200": {
                "description": "",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/Container"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "components": {
        "schemas": {
          "Container": {
            "type": "object",
            "required": null,
            "properties": {
              "propertyOne": {
                "type": "string"
              },
              "propertyTwo": {
                "type": "string"
              },
              "propertyThree": {
                "type": "string"
              },
              "propertyFour": {
                "type": "string"
              }
            }
          }
        }
      }
    }
    
    Output
    // Generated by Create API
    // https://github.com/kean/CreateAPI
    //
    // swiftlint:disable all
    
    import Foundation
    
    public struct Container: Codable {
        public var propertyFour: String?
        public var propertyThree: String?
        public var propertyOne: String?
        public var propertyTwo: String?
    
        public init(propertyFour: String? = nil, propertyThree: String? = nil, propertyOne: String? = nil, propertyTwo: String? = nil) {
            self.propertyFour = propertyFour
            self.propertyThree = propertyThree
            self.propertyOne = propertyOne
            self.propertyTwo = propertyTwo
        }
    }
    
    struct StringCodingKey: CodingKey, ExpressibleByStringLiteral {
        private let string: String
        private var int: Int?
    
        var stringValue: String { return string }
    
        init(string: String) {
            self.string = string
        }
    
        init?(stringValue: String) {
            self.string = stringValue
        }
    
        var intValue: Int? { return int }
    
        init?(intValue: Int) {
            self.string = String(describing: intValue)
            self.int = intValue
        }
    
        init(stringLiteral value: String) {
            self.string = value
        }
    }
    

    The easiest workaround is to convert the .json spec to a .yaml spec beforehand.

    enhancement 
    opened by PhilipTrauner 6
  • Make `--split` (`-s`) the default behaviour

    Make `--split` (`-s`) the default behaviour

    Background

    • #57

    Description

    Bundling everything into just Paths.swift and Entities.swift prevents the compiler from parallelising build tasks and results in bad compile times for larger projects.

    Therefore bundling the source has little advantage compared to splitting into individual files (--split) so we should make this the default.

    We're not ready to remove the option completely, likely we'll replace it with something like --no-split or --merge but we should put less emphasis on it.

    The one time that I've found it useful is for predicting the output sources so that we can make efficient BuildToolPlugin's. But in the long run, I want to explore ways to break out the evaluation from the generation so that we could compute this ahead of time... Maybe..

    enhancement breaking 
    opened by liamnichols 5
  • Homebrew Installation

    Homebrew Installation

    I rather prefer Homebrew to install all my packages instead over Mint and of course over manual installation for every update. Could there be a Homebrew option for installation?

    enhancement 
    opened by LePips 5
  • Request uses incorrect body instead of asQuery

    Request uses incorrect body instead of asQuery

    Hi, I'm working on a library for DeepL (it's amazing to see the capabilities of CreateAPI) and while doing so I encountered a bug that even seams to be present in the tests (https://github.com/CreateAPI/CreateAPI/blob/da8730b23dab769414229bb386b3dcc2a77d6e42/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Paths/PathsFake.swift).

    The problem is that CreateAPI generates a POST request using URLQueryEncoder.encode(body).percentEncodedQuery as the body, but it should be using the asQuery property instead. This causes the request to be incorrect because URLQueryEncoder.encode(body).percentEncodedQuery uses camelCase for the property names, but the expected format is snake_case, which asQuery correctly uses.

    In the test the property pattern_without_delimiter incorrectly would be called patternWithoutDelimiter in the POST request.

    So instead of https://github.com/CreateAPI/CreateAPI/blob/da8730b23dab769414229bb386b3dcc2a77d6e42/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Paths/PathsFake.swift#L57

    I would expect:

     Request(path: path, method: "POST", query: body?.asQuery, id: "testEndpointParameters") 
    
    opened by mikakruschel 0
  • Incorrectly formatted entity name

    Incorrectly formatted entity name

    I have a case where the following example data:

    {
        "note": {
            "text": "99 sheep <{{|t|1|}}> <{{|m|1|}}>",
            "tags": [
                {
                    "id": 1,
                    "key": "1234",
                    "label": "some-tag"
                }
            ],
            "mentions": [
                {
                    "id": 1,
                    "key": "1234",
                    "label": "some mention"
                }
            ]
        }
    }
    

    Results in the generated entity for "mentions" to be improperly named to Mantions, instead of Mention (note the typo):

    public struct Note: Decodable {
      /// Example:
      ///
      /// [
      ///   {
      ///   "id" : 1,
      ///   "key" : "123432234",
      ///   "label" : "some-mention"
      ///   }
      /// ]
      public var mentions: [Mantions]?
      /// Example: []
      public var tags: [AnyJSON]?
      /// Example: "<{{|m|1|}}> some text"
      public var text: String?
    
      public struct Mantions: Decodable, Identifiable {
        public var id: Double?
        public var key: String?
        public var label: String?
      }
    }
    

    This also happens in another endpoint with the same name:

    public struct GetResponse: Decodable {
        /// Example:
        ///
        /// [
        ///   {
        ///   "id" : 1,
        ///   "key" : "4321",
        ///   "label" : "some mention"
        ///   }
        /// ]
        public var mentions: [Mantions]?
        /// Example:
        ///
        /// [
        ///   {
        ///   "id" : 1,
        ///   "key" : "1234",
        ///   "label" : "some-tag"
        ///   }
        /// ]
        public var tags: [Tag]?
    
        public struct Mantions: Decodable, Identifiable {
            public var id: Double?
            public var key: String?
            public var label: String?
        }
    
        public struct Tag: Decodable, Identifiable {
            public var id: Double?
            public var key: String?
            public var label: String?
        }
    }
    

    I can work around it by renaming it to itself, so it skips the formatter:

    rename:
      collectionElements:
        Mentions: Mention
    
    $ create-api --version
    0.1.1
    

    Also tried on latest main since https://github.com/CreateAPI/CreateAPI/commit/da8730b23dab769414229bb386b3dcc2a77d6e42

    opened by fnky 2
  • Entity Property Type Override

    Entity Property Type Override

    • Closes https://github.com/CreateAPI/CreateAPI/issues/176

    Implements individual property type override. This allows both general property naming and specific property type, mirroring the usage of rename.properties. I consider this an advanced feature, since this allows such fine control over single properties.

    Overriding Optional

    Since this is an advanced feature and by definition allows one to override the actual property type, it could be thought that his encompasses the entire type which includes whether it is an Optional.

    For example, assume that Pet.tag would originally map to String?, but with the below:

    entities:
      propertyTypeOverrides:
        Pet.tag: UUID
    

    this would result in Pet.tag mapping to UUID, therefore making this required to the client. This can also happen the other way, making a non-optional property generate as an optional instead. This would also of course be a responsibility to the developer that the types can properly decode/encode.

    I don't do this here (Optional is stable through the type override), however I think this should be a consideration.

    opened by LePips 0
  • Entity Individual Property Swift Type Override

    Entity Individual Property Swift Type Override

    While property schema datatype's can be overridden, I need to be able to override a single entity property type.


    Context

    The schema I am using has a string property that is represented by a string enum on the backend however isn't specified in the schema as an enum due to the complexity/time of rewriting the backend using that enum (along with a few others).

    Essentially, I have my own Swift enum specified elsewhere and would like to use that instead to fill in gaps of the schema.

    Currently the following would be generated:

    struct MyItem {
    	let itemType: String
    }
    

    What should come from generation:

    struct MyItem {
    	let itemType: MyItemType
    }
    

    Implementation

    Introduce new config option entities.propertyTypeOverrides which represents a mapping of scheme properties to Swift types:

    entities:
      propertyTypeOverrides:
        MyItem.itemType: MyItemType
    

    This option would take precedence over the datatype override and would follow the same rule:

    It is your responsibility to ensure that the replacement type conforms to Codable and can properly decode and encode to the original primitive type.

    While my example is specifically for a String -> enum case, I think this can be helpful in other contexts.

    opened by LePips 0
  • Sort Properties After Creation

    Sort Properties After Creation

    • Closes https://github.com/CreateAPI/CreateAPI/issues/174

    Sorts created properties, which go through their own independent renamings if applicable, instead of the raw keys.

    opened by LePips 1
  • `useSwiftyPropertyNames` and `sortPropertiesAlphabetically` ordering

    `useSwiftyPropertyNames` and `sortPropertiesAlphabetically` ordering

    Using useSwiftyPropertyNames: true and entities.sortPropertiesAlphabetically: true, the is- conversion is happening after the alphabetical sorting.

    Example schema:

    // ...
    components:
      schemas:
        Pet:
          title: A pet title
          description: A pet description
          type: object
          required:
            - id
          properties:
            id:
              type: string
            likesMeat:
              type: boolean
            allergic:
              type: boolean
    
    

    Generates the following:

    public struct Pet: Codable {
        public var isAllergic: Bool?
        public var id: String
        public var isLikesMeat: Bool?
    
        // ...
    }
    

    It would be much more preferable if properties were properly sorted:

    public struct Pet: Codable {
        public var id: String
        public var isAllergic: Bool?
        public var isLikesMeat: Bool?
    
        // ...
    }
    

    Additionally, it would probably be beneficial for an exclude list for useSwiftyPropertyNames as some property conversions may not be grammatically preferable, like in the above example.

    bug 
    opened by LePips 1
Releases(0.1.1)
  • 0.1.1(Oct 5, 2022)

    What's Changed

    • List jellyfin-sdk-swift as a project using CreateAPI by @LePips in https://github.com/CreateAPI/CreateAPI/pull/148
    • Add Xcode 14 and Swift 5.7 to CI by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/156
    • Fix issue with Discriminator type resolution that impacted the decoding of oneOf types in some conditions by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/158
    • Improve error messages that are used when oneOf object decoding fails by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/159

    Full Changelog: https://github.com/CreateAPI/CreateAPI/compare/0.1.0...0.1.1

    Artifact Bundle

    Checksum: 0f0cfe7300580ef3062aacf4c4936d942f5a24ab971e722566f937fa7714369a

    .binaryTarget(
        name: "create-api",
        url: "https://github.com/CreateAPI/CreateAPI/releases/download/0.1.1/create-api.artifactbundle.zip",
        checksum: "0f0cfe7300580ef3062aacf4c4936d942f5a24ab971e722566f937fa7714369a"
    )
    
    Source code(tar.gz)
    Source code(zip)
    create-api.artifactbundle.zip(5.07 MB)
  • 0.1.0(Aug 16, 2022)

    CreateAPI 0.1 makes some big changes to help prepare for even more features and enhancements. To make this possible, we've had to revisit a lot of parts of the way that the generator is used and while at the core there hasn't been much change, it's likely that you will need to adjust your configuration files and the way that you use the cli. For more details, please refer to the release notes below.

    As always, if you have any problems then please feel free to create a new issue!

    Enhancements

    • #69 - Publish release to Homebrew.
    • #48 - Support Swift Package Plugins.
    • #58 - Improve readme, add usage documentation and contributing guides.
    • #47 - Override any option in the configuration file from the command line using --config-option.
    • #85 - Add custom package dependencies in generated package.
    • #114 - Allow custom mapping between schema data types/formats and Swift types used in generation.
    • #125 - Raise an error if the --config file doesn't exist instead of silently falling back to the default options.
    • #90 - Produce warnings when configuration files contain unknown or deprecated options.
    • #76 - Add --version option/command.
    • #71 - Support excluding individual properties on entities.
    • #116, #141 - Write extension source files into Extensions directory and improve their filenames.
    • #131 - Raise an error if you use --clean when the --output directory also contains the schema or config file.
    • #138 - Trim whitespace from the fileHeaderComment.
    • #140 - Run path generation in parallel.

    Breaking Changes

    • #83 - Generated packages and paths now depend on Get 1.0.2 or later. If you don't use Get, your Request type must expose an initializer that matches the initializer defined in Get.
    • #88 - When generating a Swift Package, the Package.swift file and all other sources are written to the root of the --output directory instead of being nested inside a subdirectory.
    • #132 Default output directory is now ./CreateAPI when --output is not specified.
    • #112 - The rename.properties option now understands property names as defined in the original schema and not after applying CreateAPI transformations (such as case conversion or swifty style booleans).
    • #125 - The generator will now error if the path defined using --config did not contain a valid file (prior behaviour was to fallback to the default configuration).
    • #47 - Command Line Argument options that alter the generate output have now been moved into the configuration file and the behaviour may have also been adjusted.
      • --split (-s) is now the default behavior. Use the mergeSources option to merge generated source files.
      • --filename-template has been replaced by the entities.filenameTemplate and paths.filenameTemplate options.
      • --entityname-template has been replaced by the entities.nameTemplate option.
      • --generate has been replaced by the generate option and now accepts paths, entities, enums and package to customize which components are generated.
      • --package and --module have been incorporated as part of the generate option (see above) for controlling the generated outputs and the module/package name is configured using the module option.
      • --vendor has been replaced by the vendor option.
    • #100 - For entities, isGeneratingStructs and isMakingClassesFinal have merged into a single defaultType option (accepted values struct, class or finalClass).
      • isGeneratingMutableClassProperties and isGeneratingMutableStructProperties have been replaced by a single mutableProperties option. Specify true, false, structs or classes instead.
      • entitiesGeneratedAsClasses and entitiesGeneratedAsStructs have been replaced by a single typeOverrides option.
    • #98 - comments options have been replaced with a single commentOptions property that accepts false, true or an array containing any of [title, description, example, externalDocumentation, capitalized].
    • #97 - isReplacingCommonAcronyms, addedAcronyms and ignoredAcronyms have been replaced with a single acronyms option.
    • #94 - isSwiftLintDisabled has been removed. Use fileHeaderComment if you want to replicate this behavior.
    • #93 - isAdditionalPropertiesOnByDefault has been removed with no replacement.
    • #92 - Every generated Request now includes its operationId and the isAddingOperationIds option has now been removed.
    • #91 - Fixed a spelling mistake in overridenResponses and overridenBodyTypes.
    • #63 - isInliningPropertiesFromReferencedSchemas behavior is now enabled by default and the option has renamed to inlineReferencedSchemas.
    • #75 - isGeneratingCustomCodingKeys behavior is now enabled by default and the option has been renamed to optimizeCodingKeys.
    • #66 - access no longer accepts an open string. The value must be either internal or public.
    • #114, #145 - isUsingIntegersWithPredefinedCapacity has been removed. You can now configure data type mappings to Swift types using the dataTypes option.
    • #134 - isGeneratingEnums has been removed and is now configurable as part of the new generate option.
    • #89 - Swifty style boolean properties in the configuration file have been renamed.
      • isNaiveDateEnabled useNaiveDate
      • isPluralizationEnabled pluralizeProperties
      • isInliningTypealiases inlineTypealiases
      • isGeneratingSwiftyBooleanPropertyNames useSwiftyPropertyNames
      • isAddingDeprecations annotateDeprecations
      • entities
        • isStrippingParentNameInNestedObjects stripParentNameInNestedObjects
        • isAddingDefaultValues includeDefaultValues
        • isSortingPropertiesAlphabetically sortPropertiesAlphabetically
        • isGeneratingEncodeWithEncoder alwaysIncludeEncodableImplementation
        • isGeneratingInitWithDecoder alwaysIncludeDecodableImplementation
        • isGeneratingInitializers includeInitializer
        • isSkippingRedundantProtocols skipRedundantProtocols
        • isGeneratingIdentifiableConformance includeIdentifiableConformance
      • paths
        • isRemovingRedundantPaths removeRedundantPaths
        • isMakingOptionalPatchParametersDoubleOptional makeOptionalPatchParametersDoubleOptional
        • isInliningSimpleQueryParameters inlineSimpleQueryParameters
        • isInliningSimpleRequests inlineSimpleRequests
        • isGeneratingResponseHeaders includeResponseHeaders
        • isGeneratingCustomCodingKeys optimizeCodingKeys
        • isInliningPropertiesFromReferencedSchemas inlineReferencedSchemas

    Refer to the Configuration Options documentation for more information.

    Internal

    • #79 - Lint project using SwiftLint.
    • #81 - Compile generated test snapshots on Linux as part of CI checks.
    • #117 - Refactor file writing responsibility out of the Generate command.
    • #122 - Cleanup tests with new snapshot(spec:name:testCompilationOnLinux:arguments:configuration:) method.
    • #120 - Use swift-configuration-parser library.
    • #128 - Refactor CreateAPITests structure and rewrite snapshotter.
    • #123 - Automatically update AllPackages package when rerecording snapshots.
    • #129 - Introduce 'Record Snapshots' scheme to simplify rerecording snapshots.

    Full Changelog: https://github.com/CreateAPI/CreateAPI/compare/0.0.5...0.1.0

    Artifact Bundle

    Checksum: 4e9d1fb023c52e423d57de0928da5d943e3e4c81f6cb903523654867e6372db7

    .binaryTarget(
        name: "create-api",
        url: "https://github.com/CreateAPI/CreateAPI/releases/download/0.1.0/create-api.artifactbundle.zip",
        checksum: "4e9d1fb023c52e423d57de0928da5d943e3e4c81f6cb903523654867e6372db7"
    )
    
    Source code(tar.gz)
    Source code(zip)
    create-api.artifactbundle.zip(5.07 MB)
  • 0.0.5(Jul 30, 2022)

    What's Changed

    • Support Linux by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/43
    • Update Makefile by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/54
    • Update generator code to point to https://github.com/kean/Get and not CreateAPI/Get by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/51
    • Remove main.swift and mark CreateAPI as @main type directly by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/49
    • Fix comment generation when using other kind of linebreaks by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/46
    • Support automatically generating Identifiable conformance on entities by @LePips in https://github.com/CreateAPI/CreateAPI/pull/61
    • Tests - Automatic Path Finding and Remove Environment Variables by @LePips in https://github.com/CreateAPI/CreateAPI/pull/62
    • Single source of truth for configuration options by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/52
    • Update README and use new CreateOptions module by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/65
    • Produce an artifactbundle when making releases by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/67

    New Contributors

    • @LePips made their first contribution in https://github.com/CreateAPI/CreateAPI/pull/61

    Full Changelog: https://github.com/CreateAPI/CreateAPI/compare/0.0.4...0.0.5

    Artifact Bundle

    Checksum: 89c75ec3b2938d08b961b94e70e6dd6fa0ff52a90037304d41718cd5fb58bd24

    .binaryTarget(
        name: "create-api",
        url: "https://github.com/CreateAPI/CreateAPI/releases/download/0.0.5/create-api.artifactbundle.zip",
        checksum: "89c75ec3b2938d08b961b94e70e6dd6fa0ff52a90037304d41718cd5fb58bd24"
    )
    
    Source code(tar.gz)
    Source code(zip)
    create-api.artifactbundle.zip(4.70 MB)
  • 0.0.4(Jun 10, 2022)

    What's Changed

    • Discriminator Support by @PhilipTrauner in https://github.com/CreateAPI/CreateAPI/pull/10
    • Strip parent name of enum cases within nested objects by @PhilipTrauner in https://github.com/CreateAPI/CreateAPI/pull/15
    • Added options for mutable properties in classes and structs by @JanC in https://github.com/CreateAPI/CreateAPI/pull/17
    • Add entities name template by @imjn in https://github.com/CreateAPI/CreateAPI/pull/14
    • Added imports option for entities by @JanC in https://github.com/CreateAPI/CreateAPI/pull/19
    • Fix shouldGenerate check for entities.include option by @ainame in https://github.com/CreateAPI/CreateAPI/pull/20
    • Fix namespace when using operations style by @simorgh3196 in https://github.com/CreateAPI/CreateAPI/pull/21
    • Fix String type with byte format by @mattia in https://github.com/CreateAPI/CreateAPI/pull/25
    • Fixed fileHeader option to fileHeaderComment by @imjn in https://github.com/CreateAPI/CreateAPI/pull/22
    • Fixed test failures for string with byte format by @imjn in https://github.com/CreateAPI/CreateAPI/pull/26
    • Fix test failures in comparing Package.swift by @imjn in https://github.com/CreateAPI/CreateAPI/pull/28
    • Update repository links to github.com/CreateAPI/CreateAPI by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/35
    • Support multiple discriminator mappings to share one type by @imjn in https://github.com/CreateAPI/CreateAPI/pull/36
    • Update GitHub Workflow CI by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/37
    • Fix allOf decoding issue by @imjn in https://github.com/CreateAPI/CreateAPI/pull/27
    • Removed redundant space before struct and class declaration by @imjn in https://github.com/CreateAPI/CreateAPI/pull/38
    • Decode JSON input specs using YAMLDecoder by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/34
    • Treat single element allOf/oneOf/anyOf schemas as the nested schema by @liamnichols in https://github.com/CreateAPI/CreateAPI/pull/39

    New Contributors

    • @JanC made their first contribution in https://github.com/CreateAPI/CreateAPI/pull/17
    • @ainame made their first contribution in https://github.com/CreateAPI/CreateAPI/pull/20
    • @mattia made their first contribution in https://github.com/CreateAPI/CreateAPI/pull/25
    • @liamnichols made their first contribution in https://github.com/CreateAPI/CreateAPI/pull/35

    Full Changelog: https://github.com/CreateAPI/CreateAPI/compare/0.0.2...0.0.4

    Source code(tar.gz)
    Source code(zip)
  • 0.0.3(Feb 2, 2022)

    What's Changed

    • Fix an issue with entities.include not being used correctly

    Full Changelog: https://github.com/CreateAPI/CreateAPI/compare/0.0.2...0.0.3

    Source code(tar.gz)
    Source code(zip)
  • 0.0.2(Jan 29, 2022)

    What's Changed

    • Add support for installation by Mint by @simorgh3196 in https://github.com/CreateAPI/CreateAPI/pull/1
    • Fixed small typos in README.md by @imjn in https://github.com/CreateAPI/CreateAPI/pull/2
    • Fixed wrong example in readme yaml by @imjn in https://github.com/CreateAPI/CreateAPI/pull/4
    • Add Entities.include by @imjn in https://github.com/CreateAPI/CreateAPI/pull/5
    • Revert "Added entityPrefix and entitySuffix to GenerateOptions.Rename" by @imjn in https://github.com/CreateAPI/CreateAPI/pull/8
    • Added --clean to readme by @imjn in https://github.com/CreateAPI/CreateAPI/pull/7
    • Use builtin UUID type for uuid format in schemas by @PhilipTrauner in https://github.com/CreateAPI/CreateAPI/pull/11
    • Fix tests by @PhilipTrauner in https://github.com/CreateAPI/CreateAPI/pull/13

    Full Changelog: https://github.com/CreateAPI/CreateAPI/compare/0.0.1...0.0.2

    Source code(tar.gz)
    Source code(zip)
  • 0.0.1(Jan 4, 2022)

Owner
Alexander Grebenyuk
I write kean.blog and like porridge
Alexander Grebenyuk
OpenAPI specification generator for Vapor based Swift projects.

VaporToOpenAPI VaporToOpenAPI is a Swift library which can generate output compatible with OpenAPI version 3.0.1 from Vapor code. You can use generate

null 3 Dec 15, 2022
A repository to experiment around the use and generation of tokens for the JLL/T Design System

Basic Style Dictionary This example code is bare-bones to show you what this framework can do. If you have the style-dictionary module installed globa

null 0 Dec 7, 2021
WebDomHandling - A Swift Package for handling JavaScript code between WebKit and Swift implemented by WebKit

WebDomHandling A Swift Package for handling JavaScript code between WebKit and S

null 0 Jan 23, 2022
A Swift SPM framework for running and managing Lua code from Swift

LuaKit A Swift Package for running and managing Lua code from Swift. Documentation For documentation, add this package as Swift Package Dependency, an

GGorAA 5 Nov 24, 2022
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Dec 31, 2022
SwiftTypeReader - You can gather type definitions from Swift source code.

SwiftTypeReader - You can gather type definitions from Swift source code.

omochimetaru 23 Dec 12, 2022
React Native library that implements PayPal Checkout flow using purely native code (swift).

react-native-paypal-swift React Native library that implements PayPal Checkout flow using purely native code (swift). Installation npm install react-n

Tibb 6 Nov 28, 2022
Some helpful swift code snippets

HelpfulSwiftSnippets Some helpful swift code snippets Network Manager - a generic network manager that deals with downloading data from the internet u

null 2 Oct 17, 2021
How to use swiftlint to identify unused code or unused imports in a Swift codebase

Swift compilation database This repository demonstrates how to use swiftlint to identify unused code or unused imports in a Swift codebase. How to run

Andrés Cecilia Luque 3 Aug 26, 2022
A simple Swift sample code to reads ISO 10303-21 exchange structure (STEP P21) file for AP242 schema.

simpleP21ReadSample A simple sample code to reads ISO 10303-21 exchange structure (STEP P21) file for AP242 schema. by Tsutomu Yoshida, Minokamo Japan

Tsutomu Yoshida 1 Nov 23, 2021
A template to solve Advent of Code problems using Swift

Advent Of Code Swift Template This repository serves as a template for an Xcode project set up to solve the Advent of Code problems in Swift. No attem

Christopher Luu 5 Dec 7, 2022
Swift solutions for Advent of Code 2021

Advent Of Code Swift Template This repository serves as a template for an Xcode project set up to solve the Advent of Code problems in Swift. No attem

Christopher Luu 1 Dec 5, 2022
Generate Swift code from Qt5 user interfaces.

Qlift-uic Description qlift-uic takes a Qt5 user interface description file and compiles it to Swift code for use with QLift. Splitted from main QLift

Dmitriy Borovikov 1 Apr 2, 2022
XCSnippetsApp - macOS application to explore code snippets from the Swift and iOS community, view and edit the snippets before adding them conveniently to Xcode

XCSnippetsApp macOS application to explore code snippets from the Swift and iOS community, view and edit the snippets before adding them conveniently

Marco Eidinger 119 Dec 27, 2022
Command line tool for exporting resources and generating code from your Figma files

Fugen Fugen is a command line tool for exporting resources and generating code from your Figma files. Currently, Fugen supports the following entities

Almaz Ibragimov 69 Dec 17, 2022
Some code for playing with the Teenage Engineering Ortho Remote

ortho-remote C program for interfacing with the Teenage Engineering Ortho Remote. Currently only implemented for macOS Puts the remote into MIDI mode

Rasmus 13 Oct 18, 2022
The iOS pod which can collect profile data to detect code coverage.

CodeCoverageKit Installation CodeCoverageKit is available through CocoaPods.

木子 2 Sep 29, 2021
Yumemi Co., Ltd. iOS engineer code check task

株式会社ゆめみ iOS エンジニアコードチェック課題 概要 本プロジェクトは株式会社ゆめみ(以下弊社)が、弊社に iOS エンジニアを希望する方に出す課題のベースプロジェクトです。本課題が与えられた方は、下記の概要を詳しく読んだ上で課題を取り組んでください。 アプリ仕様 本アプリは GitHub の

akidon 0 Oct 31, 2021
High-quality source code, easy implementation

High-quality source code, easy implementation

T.M 0 Nov 8, 2021