24 | *
25 | * "tags": {
26 | * "type": "array",
27 | * "items": {
28 | * "$ref": "#/definitions/tag"
29 | * },
30 | * "uniqueItems": true
31 | * }
32 | *
33 | *
34 | *
35 | */
36 | public class ArrayTypeDefinition extends TypeDefinition {
37 |
38 | public final TypeDefinition itemsType;
39 |
40 | public ArrayTypeDefinition(JsonSchema schema, JsonPointer pointer, JsonNode definition) {
41 | super(schema, pointer, definition, JsonType.ARRAY);
42 | itemsType = schema.createType(this, "items", definition.get("items"));
43 | }
44 |
45 | @Override
46 | public TypeDefinition getPropertyType(String property) {
47 | return itemsType;
48 | }
49 | }
--------------------------------------------------------------------------------
/com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/schema/JsonSchemaUtils.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 ModelSolv, Inc. and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * ModelSolv, Inc. - initial API and implementation and/or initial documentation
10 | *******************************************************************************/
11 | package com.reprezen.swagedit.core.schema;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 | import java.util.StringJoiner;
16 |
17 | import com.fasterxml.jackson.databind.JsonNode;
18 | import com.fasterxml.jackson.databind.node.ArrayNode;
19 |
20 | public class JsonSchemaUtils {
21 | public static String getHumanFriendlyText(JsonNode swaggerSchemaNode, final String defaultValue) {
22 | String schemaTitle = getSchemaTitle(swaggerSchemaNode);
23 | if (schemaTitle != null) {
24 | return schemaTitle;
25 | }
26 | // nested array
27 | if (swaggerSchemaNode.get("items") != null) {
28 | return getHumanFriendlyText(swaggerSchemaNode.get("items"), defaultValue);
29 | }
30 | // "$ref":"#/definitions/headerParameterSubSchema"
31 | JsonNode ref = swaggerSchemaNode.get("$ref");
32 | if (ref != null) {
33 | return getLabelForRef(ref.asText());
34 | }
35 | // Auxiliary oneOf in "oneOf": [ { "$ref": "#/definitions/securityRequirement" }]
36 | JsonNode oneOf = swaggerSchemaNode.get("oneOf");
37 | if (oneOf != null) {
38 | if (oneOf instanceof ArrayNode) {
39 | ArrayNode arrayNode = (ArrayNode) oneOf;
40 | if (arrayNode.size() > 0) {
41 | List