@azure-tools/cadl-java v0.4.2
Prerequisite
Install Node.js 16 or above. (Verify by node --version
)
Install Java 11 or above. (Verify by java --version
)
Install Cadl 0.40.
Initialize Cadl Project
Follow Cadl Getting Started to initialize your Cadl project.
Make sure npx cadl compile .
runs correctly.
Add Cadl-Java
Make sure the version of Cadl-java release depends on same version of "@cadl-lang/compiler" as in your Cadl project.
Modify package.json
, add one line under dependencies
:
"dependencies": {
"@cadl-lang/compiler": "latest",
"@cadl-lang/rest": "latest",
"@azure-tools/cadl-azure-core": "latest",
+ "@azure-tools/cadl-java": "latest"
},
Run npm install
again to install @azure-tools/cadl-java
.
Modify (or create) cadl-project.yaml
, specify emit as @azure-tools/cadl-java
:
emit:
- "@azure-tools/cadl-java"
Generate Java
npx cadl compile client.cadl --emit=@azure-tools/cadl-java
or npx cadl compile client.cadl --emit=@azure-tools/cadl-java --options='@azure-tools/cadl-java.emitter-output-dir=<target=folder>
.
If emitter-output-dir
option is not provided, generated Java code will be under cadl-output/@azure-tools
folder.
Optional Configuration
SDK
One can further configure the SDK generated, using the emitter options on @azure-tools/cadl-java
.
emit:
- "@azure-tools/cadl-java"
options:
"@azure-tools/cadl-java":
emitter-output-dir: "{project-root}/azure-ai-language-authoring"
namespace: "com.azure.ai.language.authoring"
service-name: "Authoring"
partial-update: false
service-versions:
- "2022-05-15-preview"
namer: false
generate-samples: true
generate-tests: true
Convenience API
By default, Cadl-Java generates all protocol APIs and convenience APIs. A few exceptions are API of JSON Merge Patch, and API of long-running operation with ambiguous response type.
See "convenientAPI" decorator from cadl-dpg.
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago