Skip to content

Commit

Permalink
Start a patched version of 12.0
Browse files Browse the repository at this point in the history
#9
#10

I hope this encourages other people to continue tweaking it.

A basic diff can be found by running

```bash
diff -Naur keycloak/12.0{,-patched}.json
```

producing

```patch
--- keycloak/12.0.json	2021-01-16 13:22:20.000000000 +0000
+++ keycloak/12.0-patched.json	2021-01-16 13:20:20.000000000 +0000
@@ -2542,8 +2542,7 @@
                 "schema": {
                   "type": "array",
                   "items": {
-                    "type": "object",
-                    "additionalProperties": true
+                    "$ref": "#/components/schemas/ClientRepresentation"
                   }
                 }
               }
@@ -7158,8 +7157,7 @@
                 "schema": {
                   "type": "array",
                   "items": {
-                    "type": "object",
-                    "additionalProperties": true
+                    "$ref": "#/components/schemas/IdentityProviderRepresentation"
                   }
                 }
               }
```

Showing that so far I've only patched the return types of
/{realm}/identity-provider/instances and /{realm}/clients.
  • Loading branch information
ccouzens committed Jan 16, 2021
1 parent f6dadc3 commit e0a91f1
Show file tree
Hide file tree
Showing 4 changed files with 13,621 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ all : keycloak/LICENSE.txt $(specs)

.PHONY : clean
clean :
rm keycloak/*
rm $(specs) $(html) keycloak/LICENSE.txt

.PHONY : cleanAll
cleanAll : clean
Expand Down
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@
[OpenAPI definitions](https://github.com/OAI/OpenAPI-Specification) for
[Keycloak](https://www.keycloak.org/)'s Admin API.

These can be used to generate libraries for interacting with Keycloak
from any mainstream programming langauge.
These can be used to generate libraries for interacting with Keycloak from any
mainstream programming langauge.

OpenAPI definitions are sometimes known by their previous name of Swagger
specifications.

[Keycloak 12.0 Admin API](./keycloak/12.0.json)

[Keycloak 12.0 Admin API with patches](./keycloak/12.0-patched.json)

[Other versions](./keycloak/)

[Red Hat Single
Sign-On](https://access.redhat.com/products/red-hat-single-sign-on)
Admin API definitions are not distributed in this repository, but can
be generated.
[Red Hat Single Sign-On](https://access.redhat.com/products/red-hat-single-sign-on)
Admin API definitions are not distributed in this repository, but can be
generated.

```bash
make keycloak/sso-6.json keycloak/sso-7.3.json keycloak/sso-7.4.json
```

## General Usage

Typically to use Keycloak's admin Rest API, you first get a token from
a realm. This is done using the OAuth2 protocol.
Typically to use Keycloak's admin Rest API, you first get a token from a realm.
This is done using the OAuth2 protocol.

```bash
bearer_token=$(curl -X POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' \
Expand All @@ -38,27 +39,28 @@ bearer_token=$(curl -X POST 'http://localhost:8080/auth/realms/master/protocol/o

The realm used for the token is not necessarily the realm used in the API.

The endpoints in this specification can then be used with a base url
of the form `http://localhost:8080/auth/admin/realms` and the above
bearer token.
The endpoints in this specification can then be used with a base url of the form
`http://localhost:8080/auth/admin/realms` and the above bearer token.

Please see the [example app](example_app/src/index.ts).

## Help wanted

The definitions are computer generated, but [could do with a human's input](https://github.com/ccouzens/keycloak-openapi/issues/10).
The definitions are computer generated, but
[could do with a human's input](https://github.com/ccouzens/keycloak-openapi/issues/10).

## Notable Changes

2020 May - Added tags to operations.
Users of OpenAPI Generator generated clients will need to swap from using the `DefaultApi` class to multiple classes such as `UsersApi` or `ClientsApi`.
2020 May - Added tags to operations. Users of OpenAPI Generator generated
clients will need to swap from using the `DefaultApi` class to multiple classes
such as `UsersApi` or `ClientsApi`.

## Example App

[This example](./example_app/) uses
[openapi-generator](https://github.com/OpenAPITools/openapi-generator)
to build an API-client. The app in the example is very simple and only
fetches a list of Keycloak-clients.
[openapi-generator](https://github.com/OpenAPITools/openapi-generator) to build
an API-client. The app in the example is very simple and only fetches a list of
Keycloak-clients.

```bash
# Create a keycloak instance to run against
Expand All @@ -84,22 +86,21 @@ node dist/index.js
In general, clients can be generated by running a command similar to:

```bash
openapi-generator generate -i 'https://github.com/ccouzens/keycloak-openapi/raw/master/keycloak/12.0.json' -g 'typescript-axios' -o 'src/keycloak-client'
openapi-generator generate -i 'https://github.com/ccouzens/keycloak-openapi/raw/master/keycloak/12.0-patched.json' -g 'typescript-axios' -o 'src/keycloak-client'
```

## Keycloak OpenAPI Transformer

All the OpenAPI definitions are generated from the published HTML
documentation. This tool transforms the HTML documentation into OpenAPI
definitions.
All the OpenAPI definitions are generated from the published HTML documentation.
This tool transforms the HTML documentation into OpenAPI definitions.

HTML of the documentation is inputted through `stdin` and the JSON of the
definition is outputted through `stdout`.

## Requirements

Building Red Hat Single Sign-On definitions or rebuilding Keycloak's
definitions requires:
Building Red Hat Single Sign-On definitions or rebuilding Keycloak's definitions
requires:

- `make`
- [`Rust`](https://www.rust-lang.org/tools/install)
Expand All @@ -109,14 +110,13 @@ Building the transformer requires

Building the example app requires `Node` and `Java`.

Running the keycloak instance that pairs with the example app requires
`Docker`.
Running the keycloak instance that pairs with the example app requires `Docker`.

## Licensing

The OpenAPI definitions are [Apache 2.0 licensed](./keycloak/LICENSE.txt).

The transformer is [MIT licensed](keycloak-openapi-transformer/LICENSE).

The example app has a [CC0 waiver](example_app/WAIVER) (has had its
copyright waived).
The example app has a [CC0 waiver](example_app/WAIVER) (has had its copyright
waived).
2 changes: 1 addition & 1 deletion example_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"typescript": "^3.9.6"
},
"scripts": {
"generate-client": "openapi-generator generate -i ../keycloak/12.0.json -g typescript-axios -o src/keycloak-client",
"generate-client": "openapi-generator generate -i ../keycloak/12.0-patched.json -g typescript-axios -o src/keycloak-client",
"prettier": "prettier --write -- '**/*.json' '**/*.ts' '../README.md'",
"compile": "tsc"
},
Expand Down
Loading

0 comments on commit e0a91f1

Please sign in to comment.