-
Notifications
You must be signed in to change notification settings - Fork 39
Does responseConstraint
need a type?
#109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't think this makes sense. In JavaScript, and indeed in most programming languages, objects have types, and we can use this information instead of asking developers to redundantly supply us the types as strings. Various HTTP AI APIs do require the type encoded as a string, because they're using JSON, which does not have a lot of types to go around. But we don't have that constraint. This was discussed in #91 (comment). |
So assuming we had XML Schema support, you'd expect developers to pass in the schema as a parsed (new DOMParser()).parseFromString(`
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="stockItem" type="stockItemType"/>
<xsd:complexType name="stockItemType">
<xsd:sequence>
<xsd:element name="itemName" type="xsd:string" minOccurs="0"/>
<xsd:element name="quantityOnHand">
<xsd:simpleType>
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="itemNumber" type="SKU" use="required"/>
</xsd:complexType>
<xsd:simpleType name="SKU">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-[A-Z]{2}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>`, 'text/xml') If so, this would work. |
Yeah, or maybe a specific type like |
Currently,
responseConstraint
is an object, and we need to figure out dynamically if it's a JSON Schema or a regular expression.Would it make sense to make
responseConstraint
slightly more structured and add atype
, so it'd be easier to determine the concrete kind of constraint we need to deal with, and also allow us to possibly add more kinds later (see #94).The text was updated successfully, but these errors were encountered: