Request Struct looks like below
// RequestStruct is the request schema for Create
// swagger:parameters CreateRequestType
type CreateRequest struct {
// in: path
// required: true
// type: string
// maxLength: 32
// pattern: ^[a-zA-Z0-9_]+$
Consumer string `json:"consumer"`
// The request body
// required: true
// type: object
// in: body
Body *CreateRequestBody `json:"body"`
}
// CreateRequestBody ...
// swagger:model CreateRequestBody
type CreateRequestBody struct {
// type: string
// maxLength: 32
// required: true
// pattern: ^[a-zA-Z0-9_]+$
Name string `json:"name"`
// required: true
// type: object
// schema:
// $ref: '#/definitions/CallbackConfig'
CallbackConfig *spec.CallbackConfig `json:"callbackConfig"`
}
// CallbackConfig callback config
// swagger:model CallbackConfig
type CallbackConfig struct {
// required: true
// type: integer
// format: int32
// Enum: [1]
Type int32 `json:"type" enums:"1"`
// type: object
// required: true
HTTPConfig *HTTPConfig `json:"httpConfig"`
}
// HTTPConfig config
// swagger:model HTTPConfig
type HTTPConfig struct {
// required: true
// format: uri
// type: string
URL string `json:"url"`
// required: false
// type: object
Headers *map[string]string `json:"headers,omitempty"`
// required: false
// type: object
Payload *map[string]interface{} `json:"payload,omitempty"`
}
Swagger is generated using below commands, which is used for validating requests.
go:generate swagger generate spec -m -o swagger.json
go:generate swagger flatten swagger.json --with-flatten=remove-unused -o swagger.json
go:generate swagger validate swagger.json
The generated swagger is validated and correct.
used below code for validating json request
// data is object of CreateRequestBody
err := validate.AgainstSchema(schema, data, strfmt.Default)
It fails while loading the the embedded struct ie CallbackConfig in this case at line https://github.com/go-openapi/spec/blob/de3527276ef8640d6b2a2435cb0ecac3e0002041/schema_loader.go#L153
tagging @swapnilmhamane-Druva @pinkeshbardiya
Request Struct looks like below
Swagger is generated using below commands, which is used for validating requests.
The generated swagger is validated and correct.
used below code for validating json request
It fails while loading the the embedded struct ie
CallbackConfigin this case at line https://github.com/go-openapi/spec/blob/de3527276ef8640d6b2a2435cb0ecac3e0002041/schema_loader.go#L153tagging @swapnilmhamane-Druva @pinkeshbardiya