Adaptivecards: IColumn type inconsistency

Created on 8 Apr 2019  路  12Comments  路  Source: microsoft/AdaptiveCards

Platform

What platform is your issue or question related to? (Delete other platforms).

  • JavaScript

Author or host

author

custom app

Version of SDK

master

Issue

The IColumn interface defined in https://github.com/Microsoft/AdaptiveCards/blob/master/source/nodejs/adaptivecards/src/schema.ts:

export interface IColumn extends IContainer {
width?: number | "auto" | "stretch" | "auto";
}

is of type "Container"

but this link https://adaptivecards.io/explorer/Column.html says that Columns are of type "Column".

Which of the two is correct?

Area-Schema Bug Platform-HTML Triage-Investigate

All 12 comments

That's an implementation detail. A column's a column, whether its type derives from container or not.

The IContainer has type: "Container" and is inherited in IColumn and cannot be changed afterwards.

For example:
const column: IColumn; <- column.type will be Container.

Do you mean that this is expected?

Ah apologies, completely missed what you were saying. The type property isn't necessary for Column, but with what's currently there it does end up being Container, which is wrong. You are correct, a fix is needed here. IColumn should probably extend ICardElement and introduce its own properties.

Can I ask how/why you use those schema interfaces? Ideally I would like to deprecated them and eventually remove them entirely.

I'm using the Interfaces defined in schema.ts for creating adaptive cards which will be consumed by client applications.

I'm using the interfaces to ensure the adaptive card schema is correct while coding. If this schema is removed then each developer will have to type them themselves. Thus I find them useful. Let me know if there are other ways of creating and validating cards in TS.

Re: is there another/better way - it depends. Could you answer a couple additional questions?

  • Are you generating the cards server-side, in an environment that doesn't support the DOM?
  • Are you using the interfaces so you get Intellisense in your IDE?

The main other way to generate cards is to use the Object Model instead of the interfaces, e.g.:

var myCard = new AdaptiveCard();

var myTextBlock = new TextBlock();
myTextBlock.text = "Hello World";

myCard.addItem(myTextBlock);

let json = myCard.toJSON();

Thank you dclaux, Object Model is the way to go for our needs.

@dclaux so I am assuming this is a candidate for a "Resolved"/"Closed" ?

@matthidinger and @dclaux to take it offline.

Fixed.

@dclaux Shouldn't the IColumn have a type field (type: "Column") after the change?

The type property isn't required on Column. It doesn't hurt to add it though, would that make a difference?

No difference to me, just checking. If schema is strict then type have the column value by default since it is the only acceptable value.

Was this page helpful?
0 / 5 - 0 ratings