Share
Explore

ChatGPT Prompt

coda.makeObjectSchema
Write a codeblock I can copy to my clipboard for a const based a given sample API response strictly meeting all of the following expectations:
Use the makeSchemaObject method in the Coda Pack SDK and strictly adhere to the Coda Pack SDK documentation and best practices here: https://coda.io/packs/build/latest/.
Define the data type that will be returned by setting the coda.ValueType that corresponds to the JavaScript type that will be returned.
Set a coda.ValueHintType which value indicates how Coda should interpret that value when the sample data matches one of the following: Attachment, Currency, Date, DateTime, Duration, Email, Embed, Html, ImageAttachment, ImageReference, Markdown, Percent, Person, ProgressBar, Reference, Scale, Slider, Time, Toggle, Url.
The individual properties of the object are defined using the properties field of the schema. It contains a set of key value/pairs, where the key is the name of the property and the value is a schema describing the property.
When a property’s sample value is an Object or Objects, add a reference to Schema Object named property’s name suffixed with “Schema” using UpperCamelCase formatting. Do not create the additional schema.
The best approach when referencing a nested schema, use the spread operator (...) to copy the schema and then add on the fromKey field.
Rename each property from the properties using the UpperCamelCased fromKey .
The default type value for a property is coda.ValueType.String. For properties where the example value is null use coda.ValueType.String as the type .
Do not include comments or line breaks in the code block formatting.
Only create the single const when creating the code block.

Example Code:
```
const ExampleSchema = coda.makeObjectSchema({
properties: {
"PropertyOne": {
type: coda.ValueType.String,
codaType: coda.ValueHintType.Date,
fromKey: "property_one"
},
"PropertyTwo": {
...PropertyTwoSchema,
fromKey: "property_two"
},
"PropertyThree": {
type: coda.ValueType.Array,
items: PropertyThreeSchema,
from: "property_three"
},
},
displayProperty: "",
idProperty: "",
featuredProperties: ["", ""],
attribution: Attribution
});
```
Sample Response:
```
item: {
chat_gpt: “https://chat.openai.com/”,
is_full: 32,
of_useful: “String”,
surprises: [Object]
}
```
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.