@api-client/core 0.20.6 → 0.20.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/modeling/ExposedEntity.d.ts.map +1 -1
- package/build/src/modeling/ExposedEntity.js +55 -4
- package/build/src/modeling/ExposedEntity.js.map +1 -1
- package/build/src/modeling/RuntimeApiModel.d.ts.map +1 -1
- package/build/src/modeling/RuntimeApiModel.js +6 -2
- package/build/src/modeling/RuntimeApiModel.js.map +1 -1
- package/build/src/modeling/generators/RuntimeModelGenerator.d.ts +15 -0
- package/build/src/modeling/generators/RuntimeModelGenerator.d.ts.map +1 -0
- package/build/src/modeling/generators/RuntimeModelGenerator.js +78 -0
- package/build/src/modeling/generators/RuntimeModelGenerator.js.map +1 -0
- package/build/src/modeling/helpers/endpointHelpers.d.ts +6 -1
- package/build/src/modeling/helpers/endpointHelpers.d.ts.map +1 -1
- package/build/src/modeling/helpers/endpointHelpers.js +43 -4
- package/build/src/modeling/helpers/endpointHelpers.js.map +1 -1
- package/build/src/modeling/validation/api_model_rules.d.ts.map +1 -1
- package/build/src/modeling/validation/api_model_rules.js +17 -0
- package/build/src/modeling/validation/api_model_rules.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/modeling/ExposedEntity.ts +62 -4
- package/src/modeling/RuntimeApiModel.ts +7 -2
- package/src/modeling/generators/RuntimeModelGenerator.ts +79 -0
- package/src/modeling/helpers/endpointHelpers.ts +51 -4
- package/src/modeling/validation/api_model_rules.ts +19 -0
- package/tests/unit/modeling/RuntimeApiModel.spec.ts +17 -3
- package/tests/unit/modeling/exposed_entity.spec.ts +95 -0
- package/tests/unit/modeling/generators/RuntimeModelGenerator.spec.ts +192 -0
- package/tests/unit/modeling/helpers/endpointHelpers.spec.ts +10 -3
- package/tests/unit/modeling/validation/api_model_rules.spec.ts +35 -0
|
@@ -249,6 +249,41 @@ test.group('ApiModel Validation', () => {
|
|
|
249
249
|
assert.isTrue(issues.some((i) => i.code === 'EXPOSURE_INVALID_RESOURCE_PATH_FORMAT'))
|
|
250
250
|
})
|
|
251
251
|
|
|
252
|
+
test('validateExposedEntity - catches duplicate path parameters in branch', ({ assert }) => {
|
|
253
|
+
const domain = new DataDomain({ info: { version: '1.0.0' } })
|
|
254
|
+
const model = new ApiModel({}, domain)
|
|
255
|
+
|
|
256
|
+
// Parent exposure with parameter {id}
|
|
257
|
+
const parentExposure = new ExposedEntity(model, {
|
|
258
|
+
key: 'parent',
|
|
259
|
+
entity: { key: 'fakeParent' },
|
|
260
|
+
hasCollection: true,
|
|
261
|
+
collectionPath: '/parents',
|
|
262
|
+
resourcePath: '/parents/{id}',
|
|
263
|
+
isRoot: true,
|
|
264
|
+
actions: [],
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
// Child exposure with the same parameter {id}
|
|
268
|
+
const childExposure = new ExposedEntity(model, {
|
|
269
|
+
key: 'child',
|
|
270
|
+
entity: { key: 'fakeChild' },
|
|
271
|
+
hasCollection: true,
|
|
272
|
+
collectionPath: '/children',
|
|
273
|
+
resourcePath: '/children/{id}',
|
|
274
|
+
parent: { key: 'parent', association: { key: 'toChildren' } },
|
|
275
|
+
actions: [],
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
model.exposes = new Map([
|
|
279
|
+
[parentExposure.key, parentExposure],
|
|
280
|
+
[childExposure.key, childExposure],
|
|
281
|
+
])
|
|
282
|
+
|
|
283
|
+
const issues = validateExposedEntity(childExposure, model)
|
|
284
|
+
assert.isTrue(issues.some((i) => i.code === 'EXPOSURE_DUPLICATE_PATH_PARAMETER'))
|
|
285
|
+
})
|
|
286
|
+
|
|
252
287
|
test('validateExposedEntity - List needs pagination contract', ({ assert }) => {
|
|
253
288
|
const domain = new DataDomain({ info: { version: '1.0.0' } })
|
|
254
289
|
const model = new ApiModel({}, domain)
|