Skip to content

Commit 13853f7

Browse files
author
Olha Yelisieieva
committed
Issue-16: Added test for InheritanceChainPropertiesValidator
1 parent 76b37d6 commit 13853f7

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

0 commit comments

Comments
 (0)