Skip to content

Commit

Permalink
(apache#56) Update generic openapi, rest
Browse files Browse the repository at this point in the history
  • Loading branch information
tdiesler committed May 22, 2024
1 parent 35bd429 commit d288129
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 199 deletions.
20 changes: 16 additions & 4 deletions generic-examples/openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,29 @@ Deploy the examples running

```
kubectl create configmap my-openapi --from-file=greetings-api.json
kamel run --dev --name greetings --open-api configmap:my-openapi greetings.groovy
kamel run --dev --name greetings --open-api configmap:my-openapi greetings.yaml
```

Then you can test by calling the hello endpoint, ie:
If on minikube, you can get the service endpoint address like this ...

```
$ curl -i http://192.168.49.2:31373/camel/greetings/hello
$ minikube service greetings
Starting tunnel for service greetings.
|-----------|-----------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|-----------|-------------|------------------------|
| default | greetings | | http://127.0.0.1:58512 |
|-----------|-----------|-------------|------------------------|
```

You can then test that endpoint like this ...

```
$ curl -i http://127.0.0.1:58512/camel/greetings/hello
HTTP/1.1 200 OK
Accept: */*
name: hello
User-Agent: curl/7.68.0
User-Agent: curl/8.6.0
transfer-encoding: chunked
Hello from hello
Expand Down
27 changes: 0 additions & 27 deletions generic-examples/openapi/greetings.groovy

This file was deleted.

25 changes: 25 additions & 0 deletions generic-examples/openapi/greetings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# camel-k: language=yaml

# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------

- from:
uri: "direct:greeting-api"
steps:
- to: "log:api?showAll=true&multiline=true"
- setBody:
simple: "Hello from ${headers.name}"
128 changes: 0 additions & 128 deletions generic-examples/openapi/petstore-api.yaml

This file was deleted.

31 changes: 0 additions & 31 deletions generic-examples/openapi/petstore.groovy

This file was deleted.

35 changes: 34 additions & 1 deletion generic-examples/rest/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# Rest Camel K examples

Find useful examples about how to Produce/Consume RESTful webservices in a Camel K integration.
Find useful examples about how to Produce/Consume RESTful webservices in a Camel K integration.

## REST endpoint with Java DSL

```
kamel run --dev RestDSL.java
kamel run --dev rest-dsl.js
```

If on minikube, you can get the service endpoint address like this ...

```
$ minikube service rest-dsl
Starting tunnel for service rest-dsl.
|-----------|-----------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|-----------|-------------|------------------------|
| default | rest-dsl | | http://127.0.0.1:58632 |
|-----------|-----------|-------------|------------------------|
```

You can then test that endpoint like this ...

```
$ curl -i http://127.0.0.1:58632/hello
HTTP/1.1 200 OK
Accept: */*
User-Agent: curl/8.6.0
transfer-encoding: chunked
Content-Type: text/plain
Hello World
```
5 changes: 0 additions & 5 deletions generic-examples/rest/RestDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
* limitations under the License.
*/

//
// To run this integrations use:
//
// kamel run examples/RestDSL.java
//
import org.apache.camel.Exchange;

public class RestDSL extends org.apache.camel.builder.RouteBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
// kamel run --name=withrest examples/routes-rest.js
//

rest('/say/hello')
rest('/hello')
.produces("text/plain")
.get()
.to('direct:sayHello');
.to('direct:hello');

from('direct:sayHello')
from('direct:hello')
.transform().constant("Hello World");

0 comments on commit d288129

Please sign in to comment.