@@ -169,7 +169,7 @@ func (sd *SpecAnalyser) analyseEndpointData() {
169169}
170170
171171func (sd * SpecAnalyser ) analyseRequestParams () {
172- locations := []string {"query" , "path" , "body" , "header" }
172+ locations := []string {"query" , "path" , "body" , "header" , "formData" }
173173
174174 for _ , paramLocation := range locations {
175175 rootNode := getNameOnlyDiffNode (strings .Title (paramLocation ))
@@ -355,9 +355,9 @@ func (sd *SpecAnalyser) compareParams(urlMethod URLMethod, location string, name
355355 if len (name ) > 0 {
356356 childLocation = childLocation .AddNode (getSchemaDiffNode (name , param2 .Schema ))
357357 }
358-
359358 sd .compareSchema (childLocation , param1 .Schema , param2 .Schema )
360359 }
360+
361361 diffs := sd .CompareProps (forParam (param1 ), forParam (param2 ))
362362
363363 childLocation = childLocation .AddNode (getSchemaDiffNode (name , & param2 .SimpleSchema ))
@@ -369,6 +369,10 @@ func (sd *SpecAnalyser) compareParams(urlMethod URLMethod, location string, name
369369 if len (diffs ) > 0 {
370370 sd .addDiffs (childLocation , diffs )
371371 }
372+
373+ if & param1 .SimpleSchema != nil && & param2 .SimpleSchema != nil {
374+ sd .compareSimpleSchema (childLocation , & param1 .SimpleSchema , & param2 .SimpleSchema )
375+ }
372376}
373377
374378func (sd * SpecAnalyser ) addTypeDiff (location DifferenceLocation , diff * TypeDiff ) {
@@ -462,6 +466,51 @@ func (sd *SpecAnalyser) compareSchema(location DifferenceLocation, schema1, sche
462466 }
463467}
464468
469+ func (sd * SpecAnalyser ) compareSimpleSchema (location DifferenceLocation , schema1 , schema2 * spec.SimpleSchema ) {
470+ // check optional/required
471+ if schema1 .Nullable != schema2 .Nullable {
472+ // If optional is made required
473+ if schema1 .Nullable && ! schema2 .Nullable {
474+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : ChangedOptionalToRequired , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
475+ } else if ! schema1 .Nullable && schema2 .Nullable {
476+ // If required is made optional
477+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : ChangedRequiredToOptional , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
478+ }
479+ }
480+
481+ if schema1 .CollectionFormat != schema2 .CollectionFormat {
482+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : ChangedCollectionFormat , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
483+ }
484+
485+ if schema1 .Default != schema2 .Default {
486+ if schema1 .Default == nil && schema2 .Default != nil {
487+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : AddedDefault , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
488+ } else if schema1 .Default != nil && schema2 .Default == nil {
489+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : DeletedDefault , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
490+ } else {
491+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : ChangedDefault , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
492+ }
493+ }
494+
495+ if schema1 .Example != schema2 .Example {
496+ if schema1 .Example == nil && schema2 .Example != nil {
497+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : AddedExample , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
498+ } else if schema1 .Example != nil && schema2 .Example == nil {
499+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : DeletedExample , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
500+ } else {
501+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : ChangedExample , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
502+ }
503+ }
504+
505+ if isArray (schema1 ) {
506+ if isArray (schema2 ) {
507+ sd .compareSimpleSchema (location , & schema1 .Items .SimpleSchema , & schema2 .Items .SimpleSchema )
508+ } else {
509+ sd .addDiffs (location , addTypeDiff ([]TypeDiff {}, TypeDiff {Change : ChangedType , FromType : getSchemaTypeStr (schema1 ), ToType : getSchemaTypeStr (schema2 )}))
510+ }
511+ }
512+ }
513+
465514func (sd * SpecAnalyser ) addDiffs (location DifferenceLocation , diffs []TypeDiff ) {
466515 for _ , e := range diffs {
467516 eachTypeDiff := e
0 commit comments