Skip to content
Open
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
2 changes: 1 addition & 1 deletion api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SHELL = /bin/bash

# VERSION determines which API version to generate with autorest.
# The default value for VERSION should be the latest API version.
VERSION ?= v20251223preview
VERSION ?= v20260630preview

AUTOREST_OUTPUT_DIR = ../internal/api/${VERSION}/generated

Expand Down
24 changes: 20 additions & 4 deletions api/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ For the reference, the API definition of ARO-RP is here https://github.com/Azure
The tsp generation is setup to generate the right project structure for the azure-rest-api-specs. The
repository structure for typespecs projects is explained here https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/typespec-structure-guidelines.md.

Going with the guide, the typespec service is stored in the `redhatopenshift/HcpCluster` folder. The `redhatopenshift` is the folder
Going with the guide, the typespec service is stored in the `redhatopenshift/HcpCluster.Management` folder. The `redhatopenshift` is the folder
that holds the current Openshift cluster API and both definitions will need to coexist in the same folder. According to the guide,
the generation is placed in created `resource-manager` folder. Finally to allow the proper swagger inspection, the `common-types` are copied from the `azure-rest-api-specs/specification` repository, without these the swagger preview would not work properly.

Expand All @@ -59,11 +59,27 @@ To do so, open terminal, switch to api directory and call the following command

```bash
cd
tsp compile ./api/redhatopenshift/HcpCluster/
tsp compile ./api/redhatopenshift/HcpCluster.Management/
```

Or you can use the submitted build task, that does exactly the same. The default shortcut is `Ctrl+Shift+B` or `Cmd+Shift+B`.

## Adding a new API version

When introducing a new API version, there are several steps beyond defining the version in TypeSpec:

1. **Define the version in `main.tsp`**: Add the new version enum value to the `Versions` enum (e.g., `v2026_06_30_preview: "2026-06-30-preview"`).

2. **Create the examples source directory**: The typespec-autorest emitter requires example JSON files to be present in `redhatopenshift/HcpCluster.Management/examples/<version>/` (e.g., `examples/2026-06-30-preview/`). Without this directory, `tsp compile` will generate an `openapi.json` that is missing `x-ms-examples` references, which will fail API validation in CI.

You can bootstrap the examples for a new version by generating them from the compiled openapi spec (see [Swagger example generation](#swagger-example-generation) below), or by copying and updating examples from the previous version.

3. **Compile and verify**: Run `make swagger` in the `api/` directory and confirm that the generated `openapi.json` under `resource-manager/.../preview/<version>/` contains `x-ms-examples` entries.

4. **Generate the Go models**: Run `make models` to regenerate the autorest models for the new version.

5. **Generate the test SDK**: Run `make testsdk` to generate the test SDK client for the new version.

## Swagger example generation

The devcontainer comes with bundled [Azure/oav](https://github.com/Azure/oav) which lets you both
Expand All @@ -73,8 +89,8 @@ To generate the example requests and responses, you can use the following comman

```bash
export API_VERSION=2024-06-10-preview
cd api/redhatopenshift/HcpCluster/examples/$API_VERSION
oav generate-examples ../../../resource-manager/Microsoft.RedHatOpenShift/preview/$API_VERSION/openapi.json
cd api/redhatopenshift/HcpCluster.Management/examples/$API_VERSION
oav generate-examples ../../../resource-manager/Microsoft.RedHatOpenShift/hcpclusters/preview/$API_VERSION/openapi.json
```

## Generating the api client
Expand Down
8 changes: 8 additions & 0 deletions api/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ go:
remove-unreferenced-types: true
```

### Tag v20260630preview

These settings apply only when `--tag=v20260630preview` is specified on the command line.

``` yaml $(tag) == 'v20260630preview'
input-file: redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/hcpclusters/preview/2026-06-30-preview/openapi.json
```

### Tag v20251223preview

These settings apply only when `--tag=v20251223preview` is specified on the command line.
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"title": "ExternalAuths_Delete",
"operationId": "ExternalAuths_Delete",
"parameters": {
"api-version": "2026-06-30-preview",
"subscriptionId": "B403F39B-26BE-4D37-832E-5D4F88EC6D74",
"resourceGroupName": "rgopenapi",
"hcpOpenShiftClusterName": "Replace this value with a string matching RegExp ^[a-zA-Z][-a-zA-Z0-9]{1,52}[a-zA-Z0-9]$",
"externalAuthName": "Replace this value with a string matching RegExp ^[a-zA-Z][-a-zA-Z0-9]{1,15}$"
},
"responses": {
"202": {
"headers": {
"location": "https://contoso.com/operationstatus"
}
},
"204": {}
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading