Skip to content

Commit

Permalink
Prepare autorest 4.1.43/typespec 0.26.1 (#2994)
Browse files Browse the repository at this point in the history
* bump core

* sync tests

* bump autorest.java

* bump typespec-java

* bump tcgc/cadl-ranch-specs

* fix typespec-test dependency

* regen typespec

* regen swagger

* modify Generate.ps1

* revert cadl-ranch

* Revert "regen swagger"

This reverts commit d6af8b0.

* revert customization test

* fix inconsistency in setup script

* fix Generate.ps1

* bump core

* update release date

* regen
  • Loading branch information
XiaofeiCao authored Dec 10, 2024
1 parent ef83b1b commit 132e859
Show file tree
Hide file tree
Showing 28 changed files with 450 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate-test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Build autorest-java, install modules
run: |
mvn install -f pom.xml -P local,tsp --no-transfer-progress
mvn clean install -f pom.xml -P local,tsp --no-transfer-progress
- name: Generate test code for autorest-java
if: ${{ inputs.scope == 'all' || inputs.scope == 'autorest' }}
Expand Down
2 changes: 1 addition & 1 deletion core
Submodule core updated 338 files
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@autorest/java",
"version": "4.1.42",
"version": "4.1.43",
"description": "The Java extension for classic generators in AutoRest.",
"scripts": {
"autorest": "autorest",
Expand Down
7 changes: 7 additions & 0 deletions typespec-extension/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release History

## 0.26.1 (2024-12-10)

Compatible with compiler 0.62.

- Fixed `equals()` for `ExpandableEnum` implementations.
- Removed unnecessary parent read-only property shadowing for stream-style-serialization, when all polymorphic models are in the same package.

## 0.26.0 (2024-11-22)

Compatible with compiler 0.62.
Expand Down
15 changes: 8 additions & 7 deletions typespec-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions typespec-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/typespec-java",
"version": "0.26.0",
"version": "0.26.1",
"description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding",
"keywords": [
"TypeSpec"
Expand Down Expand Up @@ -49,7 +49,7 @@
"@azure-tools/typespec-azure-resource-manager": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.48.2 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.48.5 <1.0.0",
"@typespec/compiler": ">=0.62.0 <1.0.0",
"@typespec/http": ">=0.62.0 <1.0.0",
"@typespec/openapi": ">=0.62.0 <1.0.0",
Expand All @@ -67,7 +67,7 @@
"@azure-tools/typespec-azure-resource-manager": "0.48.0",
"@azure-tools/typespec-autorest": "0.48.0",
"@azure-tools/typespec-azure-rulesets": "0.48.0",
"@azure-tools/typespec-client-generator-core": "0.48.2",
"@azure-tools/typespec-client-generator-core": "0.48.5",
"@types/js-yaml": "~4.0.9",
"@types/lodash": "~4.17.13",
"@types/mocha": "~10.0.9",
Expand Down
2 changes: 2 additions & 0 deletions typespec-tests/Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ $generateScript = {
$tspOptions += " --option ""@azure-tools/typespec-java.generate-tests=false"""
# also generate with group-etag-headers=false since mgmt doesn't support etag grouping yet
$tspOptions += " --option ""@azure-tools/typespec-java.group-etag-headers=false"""
} elseif ($tspFile -match "subclient.tsp") {
$tspOptions += " --option ""@azure-tools/typespec-java.enable-subclient=true"""
}

# Test customization for one of the TypeSpec definitions - naming.tsp
Expand Down
18 changes: 4 additions & 14 deletions typespec-tests/Setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,13 @@ param (

Set-Location $PSScriptRoot

if ($RebuildJar) {
Set-Location ../
Push-Location ../
try {
./Build-TypeSpec.ps1
} else {
Set-Location ../typespec-extension/
# re-build typespec-java
npm ci
npm run build
npm run lint
npm pack
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
} finally {
Pop-Location
}

# re-install
Set-Location ../typespec-tests/
if (Test-Path node_modules) {
Remove-Item node_modules -Recurse -Force
}
Expand Down
2 changes: 1 addition & 1 deletion typespec-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@azure-tools/cadl-ranch-specs": "0.39.4",
"@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.26.0.tgz"
"@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.26.1.tgz"
},
"devDependencies": {
"@typespec/prettier-plugin-typespec": "~0.62.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;

/**
* Defines values for PriorityModel.
*/
public final class PriorityModel implements ExpandableEnum<Integer> {
private static final Map<Integer, PriorityModel> VALUES = new ConcurrentHashMap<>();

private static final Function<Integer, PriorityModel> NEW_INSTANCE = PriorityModel::new;

/**
* Static value 0 for PriorityModel.
*/
Expand All @@ -43,11 +46,7 @@ private PriorityModel(Integer value) {
@JsonCreator
public static PriorityModel fromValue(Integer value) {
Objects.requireNonNull(value, "'value' cannot be null.");
PriorityModel member = VALUES.get(value);
if (member != null) {
return member;
}
return VALUES.computeIfAbsent(value, key -> new PriorityModel(key));
return VALUES.computeIfAbsent(value, NEW_INSTANCE);
}

/**
Expand Down Expand Up @@ -76,7 +75,7 @@ public String toString() {

@Override
public boolean equals(Object obj) {
return Objects.equals(this.value, obj);
return this == obj;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import tsptest.armstreamstyleserialization.models.Dog;
import tsptest.armstreamstyleserialization.models.OutputOnlyModelChild;

/**
Expand Down Expand Up @@ -122,6 +123,15 @@ public String title() {
return this.innerProperties() == null ? null : this.innerProperties().title();
}

/**
* Get the dog property: The dog property.
*
* @return the dog value.
*/
public Dog dog() {
return this.innerProperties() == null ? null : this.innerProperties().dog();
}

/**
* Validates the instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import tsptest.armstreamstyleserialization.models.Dog;

/**
* The OutputOnlyModelProperties model.
Expand All @@ -22,6 +23,11 @@ public final class OutputOnlyModelProperties implements JsonSerializable<OutputO
*/
private String title;

/*
* The dog property.
*/
private Dog dog;

/**
* Creates an instance of OutputOnlyModelProperties class.
*/
Expand All @@ -37,6 +43,15 @@ public String title() {
return this.title;
}

/**
* Get the dog property: The dog property.
*
* @return the dog value.
*/
public Dog dog() {
return this.dog;
}

/**
* Validates the instance.
*
Expand All @@ -48,6 +63,12 @@ public void validate() {
.log(
new IllegalArgumentException("Missing required property title in model OutputOnlyModelProperties"));
}
if (dog() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property dog in model OutputOnlyModelProperties"));
} else {
dog().validate();
}
}

private static final ClientLogger LOGGER = new ClientLogger(OutputOnlyModelProperties.class);
Expand All @@ -59,6 +80,7 @@ public void validate() {
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("title", this.title);
jsonWriter.writeJsonField("dog", this.dog);
return jsonWriter.writeEndObject();
}

Expand All @@ -80,6 +102,8 @@ public static OutputOnlyModelProperties fromJson(JsonReader jsonReader) throws I

if ("title".equals(fieldName)) {
deserializedOutputOnlyModelProperties.title = reader.getString();
} else if ("dog".equals(fieldName)) {
deserializedOutputOnlyModelProperties.dog = Dog.fromJson(reader);
} else {
reader.skipChildren();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package tsptest.armstreamstyleserialization.implementation;

import tsptest.armstreamstyleserialization.fluent.models.OutputOnlyModelInner;
import tsptest.armstreamstyleserialization.models.Dog;
import tsptest.armstreamstyleserialization.models.OutputOnlyModel;

public final class OutputOnlyModelImpl implements OutputOnlyModel {
Expand Down Expand Up @@ -34,6 +35,10 @@ public String title() {
return this.innerModel().title();
}

public Dog dog() {
return this.innerModel().dog();
}

public OutputOnlyModelInner innerModel() {
return this.innerObject;
}
Expand Down
Loading

0 comments on commit 132e859

Please sign in to comment.