This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new 984e2d62 Fix #1306
984e2d62 is described below
commit 984e2d628de58564ff9052d141ed3d08253f48ba
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Fri May 31 09:55:23 2024 -0400
Fix #1306
---
karavan-core/src/core/api/CamelDefinitionYaml.ts | 1 +
karavan-core/test/openapi.spec.ts | 48 ++++++++++++++++++++++++
karavan-core/test/openapi.yaml | 7 ++++
karavan-core/test/restDsl.spec.ts | 1 -
4 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/karavan-core/src/core/api/CamelDefinitionYaml.ts
b/karavan-core/src/core/api/CamelDefinitionYaml.ts
index 7cec075d..309d7694 100644
--- a/karavan-core/src/core/api/CamelDefinitionYaml.ts
+++ b/karavan-core/src/core/api/CamelDefinitionYaml.ts
@@ -210,6 +210,7 @@ export class CamelDefinitionYaml {
stepName === 'mutualTls' ||
stepName === 'oauth2' ||
stepName === 'openIdConnect' ||
+ stepName === 'openApi' ||
key === 'from'
) {
delete newValue.inArray;
diff --git a/karavan-core/test/openapi.spec.ts
b/karavan-core/test/openapi.spec.ts
new file mode 100644
index 00000000..f7b7052f
--- /dev/null
+++ b/karavan-core/test/openapi.spec.ts
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+import {expect} from 'chai';
+import 'mocha';
+import {
+ FromDefinition,
+ LogDefinition,
+ WhenDefinition,
+ ChoiceDefinition,
+ MulticastDefinition,
+ ExpressionDefinition,
+ RouteDefinition, TryDefinition, CatchDefinition, RestDefinition,
GetDefinition, OpenApiDefinition,
+} from '../src/core/model/CamelDefinition';
+import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
+import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
+import {SimpleExpression} from "../src/core/model/CamelDefinition";
+import {Integration} from "../src/core/model/IntegrationDefinition";
+import * as fs from 'fs';
+
+describe('OpenAPI', () => {
+
+ it('Simple config', () => {
+ let i = Integration.createNew("test")
+
+ const openApi = new OpenApiDefinition({specification: "openapi.json",
id: 'openapi-1'});
+ const rest = new RestDefinition({id: 'rest-1', path: "/demo",
description: "Hello World", openApi: openApi});
+ i = CamelDefinitionApiExt.addRestToIntegration(i, rest);
+
+ const yaml1 = CamelDefinitionYaml.integrationToYaml(i);
+ const yaml2 = fs.readFileSync('test/openapi.yaml', {encoding: 'utf8',
flag: 'r'});
+
+ expect(yaml1).to.equal(yaml2);
+ });
+});
diff --git a/karavan-core/test/openapi.yaml b/karavan-core/test/openapi.yaml
new file mode 100644
index 00000000..03a44c23
--- /dev/null
+++ b/karavan-core/test/openapi.yaml
@@ -0,0 +1,7 @@
+- rest:
+ id: rest-1
+ description: Hello World
+ path: /demo
+ openApi:
+ id: openapi-1
+ specification: openapi.json
diff --git a/karavan-core/test/restDsl.spec.ts
b/karavan-core/test/restDsl.spec.ts
index 403f71b1..166ef49e 100644
--- a/karavan-core/test/restDsl.spec.ts
+++ b/karavan-core/test/restDsl.spec.ts
@@ -23,7 +23,6 @@ import {GetDefinition, PostDefinition, RestDefinition,
RouteDefinition} from "..
import {FromDefinition} from "../src/core/model/CamelDefinition";
import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
import {RestConfigurationDefinition} from "../src/core/model/CamelDefinition";
-import {SagaDefinition, ToDefinition} from "../lib/model/CamelDefinition";
describe('REST DSL', () => {