Skip to content

Commit

Permalink
Rename required behavior_meta keys
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed Jun 28, 2024
1 parent a5aeb5c commit 6c10c4b
Show file tree
Hide file tree
Showing 19 changed files with 374 additions and 278 deletions.
8 changes: 4 additions & 4 deletions compiler/src/steps/validate-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,11 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
for (const parent of typeDef.behaviors) {
validateTypeRef(parent.type, parent.generics, openGenerics)

if (parent.type.name === 'AdditionalProperty' && (parent.meta == null || parent.meta.name == null || parent.meta.value == null)) {
modelError(`AdditionalProperty behavior for type '${fqn(typeDef.name)}' requires a 'behavior_meta' decorator with at least 2 arguments (name of name, name of value, description)`)
if (parent.type.name === 'AdditionalProperty' && (parent.meta == null || parent.meta.key == null || parent.meta.value == null)) {
modelError(`AdditionalProperty behavior for type '${fqn(typeDef.name)}' requires a 'behavior_meta' decorator with at least 2 arguments (key, value)`)
}
if (parent.type.name === 'AdditionalProperties' && (parent.meta == null || parent.meta.name == null || parent.meta.description == null)) {
modelError(`AdditionalProperties behavior for type '${fqn(typeDef.name)}' requires a 'behavior_meta' decorator with exactly 2 arguments (name, description)`)
if (parent.type.name === 'AdditionalProperties' && (parent.meta == null || parent.meta.fieldname == null || parent.meta.description == null)) {
modelError(`AdditionalProperties behavior for type '${fqn(typeDef.name)}' requires a 'behavior_meta' decorator with exactly 2 arguments (fieldname, description)`)
}
}
context.pop()
Expand Down
4 changes: 2 additions & 2 deletions docs/behaviors.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ We therefore document the requirement to behave like a dictionary for unknown pr

```ts
/**
* @behavior_meta AdditionalProperties name=sub_aggregations
* @behavior_meta AdditionalProperties fieldname=sub_aggregations
*/
class IpRangeBucket implements AdditionalProperties<AggregateName, Aggregate> {}
```
Expand All @@ -25,7 +25,7 @@ There are also many places where we expect only one runtime-defined property, su

```ts
/**
* @behavior_meta AdditionalProperty name=field value=bounding_box
* @behavior_meta AdditionalProperty key=field value=bounding_box
*/
class GeoBoundingBoxQuery extends QueryBase
implements AdditionalProperty<Field, BoundingBox>
Expand Down
Loading

0 comments on commit 6c10c4b

Please sign in to comment.