APISchema produces the API JSON hyper schema.
(api *expr.APIExpr, r *expr.RootExpr)
| 132 | |
| 133 | // APISchema produces the API JSON hyper schema. |
| 134 | func APISchema(api *expr.APIExpr, r *expr.RootExpr) *Schema { |
| 135 | for _, res := range r.API.HTTP.Services { |
| 136 | GenerateServiceDefinition(api, res) |
| 137 | } |
| 138 | href := string(api.Servers[0].Hosts[0].URIs[0]) |
| 139 | links := []*Link{ |
| 140 | { |
| 141 | Href: href, |
| 142 | Rel: "self", |
| 143 | }, |
| 144 | { |
| 145 | Href: "/schema", |
| 146 | Method: "GET", |
| 147 | Rel: "self", |
| 148 | TargetSchema: &Schema{ |
| 149 | Schema: SchemaRef, |
| 150 | AdditionalProperties: true, |
| 151 | }, |
| 152 | }, |
| 153 | } |
| 154 | s := Schema{ |
| 155 | ID: fmt.Sprintf("%s/schema", href), |
| 156 | Title: api.Title, |
| 157 | Description: api.Description, |
| 158 | Type: Object, |
| 159 | Defs: Definitions, |
| 160 | Properties: propertiesFromDefs(Definitions, "#/$defs/"), |
| 161 | Links: links, |
| 162 | } |
| 163 | return &s |
| 164 | } |
| 165 | |
| 166 | // GenerateServiceDefinition produces the JSON schema corresponding to the given |
| 167 | // service. It stores the results in Definitions. |
nothing calls this directly
no test coverage detected