我想知道是否有一种方法可以根据json模式输入生成样本json输出.
例如 :-
input =>
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
output =>
{
"firstName" : "RandomFirstName",
"lastName" : "RandomLastName"
}
Run Code Online (Sandbox Code Playgroud)
我有一个大型的Json Schema,有大量的验证,所以要生成一个有效的json示例,我可以使用Java手动创建一个,也可以只在文件中输入.有更好的方法吗?
我尝试在网上挖掘以解答我的问题.我找到了一些与达芬奇项目有关的文件.这被标记为JSR 292,它与在JVM中包含闭包有关.这个项目是否实现了,它是Java 8的一部分吗?
我知道AWS IAM支持与外部SAML提供程序集成(http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_saml.html),Cognito是其联合身份提供程序,但我想知道AWS Cognito /是否IAM可以用作其他应用程序的SAML IDP
我们如何确保列表中的各个字符串不为空/空或遵循特定模式
@NotNull
List<String> emailIds;
Run Code Online (Sandbox Code Playgroud)
我还想添加一个模式
@Pattern("\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b.")
但我可以没有它.但我肯定希望有一个约束,它将检查列表中的任何字符串是否为空或空白.Json架构也将如何
"ids": {
"description": "The ids associated with this.",
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"required" :true }
}
"required" :true does not seem to do the job
Run Code Online (Sandbox Code Playgroud) 我试图在2个不同的端口8080和9000上运行2个Dropwizard服务器应用程序.第一个应用程序启动成功,但当我尝试在端口9000上运行时,我一直得到以下异常.我不明白的是为什么2个端口正在应用程序使用的,以及如何强制我的应用程序为第二个端口使用不同的端口号
INFO [2014-03-22 17:17:28,031] org.eclipse.jetty.server.AbstractConnector: Started
InstrumentedBlockingChannelConnector@0.0.0.0:9000
WARN [2014-03-22 17:17:28,033] org.eclipse.jetty.util.component.AbstractLifeCycle: FAILED
SocketConnector@0.0.0.0:8081: java.net.BindException: Address already in use
! java.net.BindException: Address already in use
! at org.eclipse.jetty.server.bio.SocketConnector.newServerSocket(SocketConnector.java:96)
~[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.bio.SocketConnector.open(SocketConnector.java:85) ~[jetty-
server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316) ~
[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.bio.SocketConnector.doStart(SocketConnector.java:156) ~
[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[jetty-util-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.Server.doStart(Server.java:291) [jetty-server-
8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
[jetty-util-8.1.10.v20130312.jar:8.1.10.v20130312]
! at com.yammer.dropwizard.cli.ServerCommand.run(ServerCommand.java:48) [dropwizard-core-
0.6.2.jar:na]
! at com.yammer.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:39)
[dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:58)
[dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.cli.Cli.run(Cli.java:53) [dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.Service.run(Service.java:61) [dropwizard-core-0.6.2.jar:na]
! at com.paypal.demandgen.places.indexing.IndexingServer.main(IndexingServer.java:96) …Run Code Online (Sandbox Code Playgroud) 在java中创建N列表联合的最佳方法是什么?
例如
List<Integer> LIST_1 = Lists.newArrayList(1);
List<Integer> LIST_2 = Lists.newArrayList(2);
List<Integer> LIST_3 = Lists.newArrayList(3);
List<Integer> LIST_4 = Lists.newArrayList(4);
List<Integer> LIST_1_2_3_4 = Lists.newArrayList(1,2,3,4);
assert LIST_1_2_3_4.equals(union(LIST_1,LIST_2,LIST_3,LIST_4));
The union method will take a var args parameter
<Item> List<Item> union(List<Item> ... itemLists)
Run Code Online (Sandbox Code Playgroud)
是否有一个提供此方法的库.最简单的方法是遍历数组并将每个列表累加为一个
HOST_NAME_="localhost:8080"
HOST_NAME_stg="stg.com:8080"
HOST_NAME_qa="qa.com:8080"
HOST_NAME=${!"HOST_NAME_$1"}
echo -n ${HOST_NAME}
Run Code Online (Sandbox Code Playgroud)
我得到错误替换错误.但是如果传递的参数是stg,我想打印stg.com:8080.我该怎么做
java ×5
json ×2
amazon-iam ×1
aws-cognito ×1
collections ×1
dropwizard ×1
indirection ×1
java-8 ×1
jetty-8 ×1
jsr ×1
port ×1
shell ×1
unix ×1
validation ×1