gerlowskija commented on code in PR #1960: URL: https://github.com/apache/solr/pull/1960#discussion_r1344314087
########## solr/api/src/java/org/apache/solr/client/api/model/CreateCollectionRequestBody.java: ########## @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.client.api.model; + +import static org.apache.solr.client.api.model.Constants.NUM_SLICES; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; +import java.util.Map; + +/** Request body for v2 "create collection" requests */ +public class CreateCollectionRequestBody { + @JsonProperty public String name; + + @JsonProperty public Integer replicationFactor; + + @JsonProperty public String config; + + @JsonProperty(NUM_SLICES) + @Schema(name = "numShards") + public Integer numShards; Review Comment: Thanks for highlighting this section - I think having `@Schema` here is a mistake on my part, which I'll fix. To answer your underlying question though: **JsonProperty** `@JsonProperty` is all about how this request body is serialized/deserialized by Jackson. If you give the annotation a value, Jackson uses that as the property name when serializing/deserializing. If no value is given, the name of the instance variable is used by default. (Since the constant `NUM_SLICES` has the value `"numShards"` and matches the variable name, I probably should've not specified any value here - I think this was a copy/paste oversight.) **Schema** The `@Schema` annotation otoh is all about metadata. It lets you provide descriptions, additional references, alternate names, etc. into the generated OpenAPI Spec ("OAS"), and therefore into the client code that's generated from that OAS. The `name` property that we're using here lets you associate an identifier with the field in question. So mostly you'll see `@Schema(name=...` when the name of a property in the OAS should be different than the field name Jackson uses to serialize it. (This is important from a good-docs perspective sometimes, but it's also something our Java-code-generation template relies on periodically) There's no reason to use `@Schema` here, since the variable name and both annotations all work out to the literal `"numShards"` - so I'll remove it. Not sure how this got here: maybe I started to add a description before getting distracted? In any case, I appreciate you flagging it. ---- > I feel the "slices" nomenclature is an unfortunate one that we should get away from, at least on the API surface. Idk whether I like "slices" or not, but I'll remove it here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org