Add grammar_json to the request parameters to facilitate JSON generation

This commit is contained in:
mudler 2023-07-06 18:05:52 +02:00
parent 483fddccf9
commit 55befe396a
4 changed files with 11 additions and 6 deletions

View file

@ -11,8 +11,8 @@ type Function struct {
}
type Functions []Function
func (f Functions) ToJSONStructure() JSONStructure {
js := JSONStructure{}
func (f Functions) ToJSONStructure() JSONFunctionStructure {
js := JSONFunctionStructure{}
for _, function := range f {
// t := function.Parameters["type"]
//tt := t.(string)

View file

@ -211,12 +211,12 @@ type Item struct {
Properties Properties `json:"properties"`
}
type JSONStructure struct {
type JSONFunctionStructure struct {
OneOf []Item `json:"oneOf,omitempty"`
AnyOf []Item `json:"anyOf,omitempty"`
}
func (j JSONStructure) Grammar(propOrder string) string {
func (j JSONFunctionStructure) Grammar(propOrder string) string {
dat, _ := json.Marshal(j)
return NewJSONSchemaConverter(propOrder).GrammarFromBytes(dat)
}

View file

@ -66,7 +66,7 @@ var _ = Describe("JSON schema grammar tests", func() {
})
It("generates a valid grammar from JSON Objects", func() {
structuredGrammar := JSONStructure{
structuredGrammar := JSONFunctionStructure{
OneOf: []Item{
{
Type: "object",