File tree Expand file tree Collapse file tree 5 files changed +100
-3
lines changed
main/java/com/github/sylvainlaurent/maven/swaggervalidator/semantic/validator/definition
java/com/github/sylvainlaurent/maven/swaggervalidator
resources/semantic-validation Expand file tree Collapse file tree 5 files changed +100
-3
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,9 @@ public void validate(RefModelWrapper refModelWrapper) {
6868 @ Override
6969 public void validate (ComposedModelWrapper composedModelWrapper ) {
7070 if (composedModelWrapper != root ) {
71- Map <String , Property > childProperties = composedModelWrapper .getChild (). getProperties () ! = null ?
72- composedModelWrapper . getChild (). getProperties () :
73- Collections .< String , Property > emptyMap ();
71+ Map <String , Property > childProperties = composedModelWrapper .getChild ()== null || composedModelWrapper . getChild (). getProperties () = = null ?
72+ Collections .< String , Property > emptyMap () :
73+ composedModelWrapper . getChild (). getProperties ();
7474 parentProperties .addAll (childProperties .keySet ());
7575 }
7676
Original file line number Diff line number Diff line change 1+ package com .github .sylvainlaurent .maven .swaggervalidator .semantic .validator .path ;
2+
3+ import static com .github .sylvainlaurent .maven .swaggervalidator .SemanticValidationServiceTest .RESOURCE_FOLDER ;
4+ import static com .github .sylvainlaurent .maven .swaggervalidator .SemanticValidationServiceTest .readDoc ;
5+ import static org .junit .Assert .assertEquals ;
6+ import static org .junit .Assert .assertFalse ;
7+ import static org .junit .Assert .assertTrue ;
8+
9+ import java .util .List ;
10+
11+ import com .github .sylvainlaurent .maven .swaggervalidator .ValidatorJunitRunner ;
12+ import com .github .sylvainlaurent .maven .swaggervalidator .semantic .validator .error .SemanticError ;
13+ import com .github .sylvainlaurent .maven .swaggervalidator .service .SemanticValidationService ;
14+ import io .swagger .parser .util .SwaggerDeserializationResult ;
15+ import org .junit .Test ;
16+ import org .junit .runner .RunWith ;
17+ import org .slf4j .Logger ;
18+ import org .slf4j .LoggerFactory ;
19+
20+ @ RunWith (ValidatorJunitRunner .class )
21+ public class InheritanceChainPropertiesValidatorTest {
22+
23+ private static Logger logger = LoggerFactory .getLogger (InheritanceChainPropertiesValidatorTest .class );
24+
25+ @ Test
26+ public void succeed_when_ancestor_has_no_properties () {
27+ SwaggerDeserializationResult swaggerResult = readDoc (
28+ RESOURCE_FOLDER + "inheritance-hierarchy-model-valid.yml" );
29+ List <SemanticError > errors = new SemanticValidationService (swaggerResult .getSwagger ()).validate ();
30+ logger .info (errors .toString ());
31+
32+ assertTrue (errors .isEmpty ());
33+ }
34+
35+ }
Original file line number Diff line number Diff line change 11package com .github .sylvainlaurent .maven .swaggervalidator .semantic .validator .path ;
22
3+ import com .github .sylvainlaurent .maven .swaggervalidator .ValidatorJunitRunner ;
34import com .github .sylvainlaurent .maven .swaggervalidator .semantic .validator .error .SemanticError ;
45import com .github .sylvainlaurent .maven .swaggervalidator .service .SemanticValidationService ;
56import io .swagger .parser .util .SwaggerDeserializationResult ;
67import org .junit .Test ;
8+ import org .junit .runner .RunWith ;
79import org .slf4j .Logger ;
810import org .slf4j .LoggerFactory ;
911
1517import static org .junit .Assert .assertFalse ;
1618import static org .junit .Assert .assertTrue ;
1719
20+ @ RunWith (ValidatorJunitRunner .class )
1821public class OperationParametersReferenceValidatorTest {
1922
2023 private static Logger logger = LoggerFactory .getLogger (OperationParametersReferenceValidatorTest .class );
Original file line number Diff line number Diff line change 22
33import java .util .Set ;
44
5+ import com .github .sylvainlaurent .maven .swaggervalidator .ValidatorJunitRunner ;
56import org .junit .Assert ;
67import org .junit .Test ;
78
1213import com .github .sylvainlaurent .maven .swaggervalidator .util .validators .path .PathValidatorImpl ;
1314import com .github .sylvainlaurent .maven .swaggervalidator .util .validators .path .PathValidatorTemplateImpl ;
1415import com .github .sylvainlaurent .maven .swaggervalidator .util .validators .path .SwaggerPathValidatorImpl ;
16+ import org .junit .runner .RunWith ;
1517
18+ @ RunWith (ValidatorJunitRunner .class )
1619public class UtilTest {
1720
1821 private static final String MODEL_VALIDATORS_PACKAGE = "com.github.sylvainlaurent.maven.swaggervalidator.util.validators.model" ;
Original file line number Diff line number Diff line change 1+ swagger : ' 2.0'
2+ info :
3+ title : Test API
4+ description : Test API
5+ version : " 1.0.0"
6+ host : none
7+ schemes :
8+ - https
9+ basePath : /v1
10+ produces :
11+ - application/json
12+ paths :
13+ /products/{id} :
14+ get :
15+ parameters :
16+ - name : id
17+ in : path
18+ required : true
19+ type : string
20+ operationId : getProduct
21+ summary : test service
22+ responses :
23+ 200 :
24+ description : ok
25+ schema :
26+ $ref : ' #/definitions/Product'
27+
28+ definitions :
29+ TypedProduct1 :
30+ x-discriminator-value : productType1
31+ allOf :
32+ - $ref : ' #/definitions/CatalogProduct'
33+ CatalogProduct :
34+ allOf :
35+ - $ref : ' #/definitions/Product'
36+ Product :
37+ allOf :
38+ - $ref : ' #/definitions/Entity'
39+ - type : object
40+ discriminator : productType
41+ required :
42+ - productType
43+ properties :
44+ productType :
45+ $ref : ' #/definitions/ProductType'
46+ Entity :
47+ type : object
48+ properties :
49+ id :
50+ type : string
51+ ProductType :
52+ type : string
53+ enum :
54+ - productType1
55+ - productType2
56+ - productType3
You can’t perform that action at this time.
0 commit comments