Skip to content

Commit

Permalink
http-client-java, add package-version option (#5387)
Browse files Browse the repository at this point in the history
tested locally.
  • Loading branch information
weidongxu-microsoft authored Dec 17, 2024
1 parent ff550fa commit 8ee7ec2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private static void handleDPG(CodeModel codeModel, EmitterOptions emitterOptions
}

boolean includeApiViewProperties
= emitterOptions.includeApiViewProperties() != null && emitterOptions.includeApiViewProperties();
= emitterOptions.getIncludeApiViewProperties() != null && emitterOptions.getIncludeApiViewProperties();
if (includeApiViewProperties && !CoreUtils.isNullOrEmpty(typeSpecPlugin.getCrossLanguageDefinitionMap())) {
String flavor = emitterOptions.getFlavor() == null ? "azure" : emitterOptions.getFlavor();
StringBuilder sb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public TypeSpecFluentPlugin(EmitterOptions emitterOptions, boolean sdkIntegratio
if (emitterOptions.getArm()) {
SETTINGS_MAP.put("fluent", "lite");
}
if (emitterOptions.getPackageVersion() != null) {
SETTINGS_MAP.put("package-version", emitterOptions.getPackageVersion());
}
SETTINGS_MAP.put("sdk-integration", sdkIntegration);
SETTINGS_MAP.put("output-model-immutable", true);
SETTINGS_MAP.put("uuid-as-string", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class EmitterOptions implements JsonSerializable<EmitterOptions> {
private String customTypeSubpackage;
private String customizationClass;
private Boolean includeApiViewProperties = true;

private String packageVersion;
private Boolean useObjectForUnknown = false;
private Map<String, JavaSettings.PollingDetails> polling = new HashMap<>();
private Boolean arm = false;
Expand Down Expand Up @@ -102,7 +102,7 @@ public String getCustomizationClass() {
return customizationClass;
}

public Boolean includeApiViewProperties() {
public Boolean getIncludeApiViewProperties() {
return includeApiViewProperties;
}

Expand All @@ -126,29 +126,14 @@ public String getFlavor() {
return flavor;
}

public String getPackageVersion() {
return packageVersion;
}

@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
return jsonWriter.writeStartObject()
.writeStringField("namespace", namespace)
.writeStringField("output-dir", outputDir)
.writeStringField("flavor", flavor)
.writeStringField("service-name", serviceName)
.writeArrayField("service-versions", serviceVersions, JsonWriter::writeString)
.writeBooleanField("generate-tests", generateTests)
.writeBooleanField("generate-samples", generateSamples)
.writeBooleanField("enable-sync-stack", enableSyncStack)
.writeBooleanField("stream-style-serialization", streamStyleSerialization)
.writeBooleanField("partial-update", partialUpdate)
.writeStringField("custom-types", customTypes)
.writeStringField("custom-types-subpackage", customTypeSubpackage)
.writeStringField("customization-class", customizationClass)
.writeBooleanField("include-api-view-properties", includeApiViewProperties)
.writeBooleanField("use-object-for-unknown", useObjectForUnknown)
.writeMapField("polling", polling, JsonWriter::writeJson)
.writeBooleanField("arm", arm)
.writeStringField("models-subpackage", modelsSubpackage)
.writeJsonField("dev-options", devOptions)
.writeEndObject();
// it does not need to be written to JSON
return jsonWriter.writeStartObject().writeEndObject();
}

public static EmitterOptions fromJson(JsonReader jsonReader) throws IOException {
Expand Down Expand Up @@ -189,6 +174,8 @@ public static EmitterOptions fromJson(JsonReader jsonReader) throws IOException
options.arm = reader.getNullable(JsonReader::getBoolean);
} else if ("models-subpackage".equals(fieldName)) {
options.modelsSubpackage = emptyToNull(reader.getString());
} else if ("package-version".equals(fieldName)) {
options.packageVersion = emptyToNull(reader.getString());
} else if ("dev-options".equals(fieldName)) {
options.devOptions = DevOptions.fromJson(reader);
} else {
Expand Down

0 comments on commit 8ee7ec2

Please sign in to comment.