Merge pull request #3056 from mateuszmackowiak/objc/core_data_unique-id-key

[Objc] Support for x-unique-id-key vendorExtensions
This commit is contained in:
wing328 2016-06-13 23:47:31 +08:00 committed by GitHub
commit eb42f99bb5
7 changed files with 23 additions and 4 deletions

View File

@ -2,8 +2,10 @@
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="9525" systemVersion="15D21" minimumToolsVersion="Xcode 7.0"> <model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="9525" systemVersion="15D21" minimumToolsVersion="Xcode 7.0">
{{#models}}{{#model}}<entity name="{{{classname}}}ManagedObject" representedClassName="{{{classname}}}ManagedObject" syncable="YES"> {{#models}}{{#model}}<entity name="{{{classname}}}ManagedObject" representedClassName="{{{classname}}}ManagedObject" syncable="YES">
{{#vars}}{{#complexType}} <relationship name="{{name}}" {{^required}}optional="YES"{{/required}} {{#isListContainer}}toMany="YES"{{/isListContainer}}{{^isListContainer}}maxCount="1"{{/isListContainer}} deletionRule="Cascade" destinationEntity="{{{complexType}}}ManagedObject" syncable="YES"/>{{/complexType}}{{^complexType}} <attribute name="{{name}}" {{^required}}optional="YES"{{/required}} attributeType="{{#isString}}String{{/isString}}{{#isInteger}}Integer 16{{/isInteger}}{{#isLong}}Double{{/isLong}}{{#isDouble}}Double{{/isDouble}}{{#isFloat}}Float{{/isFloat}}{{#isByteArray}}Binary{{/isByteArray}}{{#isBinary}}Binary{{/isBinary}}{{#isListContainer}}Transformable{{/isListContainer}}{{#isMapContainer}}Transformable{{/isMapContainer}}{{#isBoolean}}Boolean{{/isBoolean}}{{#isDate}}Date{{/isDate}}{{#isDateTime}}Date{{/isDateTime}}" syncable="YES"/>{{/complexType}} {{#vars}}{{#complexType}} <relationship name="{{name}}" {{^required}}optional="YES"{{/required}} {{#isListContainer}}toMany="YES"{{/isListContainer}}{{^isListContainer}}maxCount="1"{{/isListContainer}} deletionRule="Cascade" destinationEntity="{{{complexType}}}ManagedObject" syncable="YES"/>{{/complexType}}{{^complexType}} <attribute name="{{name}}" {{^required}}optional="YES"{{/required}} attributeType="{{#isString}}String{{/isString}}{{#isInteger}}Integer 16{{/isInteger}}{{#isLong}}Double{{/isLong}}{{#isDouble}}Double{{/isDouble}}{{#isFloat}}Float{{/isFloat}}{{#isByteArray}}Binary{{/isByteArray}}{{#isBinary}}Binary{{/isBinary}}{{#isListContainer}}Transformable{{/isListContainer}}{{#isMapContainer}}Transformable{{/isMapContainer}}{{#isBoolean}}Boolean{{/isBoolean}}{{#isDate}}Date{{/isDate}}{{#isDateTime}}Date{{/isDateTime}}" syncable="YES"/>{{/complexType}}{{#vendorExtensions.x-unique-id-key}}
<uniquenessConstraints><uniquenessConstraint><constraint value="{{name}}"/></uniquenessConstraint></uniquenessConstraints>{{/vendorExtensions.x-unique-id-key}}
{{/vars}} {{/vars}}
</entity> </entity>
{{/model}}{{/models}} {{/model}}{{/models}}
</model> </model>

View File

@ -13,7 +13,11 @@
} }
return self; return self;
} }
{{#vars}}{{^vendorExtensions.x-unique-id-key}}{{/vendorExtensions.x-unique-id-key}}{{#vendorExtensions.x-unique-id-key}}
-(NSString*)indexPropertyName {
return @"{{name}}";
}
{{/vendorExtensions.x-unique-id-key}}{{/vars}}
{{#discriminator}} {{#discriminator}}
/** /**
* Maps "discriminator" value to the sub-class name, so that inheritance is supported. * Maps "discriminator" value to the sub-class name, so that inheritance is supported.

View File

@ -717,6 +717,7 @@ definitions:
id: id:
type: integer type: integer
format: int64 format: int64
x-is-unique: true
username: username:
type: string type: string
firstName: firstName:
@ -754,6 +755,7 @@ definitions:
id: id:
type: integer type: integer
format: int64 format: int64
x-is-unique: true
category: category:
$ref: '#/definitions/Category' $ref: '#/definitions/Category'
name: name:

View File

@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi
- API version: 1.0.0 - API version: 1.0.0
- Package version: - Package version:
- Build date: 2016-05-27T16:03:28.462+02:00 - Build date: 2016-06-06T12:11:50.444+02:00
- Build package: class io.swagger.codegen.languages.ObjcClientCodegen - Build package: class io.swagger.codegen.languages.ObjcClientCodegen
## Requirements ## Requirements

View File

@ -1,6 +1,6 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <ISO8601/ISO8601.h> #import <ISO8601/ISO8601.h>
#import <AFNetworking.h> #import <AFNetworking/AFNetworking.h>
#import "SWGJSONResponseSerializer.h" #import "SWGJSONResponseSerializer.h"
#import "SWGJSONRequestSerializer.h" #import "SWGJSONRequestSerializer.h"
#import "SWGQueryParamCollection.h" #import "SWGQueryParamCollection.h"

View File

@ -50,6 +50,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
- (instancetype)initWithBaseURL:(NSURL *)url { - (instancetype)initWithBaseURL:(NSURL *)url {
self = [super initWithBaseURL:url]; self = [super initWithBaseURL:url];
if (self) { if (self) {
self.timeoutInterval = 60;
self.requestSerializer = [AFJSONRequestSerializer serializer]; self.requestSerializer = [AFJSONRequestSerializer serializer];
self.responseSerializer = [AFJSONResponseSerializer serializer]; self.responseSerializer = [AFJSONResponseSerializer serializer];
self.securityPolicy = [self customSecurityPolicy]; self.securityPolicy = [self customSecurityPolicy];
@ -87,6 +88,11 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
[self.requestSerializer setValue:value forHTTPHeaderField:forKey]; [self.requestSerializer setValue:value forHTTPHeaderField:forKey];
} }
- (void)setRequestSerializer:(AFHTTPRequestSerializer<AFURLRequestSerialization> *)requestSerializer {
[super setRequestSerializer:requestSerializer];
requestSerializer.timeoutInterval = self.timeoutInterval;
}
#pragma mark - Cache Methods #pragma mark - Cache Methods
+(void)clearCache { +(void)clearCache {

View File

@ -4,6 +4,7 @@
<entity name="SWGCategoryManagedObject" representedClassName="SWGCategoryManagedObject" syncable="YES"> <entity name="SWGCategoryManagedObject" representedClassName="SWGCategoryManagedObject" syncable="YES">
<attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/> <attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/>
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/> <attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
</entity> </entity>
<entity name="SWGOrderManagedObject" representedClassName="SWGOrderManagedObject" syncable="YES"> <entity name="SWGOrderManagedObject" representedClassName="SWGOrderManagedObject" syncable="YES">
<attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/> <attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/>
@ -12,6 +13,7 @@
<attribute name="shipDate" optional="YES" attributeType="Date" syncable="YES"/> <attribute name="shipDate" optional="YES" attributeType="Date" syncable="YES"/>
<attribute name="status" optional="YES" attributeType="String" syncable="YES"/> <attribute name="status" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="complete" optional="YES" attributeType="Boolean" syncable="YES"/> <attribute name="complete" optional="YES" attributeType="Boolean" syncable="YES"/>
</entity> </entity>
<entity name="SWGPetManagedObject" representedClassName="SWGPetManagedObject" syncable="YES"> <entity name="SWGPetManagedObject" representedClassName="SWGPetManagedObject" syncable="YES">
<attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/> <attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/>
@ -20,10 +22,12 @@
<attribute name="photoUrls" attributeType="Transformable" syncable="YES"/> <attribute name="photoUrls" attributeType="Transformable" syncable="YES"/>
<relationship name="tags" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="SWGTagManagedObject" syncable="YES"/> <relationship name="tags" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="SWGTagManagedObject" syncable="YES"/>
<attribute name="status" optional="YES" attributeType="String" syncable="YES"/> <attribute name="status" optional="YES" attributeType="String" syncable="YES"/>
</entity> </entity>
<entity name="SWGTagManagedObject" representedClassName="SWGTagManagedObject" syncable="YES"> <entity name="SWGTagManagedObject" representedClassName="SWGTagManagedObject" syncable="YES">
<attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/> <attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/>
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/> <attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
</entity> </entity>
<entity name="SWGUserManagedObject" representedClassName="SWGUserManagedObject" syncable="YES"> <entity name="SWGUserManagedObject" representedClassName="SWGUserManagedObject" syncable="YES">
<attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/> <attribute name="_id" optional="YES" attributeType="Double" syncable="YES"/>
@ -34,6 +38,7 @@
<attribute name="password" optional="YES" attributeType="String" syncable="YES"/> <attribute name="password" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="phone" optional="YES" attributeType="String" syncable="YES"/> <attribute name="phone" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="userStatus" optional="YES" attributeType="Integer 16" syncable="YES"/> <attribute name="userStatus" optional="YES" attributeType="Integer 16" syncable="YES"/>
</entity> </entity>
</model> </model>