use of io.swagger.v3.jaxrs2.resources.model.Tag in project swagger-parser by swagger-api.
the class OpenAPIDeserializer method getTagList.
public List<Tag> getTagList(ArrayNode obj, String location, ParseResult result) {
if (obj == null) {
return null;
}
List<Tag> tags = new ArrayList<>();
Set<String> tagsTracker = new HashSet<>();
for (JsonNode item : obj) {
if (item.getNodeType().equals(JsonNodeType.OBJECT)) {
Tag tag = getTag((ObjectNode) item, location, result);
if (tag != null) {
tags.add(tag);
if (tagsTracker.contains((String) tag.getName())) {
result.uniqueTags(location, tag.getName());
}
tagsTracker.add(tag.getName());
}
}
}
return tags;
}
use of io.swagger.v3.jaxrs2.resources.model.Tag in project swagger-parser by swagger-api.
the class SwaggerConverter method convertTags.
private List<Tag> convertTags(List<io.swagger.models.Tag> v2tags) {
List<Tag> v3tags = new ArrayList<>();
for (io.swagger.models.Tag v2tag : v2tags) {
Tag v3tag = new Tag();
v3tag.setDescription(v2tag.getDescription());
v3tag.setName(v2tag.getName());
if (v2tag.getExternalDocs() != null) {
v3tag.setExternalDocs(convert(v2tag.getExternalDocs()));
}
Map<String, Object> extensions = convert(v2tag.getVendorExtensions());
if (extensions != null) {
v3tag.setExtensions(extensions);
}
v3tags.add(v3tag);
}
return v3tags;
}
use of io.swagger.v3.jaxrs2.resources.model.Tag in project swagger-parser by swagger-api.
the class OpenAPIResolverTest method testYamlArrayResponseRemoteRefs.
@Test(description = "resolve array response remote refs in yaml")
public void testYamlArrayResponseRemoteRefs() {
final OpenAPI swagger = new OpenAPI();
swagger.path("/fun", new PathItem().get(new Operation().responses(new ApiResponses().addApiResponse("200", new ApiResponse().content(new Content().addMediaType("*/*", new MediaType().schema(new ArraySchema().items(new Schema().$ref(replacePort(REMOTE_REF_YAML))))))))));
final OpenAPI resolved = new OpenAPIResolver(swagger, null).resolve();
final ApiResponse response = swagger.getPaths().get("/fun").getGet().getResponses().get("200");
final ArraySchema array = (ArraySchema) response.getContent().get("*/*").getSchema();
assertNotNull(array.getItems());
assertEquals(array.getItems().get$ref(), "#/components/schemas/Tag");
assertNotNull(swagger.getComponents().getSchemas().get("Tag"));
}
use of io.swagger.v3.jaxrs2.resources.model.Tag in project swagger-parser by swagger-api.
the class OpenAPIResolverTest method testMapRemoteModelProperty.
private void testMapRemoteModelProperty(String remoteRef) {
final OpenAPI swagger = new OpenAPI();
swagger.components(new Components().addSchemas("Sample", new Schema().addProperties("remoteRef", new Schema().additionalProperties(new Schema().$ref(remoteRef)))));
final OpenAPI resolved = new OpenAPIResolver(swagger, null).resolve();
final Schema prop = (Schema) resolved.getComponents().getSchemas().get("Sample").getProperties().get("remoteRef");
assertTrue(prop.getAdditionalProperties() != null);
assertEquals(((Schema) prop.getAdditionalProperties()).get$ref(), "#/components/schemas/Tag");
assertNotNull(swagger.getComponents().getSchemas().get("Tag"));
}
use of io.swagger.v3.jaxrs2.resources.model.Tag in project swagger-parser by swagger-api.
the class OpenAPIResolverTest method testArrayRemoteModelProperty.
private void testArrayRemoteModelProperty(String remoteRef) {
final OpenAPI swagger = new OpenAPI();
swagger.components(new Components().addSchemas("Sample", new Schema().addProperties("remoteRef", new ArraySchema().items(new Schema().$ref(remoteRef)))));
final OpenAPI resolved = new OpenAPIResolver(swagger, null).resolve();
final Schema prop = (Schema) resolved.getComponents().getSchemas().get("Sample").getProperties().get("remoteRef");
assertTrue(prop instanceof ArraySchema);
final ArraySchema ap = (ArraySchema) prop;
assertEquals(ap.getItems().get$ref(), "#/components/schemas/Tag");
assertNotNull(swagger.getComponents().getSchemas().get("Tag"));
}
Aggregations