Skip to content

Commit d9564c7

Browse files
SwaggerJSONファイルの更新
## 更新内容 * DeviceConnectSDKForIOSが参照しているDeviceConnect-SpecのJSONファイルの参照先を更新 * そのため、SDK側でapiディレクトリを削除し、download-spec.shを再度実行していただく必要があります。
1 parent cbac300 commit d9564c7

2 files changed

Lines changed: 55 additions & 6 deletions

File tree

dConnectSDK/dConnectSDKForIOS/DConnectSDK/Classes/profile/DConnectServiceInformationProfile.m

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@
2424
NSString *const DConnectServiceInformationProfileParamNFC = @"nfc";
2525
NSString *const DConnectServiceInformationProfileParamBLE = @"ble";
2626

27-
static NSString *const KEY_PATHS = @"paths";
27+
static NSString *const DConnectServiceInformationProfileKeyPaths = @"paths";
28+
29+
static NSString *const DConnectServiceInformationProfileKeyInfo = @"info";
30+
static NSString *const DConnectServiceInformationProfileKeyDefinitions = @"definitions";
31+
static NSString *const DConnectServiceInformationProfileKeyResponses = @"responses";
32+
static NSString *const DConnectServiceInformationProfileKeyParameters = @"parameters";
33+
static NSString *const DConnectServiceInformationProfileKeyXEvent = @"x-event";
34+
static NSString *const DConnectServiceInformationProfileKeySummary = @"summary";
35+
static NSString *const DConnectServiceInformationProfileKeyDescription = @"description";
2836

2937
@interface DConnectServiceInformationProfile()
3038

@@ -115,6 +123,8 @@ + (BOOL) setSupportApis:(NSArray *)profiles target:(DConnectMessage *)message er
115123
if (![DConnectServiceInformationProfile createSupportApisBundle: profileSpec profile: profile outBundle:&bundle error:error]) {
116124
return NO;
117125
}
126+
// 送信しない情報はここで削除
127+
[DConnectServiceInformationProfile reduceInformationForApi:bundle outApi:&bundle];
118128
NSString *profileName = [profile profileName];
119129
supportApis[profileName] = bundle;
120130
}
@@ -135,7 +145,7 @@ + (BOOL) createSupportApisBundle: (DConnectProfileSpec *) profileSpec profile: (
135145
NSMutableDictionary *tmpBundle = CFBridgingRelease(tmpBundle_);
136146

137147
// API定義(JSONファイルから読み取ったデータ)のうち、プロファイルにAPIが未実装のものは削除する
138-
NSMutableDictionary *pathsObj = tmpBundle[KEY_PATHS];
148+
NSMutableDictionary *pathsObj = tmpBundle[DConnectServiceInformationProfileKeyPaths];
139149
if (!pathsObj) {
140150
*outBundle = tmpBundle;
141151
return YES;
@@ -169,6 +179,45 @@ + (BOOL) createSupportApisBundle: (DConnectProfileSpec *) profileSpec profile: (
169179
return YES;
170180
}
171181

182+
+ (void) reduceInformationForApi:(NSDictionary*)api outApi:(NSDictionary**)outApi {
183+
CFPropertyListRef *tmpBundle_ = (CFPropertyListRef *)CFPropertyListCreateDeepCopy(kCFAllocatorDefault,
184+
(CFDictionaryRef)api,
185+
kCFPropertyListMutableContainersAndLeaves);
186+
NSMutableDictionary *supportApi = CFBridgingRelease(tmpBundle_);
187+
NSMutableDictionary* infoObj = supportApi[DConnectServiceInformationProfileKeyInfo];
188+
if (infoObj != nil) {
189+
[infoObj removeObjectForKey:DConnectServiceInformationProfileKeyDescription];
190+
}
191+
NSMutableDictionary *pathsObj = supportApi[DConnectServiceInformationProfileKeyPaths];
192+
if (pathsObj != nil) {
193+
for (NSString *pathName in [pathsObj keyEnumerator]) {
194+
NSMutableDictionary *pathObj = pathsObj[pathName];
195+
if (pathObj == nil) {
196+
continue;
197+
}
198+
for (NSString *method in DConnectSpecMethods()) {
199+
NSMutableDictionary *methodObj = pathObj[[method lowercaseString]];
200+
if (methodObj == nil) {
201+
continue;
202+
}
203+
[methodObj removeObjectForKey:DConnectServiceInformationProfileKeyResponses];
204+
[methodObj removeObjectForKey:DConnectServiceInformationProfileKeyXEvent];
205+
[methodObj removeObjectForKey:DConnectServiceInformationProfileKeySummary];
206+
[methodObj removeObjectForKey:DConnectServiceInformationProfileKeyDescription];
207+
208+
NSMutableArray *parameters = methodObj[DConnectServiceInformationProfileKeyParameters];
209+
if (parameters != nil) {
210+
for (NSMutableDictionary *parameter in parameters) {
211+
[parameter removeObjectForKey:DConnectServiceInformationProfileKeyDescription];
212+
}
213+
}
214+
}
215+
}
216+
}
217+
[supportApi removeObjectForKey:DConnectServiceInformationProfileKeyDefinitions];
218+
219+
*outApi = supportApi;
220+
}
172221
// NSDictionaryをDConnectMessageに変換
173222
+ (DConnectMessage *) convertToDConnectMessageFromNSDictionary: (NSDictionary *)dictionary {
174223

dConnectSDK/dConnectSDKForIOS/download-spec.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
PROJECT_DIR=$(cd $(dirname $0) && pwd)
44
TEMP_DIR=${PROJECT_DIR}/temp-`date +%s`
5-
REVISION=feature_plugin_sdk_2.0.0
5+
REVISION=master
66
SPEC_ZIP_NAME=${REVISION}.zip
7-
SPEC_ZIP_URL=https://github.com/TakayukiHoshi1984/DeviceConnect-Spec/archive/${SPEC_ZIP_NAME}
7+
SPEC_ZIP_URL=https://github.com/DeviceConnect/DeviceConnect-Spec/archive/${SPEC_ZIP_NAME}
88
SPEC_DIR=${PROJECT_DIR}/DConnectSDK_resources/api
99

1010
if [ -e ${SPEC_DIR} ]; then
@@ -18,8 +18,8 @@ cd ${TEMP_DIR}
1818
echo "Download URL: ${SPEC_ZIP_URL}"
1919
curl -L -O -k ${SPEC_ZIP_URL}
2020

21-
unzip -d . ${SPEC_ZIP_NAME}
22-
cp ${TEMP_DIR}/DeviceConnect-Spec-${REVISION}/api/*.json ${SPEC_DIR}
21+
unzip -d . ${SPEC_ZIP_NAME} "*.json"
22+
cp -r ${TEMP_DIR}/DeviceConnect-Spec-${REVISION}/api/*.json ${SPEC_DIR}
2323
rm -rf ${TEMP_DIR}
2424

2525
# ファイル名を小文字に統一

0 commit comments

Comments
 (0)