-
Notifications
You must be signed in to change notification settings - Fork 29
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
Conversation
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
519933e
to
25cadfa
Compare
const ajv = new Ajv({ | ||
strict: false, | ||
allErrors: true, | ||
useDefaults: 'empty', |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
/** 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`); | ||
}); | ||
}); |
There was a problem hiding this comment.
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.
it.skip('should return schema from store', () => { | ||
const entity = new CamelRestConfigurationVisualEntity(restConfigurationDef); | ||
|
||
expect(entity.getComponentSchema().schema).toEqual(restConfigurationSchema); | ||
}); |
There was a problem hiding this comment.
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.
Context
This commit adds support for the
RestConfiguration
entity.How to test
Screenshot
Note:
The node validation is still pending due to an issue with the JSONSchema, please see #969 for more details.
fix: #562
relates: #969