Are dynamic types possible? #169
-
Hello, I would like to parse some remote data (per user request) and add data models/interactors dynamically - is that possible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Please check a newly added example https://github.com/swaggest/rest/blob/v0.2.58/_examples/advanced/dynamic_schema.go. |
Beta Was this translation helpful? Give feedback.
-
@vearutop One more question on this subject: I wanted to set the definition name in the schema, e.g., dynOut := dynamicOutput{}
dynOut.Struct.DefName = "Test123"
dynOut.Struct.Fields = []jsonschema.Field{
{Name: "Foo", Value: 123, Tag: `header:"foo" enum:"123,456,789"`},
{Name: "Bar", Value: "abc", Tag: `json:"bar"`},
{Name: "_", Value: new(struct{}), Tag: `query:"_" additionalProperties:"false" description:"aaMyObj is my object." title: "BLAH"`},
} But the output always appears to use the structure name rather than "Test123", here's the output: "DynamicOutput": {
"type": "object",
"properties": {
"bar": {
"type": "string"
},
"status": {
"type": "string"
}
},
"additionalProperties": false,
"description": "aaMyObj is my object."
}, Do you know how i might change the definition name? The use case is that I would like to reuse that dynamic structure to generate many different definitions |
Beta Was this translation helpful? Give feedback.
Please check a newly added example https://github.com/swaggest/rest/blob/v0.2.58/_examples/advanced/dynamic_schema.go.