Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pacedotdev/oto
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.10.5
Choose a base ref
...
head repository: pacedotdev/oto
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.10.6
Choose a head ref
  • 5 commits
  • 15 files changed
  • 2 contributors

Commits on Sep 28, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    98b943e View commit details

Commits on Sep 29, 2020

  1. more work on swift client

    matryer committed Sep 29, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2e8295e View commit details
  2. more work on swift client

    matryer committed Sep 29, 2020
    Copy the full SHA
    9461014 View commit details
  3. added Swift type names

    matryer committed Sep 29, 2020
    Copy the full SHA
    0c82632 View commit details
  4. finished swift client

    matryer committed Sep 29, 2020
    Copy the full SHA
    70db1dc View commit details
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -15,3 +15,5 @@
oto
.DS_Store
dist
example/swift/SwiftCLIExample/SwiftCLIExample.xcodeproj/project.xcworkspace/xcuserdata/matryer.xcuserdatad/UserInterfaceState.xcuserstate
example/swift/SwiftCLIExample/SwiftCLIExample.xcodeproj/project.xcworkspace/xcuserdata/matryer.xcuserdatad/UserInterfaceState.xcuserstate
59 changes: 59 additions & 0 deletions example/client.swift.plush
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Code generated by oto; DO NOT EDIT.

import Foundation

class OtoClient {
var endpoint: String
init(withEndpoint url: String) {
self.endpoint = url
}
}

<%= for (service) in def.Services { %>
<%= format_comment_text(service.Comment) %>class <%= service.Name %> {
var client: OtoClient
init(withClient client: OtoClient) {
self.client = client
}
<%= for (method) in service.Methods { %>
<%= format_comment_text(method.Comment) %> func <%= camelize_down(method.Name) %>(withRequest <%= camelize_down(method.InputObject.TypeName) %>: <%= method.InputObject.TypeName %>, completion: @escaping (_ response: <%= method.OutputObject.TypeName %>?, _ error: Error?) -> ()) {
var request = URLRequest(url: URL(string: "\(self.client.endpoint)/<%= service.Name %>.<%= method.Name %>")!)
request.httpMethod = "POST"
request.addValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.addValue("application/json; charset=utf-8", forHTTPHeaderField: "Accept")
var jsonData: Data
do {
jsonData = try JSONEncoder().encode(<%= camelize_down(method.InputObject.TypeName) %>)
} catch let err {
completion(nil, err)
return
}
request.httpBody = jsonData
let session = URLSession(configuration: URLSessionConfiguration.default)
let task = session.dataTask(with: request) { (data, response, error) in
if let err = error {
completion(nil, err)
return
}
var <%= camelize_down(method.OutputObject.TypeName) %>: <%= method.OutputObject.TypeName %>
do {
<%= camelize_down(method.OutputObject.TypeName) %> = try JSONDecoder().decode(<%= method.OutputObject.TypeName %>.self, from: data!)
} catch let err {
completion(nil, err)
return
}
completion(<%= camelize_down(method.OutputObject.TypeName) %>, nil)
}
task.resume()
}
<% } %>
}
<% } %>

<%= for (object) in def.Objects { %>
<%= format_comment_text(object.Comment) %>struct <%= object.Name %>: Encodable, Decodable {
<%= for (field) in object.Fields { %>
<%= format_comment_text(field.Comment) %> var <%= camelize_down(field.Name) %>: <%= field.Type.SwiftType %>?
<% } %>
}
<% } %>
1 change: 1 addition & 0 deletions example/def/greeter_service.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package def

// GreeterService is a polite API for greeting people.
type GreeterService interface {
// Greet prepares a lovely greeting.
Greet(GreetRequest) GreetResponse
}

6 changes: 6 additions & 0 deletions example/generate.sh
Original file line number Diff line number Diff line change
@@ -12,3 +12,9 @@ oto -template client.js.plush \
-pkg main \
./def
echo "generated client.gen.js"

oto -template client.swift.plush \
-out ./swift/SwiftCLIExample/SwiftCLIExample/client.gen.swift \
-pkg main \
./def
echo "generated client.gen.swift"
3 changes: 1 addition & 2 deletions example/server.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
0536E5D225222EB200E82696 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0536E5D125222EB200E82696 /* main.swift */; };
0536E5DF2523678400E82696 /* client.gen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0536E5DE2523678400E82696 /* client.gen.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
0536E5CC25222EB200E82696 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0536E5CE25222EB200E82696 /* SwiftCLIExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SwiftCLIExample; sourceTree = BUILT_PRODUCTS_DIR; };
0536E5D125222EB200E82696 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
0536E5DE2523678400E82696 /* client.gen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = client.gen.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
0536E5CB25222EB200E82696 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
0536E5C525222EB200E82696 = {
isa = PBXGroup;
children = (
0536E5D025222EB200E82696 /* SwiftCLIExample */,
0536E5CF25222EB200E82696 /* Products */,
);
sourceTree = "<group>";
};
0536E5CF25222EB200E82696 /* Products */ = {
isa = PBXGroup;
children = (
0536E5CE25222EB200E82696 /* SwiftCLIExample */,
);
name = Products;
sourceTree = "<group>";
};
0536E5D025222EB200E82696 /* SwiftCLIExample */ = {
isa = PBXGroup;
children = (
0536E5D125222EB200E82696 /* main.swift */,
0536E5DE2523678400E82696 /* client.gen.swift */,
);
path = SwiftCLIExample;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
0536E5CD25222EB200E82696 /* SwiftCLIExample */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0536E5D525222EB200E82696 /* Build configuration list for PBXNativeTarget "SwiftCLIExample" */;
buildPhases = (
0536E5CA25222EB200E82696 /* Sources */,
0536E5CB25222EB200E82696 /* Frameworks */,
0536E5CC25222EB200E82696 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = SwiftCLIExample;
productName = SwiftCLIExample;
productReference = 0536E5CE25222EB200E82696 /* SwiftCLIExample */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
0536E5C625222EB200E82696 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1200;
LastUpgradeCheck = 1200;
TargetAttributes = {
0536E5CD25222EB200E82696 = {
CreatedOnToolsVersion = 12.0.1;
};
};
};
buildConfigurationList = 0536E5C925222EB200E82696 /* Build configuration list for PBXProject "SwiftCLIExample" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0536E5C525222EB200E82696;
productRefGroup = 0536E5CF25222EB200E82696 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0536E5CD25222EB200E82696 /* SwiftCLIExample */,
);
};
/* End PBXProject section */

/* Begin PBXSourcesBuildPhase section */
0536E5CA25222EB200E82696 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0536E5DF2523678400E82696 /* client.gen.swift in Sources */,
0536E5D225222EB200E82696 /* main.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
0536E5D325222EB200E82696 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
0536E5D425222EB200E82696 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Release;
};
0536E5D625222EB200E82696 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
0536E5D725222EB200E82696 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
0536E5C925222EB200E82696 /* Build configuration list for PBXProject "SwiftCLIExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0536E5D325222EB200E82696 /* Debug */,
0536E5D425222EB200E82696 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0536E5D525222EB200E82696 /* Build configuration list for PBXNativeTarget "SwiftCLIExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0536E5D625222EB200E82696 /* Debug */,
0536E5D725222EB200E82696 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0536E5C625222EB200E82696 /* Project object */;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading