Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/qjj upgrade v2 #373

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.sw[nop]
*.iml
.vscode/
.idea/
4 changes: 2 additions & 2 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package: github.com/xeipuuv/gojsonschema
package: github.com/qjjayy/gojsonschema
license: Apache 2.0
import:
- package: github.com/xeipuuv/gojsonschema
- package: github.com/qjjayy/gojsonschema

- package: github.com/xeipuuv/gojsonpointer

Expand Down
11 changes: 9 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
module github.com/xeipuuv/gojsonschema
module github.com/qjjayy/gojsonschema

go 1.18

require (
github.com/stretchr/testify v1.3.0
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
)
146 changes: 73 additions & 73 deletions schema.go

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions schemaLoader.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ func (sl *SchemaLoader) Compile(rootSchema JSONLoader) (*Schema, error) {
}

d := Schema{}
d.pool = sl.pool
d.pool.jsonLoaderFactory = rootSchema.LoaderFactory()
d.documentReference = ref
d.referencePool = newSchemaReferencePool()
d.Pool = sl.pool
d.Pool.jsonLoaderFactory = rootSchema.LoaderFactory()
d.DocumentReference = ref
d.ReferencePool = newSchemaReferencePool()

var doc interface{}
if ref.String() != "" {
// Get document from schema pool
spd, err := d.pool.GetDocument(d.documentReference)
spd, err := d.Pool.GetDocument(d.DocumentReference)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions schemaReferencePool.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ import (
)

type schemaReferencePool struct {
documents map[string]*subSchema
documents map[string]*SubSchema
}

func newSchemaReferencePool() *schemaReferencePool {

p := &schemaReferencePool{}
p.documents = make(map[string]*subSchema)
p.documents = make(map[string]*SubSchema)

return p
}

func (p *schemaReferencePool) Get(ref string) (r *subSchema, o bool) {
func (p *schemaReferencePool) Get(ref string) (r *SubSchema, o bool) {

if internalLogEnabled {
internalLog(fmt.Sprintf("Schema Reference ( %s )", ref))
Expand All @@ -57,7 +57,7 @@ func (p *schemaReferencePool) Get(ref string) (r *subSchema, o bool) {
return nil, false
}

func (p *schemaReferencePool) Add(ref string, sch *subSchema) {
func (p *schemaReferencePool) Add(ref string, sch *SubSchema) {

if internalLogEnabled {
internalLog(fmt.Sprintf("Add Schema Reference %s to pool", ref))
Expand Down
63 changes: 32 additions & 31 deletions subSchema.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
// repository-name gojsonschema
// repository-desc An implementation of JSON Schema, based on IETF's draft v4 - Go language.
//
// description Defines the structure of a sub-subSchema.
// A sub-subSchema can contain other sub-schemas.
// description Defines the structure of a sub-SubSchema.
// A sub-SubSchema can contain other sub-schemas.
//
// created 27-02-2013

package gojsonschema

import (
"github.com/xeipuuv/gojsonreference"
"math/big"
"regexp"

"github.com/xeipuuv/gojsonreference"
)

// Constants
Expand Down Expand Up @@ -76,32 +77,32 @@ const (
KEY_ELSE = "else"
)

type subSchema struct {
type SubSchema struct {
draft *Draft

// basic subSchema meta properties
id *gojsonreference.JsonReference
title *string
description *string
// basic SubSchema meta properties
Id *gojsonreference.JsonReference
Title *string
Description *string

property string
Property string

// Quick pass/fail for boolean schemas
pass *bool

// Types associated with the subSchema
types jsonSchemaType
// Types associated with the SubSchema
Types jsonSchemaType

// Reference url
ref *gojsonreference.JsonReference
Ref *gojsonreference.JsonReference
// Schema referenced
refSchema *subSchema
RefSchema *SubSchema

// hierarchy
parent *subSchema
itemsChildren []*subSchema
itemsChildrenIsSingleSchema bool
propertiesChildren []*subSchema
Parent *SubSchema
ItemsChildren []*SubSchema
ItemsChildrenIsSingleSchema bool
PropertiesChildren []*SubSchema

// validation : number / integer
multipleOf *big.Rat
Expand All @@ -121,29 +122,29 @@ type subSchema struct {
maxProperties *int
required []string

dependencies map[string]interface{}
additionalProperties interface{}
patternProperties map[string]*subSchema
propertyNames *subSchema
Dependencies map[string]interface{}
AdditionalProperties interface{}
PatternProperties map[string]*SubSchema
PropertyNames *SubSchema

// validation : array
minItems *int
maxItems *int
uniqueItems bool
contains *subSchema
Contains *SubSchema

additionalItems interface{}
AdditionalItems interface{}

// validation : all
_const *string //const is a golang keyword
enum []string

// validation : subSchema
oneOf []*subSchema
anyOf []*subSchema
allOf []*subSchema
not *subSchema
_if *subSchema // if/else are golang keywords
_then *subSchema
_else *subSchema
// validation : SubSchema
oneOf []*SubSchema
anyOf []*SubSchema
allOf []*SubSchema
not *SubSchema
_if *SubSchema // if/else are golang keywords
_then *SubSchema
_else *SubSchema
}
Loading