我想使用MVC模式开发API.我发现sails框架很有趣,我想知道是否可以配置swagger或类似于sails的东西来生成我的API文档(例如swagger-express for express).
谢谢!
我想尝试使用Java收集器编写以下代码。
给定一个人的2个属性(名字和姓氏),我想获得一张包含唯一的名字或姓氏作为键的地图,以及相应人物的列表。
这是一组数据:
Person person1 = new Person();
person1.setFirstName("john");
person1.setLastName("doe");
person1.setUserId("user1");
Person person2 = new Person();
person2.setFirstName("doe");
person2.setLastName("frank");
person2.setUserId("user2");
Person person3 = new Person();
person3.setFirstName("john");
person3.setLastName("wayne");
person3.setUserId("user3");
List<Person> personList = new ArrayList<>();
personList.add(person1);
personList.add(person2);
personList.add(person3);
Run Code Online (Sandbox Code Playgroud)
输出(预期)如下:
frank=[Person{userId='user2', firstName='doe', lastName='frank'}],
john=[Person{userId='user1', firstName='john', lastName='doe'}, Person{userId='user3', firstName='john', lastName='wayne'}],
doe=[Person{userId='user1', firstName='john', lastName='doe'}, Person{userId='user2', firstName='doe', lastName='frank'}],
wayne=[Person{userId='user3', firstName='john', lastName='wayne'}]
Run Code Online (Sandbox Code Playgroud)
以及填充地图的代码:
Map<String, List<Person>> mapPersons = new HashMap<String, List<Person>>();
List<Person> listPersons;
for (Person p: personList) {
if (mapPersons.get(p.getFirstName()) == null) {
listPersons = new ArrayList<Person>();
listPersons.add(p);
mapPersons.put(p.getFirstName(), …Run Code Online (Sandbox Code Playgroud) 我在功能api方面遇到了麻烦.我正试图从我的Android可穿戴设备向我的手机发送消息.我检测到一个功能,但根本没有节点.
private static final String CAPABILITY_NAME = "mobile";
@Override
public void onConnected(Bundle bundle) {
Log.d(TAG, "CONNECTED TO API");
setupNode();
Wearable.CapabilityApi.addCapabilityListener(mApiClient, capabilityListener, CAPABILITY_NAME);
}
private void setupNode() {
new Thread(new Runnable() {
@Override
public void run() {
Wearable.CapabilityApi.getCapability(
mApiClient, CAPABILITY_NAME,
CapabilityApi.FILTER_REACHABLE).setResultCallback(new ResultCallback<CapabilityApi.GetCapabilityResult>() {
@Override
public void onResult(CapabilityApi.GetCapabilityResult result) {
if (result.getCapability() == null) {
Log.d(TAG, "we detected no capability");
} else {
Log.d(TAG, "we detected a capability");
}
updateCapability(result.getCapability());
}
});
}
}).start();
}
private void updateCapability(CapabilityInfo capabilityInfo) {
Set<Node> connectedNodes …Run Code Online (Sandbox Code Playgroud) 我正在使用node-soap模块,它工作正常,除非我在代理后面工作.我无法找到设置该代理的方法,因此我可以请求API.
soap.createClient(url, function(err, client) {
client.MyFunction(args, function(err, result) {
console.log(result);
});
});
Run Code Online (Sandbox Code Playgroud)
它写在文档中:
The options argument allows you to customize the client with the following properties:
request: to override the request module.
httpClient: to provide your own http client that implements request(rurl, data, callback, exheaders, exoptions).
Run Code Online (Sandbox Code Playgroud)
这是要走的路吗?
node.js ×2
java ×1
java-8 ×1
java-stream ×1
node-soap ×1
sails.js ×1
soap ×1
soap-client ×1
swagger ×1
wear-os ×1