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

http-client-java, add package-version option #5387

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 @@ -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
Loading