Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(restConfiguration): Add restConfiguration entity #970

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

lordrip
Copy link
Member

@lordrip lordrip commented Mar 21, 2024

Context

This commit adds support for the RestConfiguration entity.

How to test

  1. In the source code, start with the following route:
- restConfiguration: {}
  1. Go to the design page

Screenshot

image

Note:

The node validation is still pending due to an issue with the JSONSchema, please see #969 for more details.

fix: #562
relates: #969

This commit adds support for RestConfiguration entity.

Note:
The node validation is still pending due to an issue with the
JSONSchema, please see KaotoIO#969 for more details.

fix: KaotoIO#562
relates: KaotoIO#969
@lordrip lordrip force-pushed the feat/add-rest-configuration branch from 519933e to 25cadfa Compare March 21, 2024 15:23
const ajv = new Ajv({
strict: false,
allErrors: true,
useDefaults: 'empty',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@igarashitm , I think you already saw this, but in any case, this useDefaults: 'empty' causes us to write all default values in the model, and since we don't want that, I'm validating a copy of the model, so the original don't get updated.

type: 'boolean',
title: 'Use XForward Headers',
description: 'Whether to use X-Forward headers for Host and related setting. The default value is true.',
default: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the right default value

Comment on lines +142 to +185
/** Skip until https://github.com/KaotoIO/kaoto-next/issues/969 gets resolved */
describe.skip('getNodeValidationText', () => {
it('should return undefined for valid definitions', () => {
const entity = new CamelRestConfigurationVisualEntity({
restConfiguration: {
...restConfigurationDef.restConfiguration,
useXForwardHeaders: true,
apiVendorExtension: true,
skipBindingOnErrorCode: true,
clientRequestValidation: true,
enableCORS: true,
enableNoContentResponse: true,
inlineRoutes: true,
},
});

expect(entity.getNodeValidationText()).toBeUndefined();
});

it('should not modify the original definition when validating', () => {
const originalRestConfigurationDef: RestConfiguration = { ...restConfigurationDef.restConfiguration };
const entity = new CamelRestConfigurationVisualEntity(restConfigurationDef);

entity.getNodeValidationText();

expect(restConfigurationDef.restConfiguration).toEqual(originalRestConfigurationDef);
});

it('should return errors when there is an invalid property', () => {
const invalidRestConfigurationDef: RestConfiguration = {
...restConfigurationDef.restConfiguration,
bindingMode: 'WildModeOn' as RestConfiguration['bindingMode'],
};
const entity = new CamelRestConfigurationVisualEntity({ restConfiguration: invalidRestConfigurationDef });

expect(entity.getNodeValidationText()).toEqual(`'/useXForwardHeaders' must be boolean,
'/apiVendorExtension' must be boolean,
'/skipBindingOnErrorCode' must be boolean,
'/clientRequestValidation' must be boolean,
'/enableCORS' must be boolean,
'/enableNoContentResponse' must be boolean,
'/inlineRoutes' must be boolean`);
});
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to reenable this test, once #969 is fixed.

Comment on lines +87 to +91
it.skip('should return schema from store', () => {
const entity = new CamelRestConfigurationVisualEntity(restConfigurationDef);

expect(entity.getComponentSchema().schema).toEqual(restConfigurationSchema);
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to reenable this test, once #969 is fixed.

@lordrip lordrip merged commit b90d7e7 into KaotoIO:main Mar 21, 2024
9 checks passed
@lordrip lordrip deleted the feat/add-rest-configuration branch March 21, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support restConfiguration
2 participants