Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][doc] Use Text Blocks to improve JSON text #17521

Merged
merged 3 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ public void createCluster(
examples = @Example(
value = @ExampleProperty(
mediaType = MediaType.APPLICATION_JSON,
value =
"{\n"
+ " 'serviceUrl': 'http://pulsar.example.com:8080',\n"
+ " 'brokerServiceUrl': 'pulsar://pulsar.example.com:6651',\n"
+ "}"
value = """
{
"serviceUrl": "http://pulsar.example.com:8080",
"brokerServiceUrl": "pulsar://pulsar.example.com:6651",
}
"""
)
)
) ClusterDataImpl clusterData) {
Expand Down Expand Up @@ -201,11 +202,12 @@ public void updateCluster(
examples = @Example(
value = @ExampleProperty(
mediaType = MediaType.APPLICATION_JSON,
value =
"{\n"
+ " 'serviceUrl': 'http://pulsar.example.com:8080',\n"
+ " 'brokerServiceUrl': 'pulsar://pulsar.example.com:6651'\n"
+ "}"
value = """
{
"serviceUrl": "http://pulsar.example.com:8080",
"brokerServiceUrl": "pulsar://pulsar.example.com:6651"
}
"""
)
)
) ClusterDataImpl clusterData) {
Expand Down Expand Up @@ -247,10 +249,11 @@ public void setPeerClusterNames(@Suspended AsyncResponse asyncResponse,
required = true,
examples = @Example(
value = @ExampleProperty(mediaType = MediaType.APPLICATION_JSON,
value = "[\n"
+ " 'cluster-a',\n"
+ " 'cluster-b'\n"
+ "]")))
value = """
[
"cluster-a",
"cluster-b"
]""")))
LinkedHashSet<String> peerClusterNames) {
validateSuperUserAccessAsync()
.thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,21 @@ public void registerFunction(
value = {
@ExampleProperty(
mediaType = MediaType.TEXT_PLAIN,
value = " Example \n"
+ "\n"
+ " 1. Create a JSON object. \n"
+ "\n"
+ "{\n"
+ "\t\"inputs\": \"persistent://public/default/input-topic\",\n"
+ "\t\"parallelism\": \"4\",\n"
+ "\t\"output\": \"persistent://public/default/output-topic\",\n"
+ "\t\"log-topic\": \"persistent://public/default/log-topic\",\n"
+ "\t\"classname\": \"org.example.test.ExclamationFunction\",\n"
+ "\t\"jar\": \"java-function-1.0-SNAPSHOT.jar\"\n"
+ "}\n"
+ "\n"
+ "\n"
+ "2. Encapsulate the JSON object to a multipart object (in Python). \n"
+ "\n"
+ "from requests_toolbelt.multipart.encoder import MultipartEncoder \n"
+ "mp_encoder = MultipartEncoder( \n"
+ "\t[('functionConfig', "
+ "(None, json.dumps(config), 'application/json'))])\n"
value = """
Examples
1. Create a JSON object
{
"inputs": "persistent://public/default/input-topic",
"parallelism": "4",
"output": "persistent://public/default/output-topic",
"log-topic": "persistent://public/default/log-topic",
"classname": "org.example.test.ExclamationFunction",
"jar": "java-function-1.0-SNAPSHOT.jar"
}
2. Encapsulate the JSON object to a multipart object (in Python)
from requests_toolbelt.multipart.encoder import MultipartEncoders
mp_encoder = MultipartEncoder([('functionConfig',(None, json.dumps(config),\
'application/json'))])"""
)
}
)
Expand Down Expand Up @@ -309,14 +304,16 @@ public void updateFunction(
examples = @Example(
value = @ExampleProperty(
mediaType = MediaType.APPLICATION_JSON,
value = "{\n"
+ " \"inputs\": persistent://public/default/input-topic,\n"
+ " \"parallelism\": 4\n"
+ " \"output\": persistent://public/default/output-topic\n"
+ " \"log-topic\": persistent://public/default/log-topic\n"
+ " \"classname\": org.example.test.ExclamationFunction\n"
+ " \"jar\": java-function-1.0-SNAPSHOT.jar\n"
+ "}\n"
value = """
{
"inputs": "persistent://public/default/input-topic",
"parallelism": 4,
"output": "persistent://public/default/output-topic",
"log-topic": "persistent://public/default/log-topic",
"classname": "org.example.test.ExclamationFunction",
"jar": "java-function-1.0-SNAPSHOT.jar"
}
"""
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,23 @@ public void registerSink(@ApiParam(value = "The tenant of a Pulsar Sink") final
value = {
@ExampleProperty(
mediaType = MediaType.TEXT_PLAIN,
value = "Example \n"
+ "\n"
+ " 1. Create a JSON object. \n"
+ "\n"
+ "{\n"
+ "\t\"classname\": \"org.example.MySinkTest\",\n"
+ "\t\"inputs\": ["
+ "\"persistent://public/default/sink-input\"],\n"
+ "\t\"processingGuarantees\": \"EFFECTIVELY_ONCE\",\n"
+ "\t\"parallelism\": \"10\"\n"
+ "}\n"
+ "\n"
+ "\n"
+ "2. Encapsulate the JSON object to a multipart object "
+ "(in Python).\n"
+ "\n"
+ "from requests_toolbelt.multipart.encoder import "
+ "MultipartEncoder \n"
+ "mp_encoder = MultipartEncoder( \n"
+ "\t[('sinkConfig', "
+ "(None, json.dumps(config), 'application/json'))])\n"
value = """
Example
1. Create a JSON object.
{
"classname": "org.example.MySinkTest",
"inputs": ["persistent://public/default/sink-input"],
"processingGuarantees": "EFFECTIVELY_ONCE",
"parallelism": "10"
}
2. Encapsulate the JSON object to a multipart object \
(in Python).
from requests_toolbelt.multipart.encoder import \
MultipartEncoder
mp_encoder = MultipartEncoder(\
[('sinkConfig',\
(None, json.dumps(config), 'application/json'))])
"""
)
}
)
Expand Down Expand Up @@ -260,13 +256,14 @@ public void updateSink(@ApiParam(value = "The tenant of a Pulsar Sink") final @P
examples = @Example(
value = @ExampleProperty(
mediaType = MediaType.APPLICATION_JSON,
value = "{\n"
+ "\t\"classname\": \"org.example.SinkStressTest\",\n"
+ "\t\"inputs\": ["
+ "\"persistent://public/default/sink-input\"],\n"
+ "\t\"processingGuarantees\": \"EFFECTIVELY_ONCE\",\n"
+ "\t\"parallelism\": 5\n"
+ "}"
value = """
{
"classname": "org.example.SinkStressTest",
"inputs": ["persistent://public/default/sink-input"],
"processingGuarantees": "EFFECTIVELY_ONCE",
"parallelism": 5
}
"""
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,24 @@ public void registerSource(
examples = @Example(
value = @ExampleProperty(
mediaType = MediaType.TEXT_PLAIN,
value = " Example \n"
+ "\n"
+ "1. Create a JSON object. \n"
+ "\n"
+ "{\n"
+ "\t\"tenant\": \"public\",\n"
+ "\t\"namespace\": \"default\",\n"
+ "\t\"name\": \"pulsar-io-mysql\",\n"
+ "\t\"className\": \"TestSourceMysql\",\n"
+ "\t\"topicName\": \"pulsar-io-mysql\",\n"
+ "\t\"parallelism\": \"1\",\n"
+ "\t\"archive\": \"/connectors/pulsar-io-mysql-0.0.1.nar\",\n"
+ "\t\"schemaType\": \"avro\"\n"
+ "}\n"
+ "\n"
+ "\n"
+ "2. Encapsulate the JSON object to a multipart object (in Python). \n"
+ "\n"
+ "from requests_toolbelt.multipart.encoder import MultipartEncoder \n"
+ "mp_encoder = MultipartEncoder( \n"
+ "\t[('sourceConfig', "
+ "(None, json.dumps(config), 'application/json'))])\n"
value = """
Example
1. Create a JSON object.
{
"tenant": "public",
"namespace": "default",
"name": "pulsar-io-mysql",
"className": "TestSourceMysql",
"topicName": "pulsar-io-mysql",
"parallelism": "1",
"archive": "/connectors/pulsar-io-mysql-0.0.1.nar",
"schemaType": "avro"
}
2. Encapsulate the JSON object to a multipart object (in Python).
from requests_toolbelt.multipart.encoder import MultipartEncoder
mp_encoder = MultipartEncoder([('sourceConfig', \
(None, json.dumps(config), 'application/json'))])
"""
)
)
)
Expand Down Expand Up @@ -212,16 +208,18 @@ public void updateSource(
examples = @Example(
value = @ExampleProperty(
mediaType = MediaType.APPLICATION_JSON,
value = "{\n"
+ " \"tenant\": public\n"
+ " \"namespace\": default\n"
+ " \"name\": pulsar-io-mysql\n"
+ " \"className\": TestSourceMysql\n"
+ " \"topicName\": pulsar-io-mysql\n"
+ " \"parallelism\": 1\n"
+ " \"archive\": /connectors/pulsar-io-mysql-0.0.1.nar\n"
+ " \"schemaType\": avro\n"
+ "}\n"
value = """
{
"tenant": "public",
"namespace": "default",
"name": "pulsar-io-mysql",
"className": "TestSourceMysql",
"topicName": "pulsar-io-mysql",
"parallelism": 1,
"archive": "/connectors/pulsar-io-mysql-0.0.1.nar",
"schemaType": "avro"
}
"""
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class Person {
private String password;
private Sex sex;
private String telephoneNumber;
@org.apache.avro.reflect.AvroSchema("{ \"type\": \"long\", \"logicalType\": \"timestamp-millis\" }")
@org.apache.avro.reflect.AvroSchema("""
{ "type": "long", "logicalType": "timestamp-millis" }""")
private long dateOfBirth;
private Integer age;
private Company company;
Expand Down