Skip to content

Commit d5af6e7

Browse files
Merge pull request #32 from TakayukiHoshi1984/modify_codegen_1_5_1
不具合修正: YAMLを入力すると異常終了
2 parents ebb0528 + 34bda4d commit d5af6e7

5 files changed

Lines changed: 19 additions & 4 deletions

File tree

DeviceConnectCodegen/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ DeviceConnect Codegenは、DeviceConnectシステム上で動作するプラグ
3333
|samples/profiles-specs|シェルスクリプトのサンプルに入力するプロファイル定義ファイル群。|
3434

3535
## Get Started
36-
[deviceconnect-codegen-project-1.5.0-dist.zip](https://github.com/TakayukiHoshi1984/DeviceConnect-Experiments/releases/tag/codegen-v1.5.0) をPC上の任意の場所にダウンロードし、解凍してください。
36+
[deviceconnect-codegen-project-1.5.1-dist.zip](https://github.com/TakayukiHoshi1984/DeviceConnect-Experiments/releases/tag/codegen-v1.5.1) をPC上の任意の場所にダウンロードし、解凍してください。
3737

3838
解凍後、ターミナルを起動し、以下のコマンドによりをサンプルのスケルトンコードを生成してください。
3939

@@ -156,6 +156,7 @@ java -jar bin/deviceconnect-codegen.jar [オプション]
156156
<tr>
157157
<td valign="top"><pre>--display-name</pre></td>
158158
<td valign="top">
159+
<b>[プラグインまたはアプリケーションのみ有効]</b><br>
159160
スケルトンコードの名前の指定。<br>
160161
<br>
161162
プラグインの場合、System APIによって取得できるデバイスプラグインの名前として使用される。アプリケーションの場合、主にアプリケーションのタイトルとして表示する名前として使用される。<br>

DeviceConnectCodegen/RELEASENOTE.TXT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# 変更履歴
2+
2017/12/20: v1.5.1 [Markdown][HTML] 不具合修正: APIリファレンスの「概要」が空の状態で出力される
3+
[共通] 不具合修正: input-specオプションにYAML形式のファイルを指定すると異常終了
4+
25
2017/11/30: v1.5.0 [Android] DeviceConnectManagerへの複数プラグイン同梱仕様対応
36
[共通] エラーメッセージの詳細化
47
[共通] 不具合修正: basePathの長さが1のプロファイルを定義した場合に異常終了

DeviceConnectCodegen/modules/deviceconnect-codegen/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.deviceconnect</groupId>
88
<artifactId>deviceconnect-codegen</artifactId>
9-
<version>1.5.0</version>
9+
<version>1.5.1</version>
1010

1111
<packaging>jar</packaging>
1212

DeviceConnectCodegen/modules/deviceconnect-codegen/src/main/java/org/deviceconnect/codegen/DConnectCodegen.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import com.fasterxml.jackson.databind.JsonNode;
55
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
67
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
78
import config.Config;
89
import config.ConfigParser;
@@ -273,7 +274,17 @@ public File writeToFile(final String filename, final String contents) throws IOE
273274
}
274275

275276
private static boolean checkSwagger(final File file) throws IOException, ProcessingException {
276-
JsonNode jsonNode = new ObjectMapper().readTree(file);
277+
String fileName = file.getName();
278+
ObjectMapper mapper;
279+
if (fileName.endsWith(".yaml")) {
280+
mapper = new ObjectMapper(new YAMLFactory());
281+
} else if (fileName.endsWith(".json")) {
282+
mapper = new ObjectMapper();
283+
} else {
284+
throw new IllegalArgumentException("file must be JSON or YAML.");
285+
}
286+
287+
JsonNode jsonNode = mapper.readTree(file);
277288
SwaggerJsonValidator.Result result = JSON_VALIDATOR.validate(jsonNode);
278289
if (result.isSuccess()) {
279290
return true;

DeviceConnectCodegen/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.deviceconnect</groupId>
88
<artifactId>deviceconnect-codegen-project</artifactId>
9-
<version>1.5.0</version>
9+
<version>1.5.1</version>
1010

1111
<packaging>pom</packaging>
1212

0 commit comments

Comments
 (0)