# Component .spec file api parameter type

**URL:** <https://forum.servoy.com/t/component-spec-file-api-parameter-type/21074>\
**Category:** Questions\
**Created:** [September 18, 2023, 1:41pm UTC](https://forum.servoy.com/t/component-spec-file-api-parameter-type/21074 "2023-09-18T13:41:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve1376656734](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/steve1376656734/32/4613_2.png) [@steve1376656734](https://forum.servoy.com/u/steve1376656734)\
**Post date:** [September 18, 2023, 1:41pm UTC](https://forum.servoy.com/t/component-spec-file-api-parameter-type/21074/1 "2023-09-18T13:41:58Z")

</div>

I have an API call in my component that has an argument that can be 1 of two custom types. In my appbar\_server.js file I document this as:

```auto
/**
 * Adds the given item to the Menu
 * 
 * @param {CustomType<mycomponents-appbar.MenuItem>|CustomType<mycomponents-appbar.SubMenuItem>} item
 * @param {String} [menuId] optional - Add the item to the submenu of the given menuId
 * @param {Number} [index] optional - Index where the item will be inserted
 * 
 * @return {Boolean}
 * 
 * @SuppressWarnings(nls)
 */
function addItem(item, menuId, index) {
   .
   .
   .
}

```

I don’t seem to be able to find the correct syntax for specifying this in the .spec file. My “api” section has the method defined as:

```auto
		"addItem": {
			"returns": "boolean",
			"parameters": [
				{
					"name": "item",
					"type": "MenuItem|SubMenuItem"
				},
				{
					"name": "menuId",
					"type":"string",
					"optional":true
				},
				{
					"name": "index",
					"type": "int",
					"optional": true
				}
			]
		},

```

However, this causes an error in the developer console:

```auto
WARN org.sablo.specification.WebObjectSpecification - Unknown type name 'MenuItem|SubMenuItem' encountered while parsing spec mycomponents-appbar

```

How should I specify that the argument can be of type MenuItem **or** SubMenuItem?

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [September 18, 2023, 2:26pm UTC](https://forum.servoy.com/t/component-spec-file-api-parameter-type/21074/2 "2023-09-18T14:26:23Z")

</div>

That is not currently supported in the .spec file.

If it’s just a server-side call, maybe it would be enough to make it an “object”; it’s not the same thing, but it might work for your case.  
Otherwise you can have 2 different methods instead of 1, so 1 for each of the custom types as argument.

---

<div class="post-metadata">

**Author:** ![steve1376656734](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/steve1376656734/32/4613_2.png) [@steve1376656734](https://forum.servoy.com/u/steve1376656734)\
**Post date:** [September 18, 2023, 2:37pm UTC](https://forum.servoy.com/t/component-spec-file-api-parameter-type/21074/3 "2023-09-18T14:37:42Z")

</div>

I will make it two separate methods for now so that I can keep the type checking in Servoy and I will add a feature request to support multiple types.

Thanks  
Steve
