1 // Copyright 2015 go-swagger maintainers
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
17 import "encoding/json"
19 //go:generate curl -L --progress -o ./schemas/v2/schema.json http://swagger.io/v2/schema.json
20 //go:generate curl -L --progress -o ./schemas/jsonschema-draft-04.json http://json-schema.org/draft-04/schema
21 //go:generate go-bindata -pkg=spec -prefix=./schemas -ignore=.*\.md ./schemas/...
22 //go:generate perl -pi -e s,Json,JSON,g bindata.go
25 // SwaggerSchemaURL the url for the swagger 2.0 schema to validate specs
26 SwaggerSchemaURL = "http://swagger.io/v2/schema.json#"
27 // JSONSchemaURL the url for the json schema schema
28 JSONSchemaURL = "http://json-schema.org/draft-04/schema#"
37 jsonSchema = MustLoadJSONSchemaDraft04()
38 swaggerSchema = MustLoadSwagger20Schema()
41 // MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error
42 func MustLoadJSONSchemaDraft04() *Schema {
43 d, e := JSONSchemaDraft04()
50 // JSONSchemaDraft04 loads the json schema document for json shema draft04
51 func JSONSchemaDraft04() (*Schema, error) {
52 b, err := Asset("jsonschema-draft-04.json")
58 if err := json.Unmarshal(b, schema); err != nil {
64 // MustLoadSwagger20Schema panics when Swagger20Schema returns an error
65 func MustLoadSwagger20Schema() *Schema {
66 d, e := Swagger20Schema()
73 // Swagger20Schema loads the swagger 2.0 schema from the embedded assets
74 func Swagger20Schema() (*Schema, error) {
76 b, err := Asset("v2/schema.json")
82 if err := json.Unmarshal(b, schema); err != nil {