io.swagger.models.Model.getProperties()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中io.swagger.models.Model.getProperties()方法的一些代码示例,展示了Model.getProperties()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.getProperties()方法的具体详情如下:
包路径:io.swagger.models.Model
类名称:Model
方法名:getProperties

Model.getProperties介绍

暂无

代码示例

代码示例来源:origin: Swagger2Markup/swagger2markup

private static Map<String, Property> getPropertiesForComposedModel(ComposedModel model, Map<String, Model> definitions) {
  //TODO: Unused method, make sure this is never used and then remove it.
  Map<String, Property> combinedProperties;
  if (model.getParent() instanceof RefModel) {
    Map<String, Property> parentProperties = definitions.get(((RefModel) model.getParent()).getSimpleRef()).getProperties();
    if (parentProperties == null) {
      return null;
    } else {
      combinedProperties = new LinkedHashMap<>(parentProperties);
    }
  } else {
    combinedProperties = new LinkedHashMap<>(model.getParent().getProperties());
  }
  Map<String, Property> childProperties;
  if (model.getChild() instanceof RefModel) {
    childProperties = definitions.get(((RefModel) model.getChild()).getSimpleRef()).getProperties();
  } else {
    childProperties = model.getChild().getProperties();
  }
  if (childProperties != null) {
    combinedProperties.putAll(childProperties);
  }
  return combinedProperties;
}

代码示例来源:origin: Swagger2Markup/swagger2markup

example = exampleMapForProperties(model.getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, refStack);

代码示例来源:origin: jooby-project/jooby

types.put(type, object);
Map<String, Object> example = new LinkedHashMap<>();
Optional.ofNullable(model.getProperties())
  .ifPresent(properties -> properties.forEach((name, property) -> {
   if (property instanceof RefProperty) {

代码示例来源:origin: jooby-project/jooby

private List<Parameter> expandParameter(Map<String, Model> models, RouteParameter it,
  Supplier<SerializableParameter> factory, String typeName, String prefix, boolean optional) {
 List<Parameter> parameters = new ArrayList<>();
 Model model = models.get(typeName);
 Map<String, Property> properties = model.getProperties();
 Optional.ofNullable(properties).ifPresent(props -> props.values().stream()
   .flatMap(p -> {
    SerializableParameter result = complement(p, it, factory.get());
    String name = prefix + p.getName();
    if (p instanceof RefProperty) {
     return expandParameter(models, it, factory, ((RefProperty) p).getSimpleRef(),
       name + ".", optional).stream();
    } else {
     result.setName(name);
     boolean required;
     if (optional) {
      required = false;
     } else {
      required = p.getRequired();
     }
     String desc = Strings.emptyToNull(p.getDescription());
     result.setRequired(required);
     result.setDescription(desc);
     return Stream.of(result);
    }
   })
   .forEach(parameters::add)
 );
 return parameters;
}

代码示例来源:origin: jooby-project/jooby

/**
 * Mostly for kotlin null safe operator and immutable properties.
 *
 * @param type Target type.
 * @param model Model.
 * @return Input model.
 */
private Model doModel(Type type, Model model) {
 Map<String, Property> properties = model.getProperties();
 if (properties != null) {
  BeanDescription desc = Json.mapper().getSerializationConfig()
    .introspect(Json.mapper().constructType(type));
  for (BeanPropertyDefinition beanProperty : desc.findProperties()) {
   Property property = properties.get(beanProperty.getName());
   if (property != null) {
    property.setRequired(beanProperty.isRequired());
   }
  }
 }
 return model;
}

代码示例来源:origin: Swagger2Markup/swagger2markup

example = schema.getExample();
if (example == null) {
  example = exampleMapForProperties(schema.getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
  public void testPropertiesTableComponent() throws URISyntaxException {
    //Given
    Path file = Paths.get(PropertiesTableComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger swagger = converter.getContext().getSwagger();

    Model petModel = swagger.getDefinitions().get("Pet");

    Swagger2MarkupConverter.Context context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    List<ObjectType> localDefinitions = new ArrayList<>();
    //When
    markupDocBuilder = new PropertiesTableComponent(context,
        new DefinitionDocumentResolverFromDefinition(context))
        .apply(markupDocBuilder, PropertiesTableComponent.parameters(petModel.getProperties(),
            "Pet", localDefinitions));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

  }
}

代码示例来源:origin: Swagger2Markup/swagger2markup

return new EnumType(modelImpl.getTitle(), modelImpl.getEnum());
else if (modelImpl.getProperties() != null) {
  ObjectType objectType = new ObjectType(modelImpl.getTitle(), model.getProperties());

代码示例来源:origin: apache/servicecomb-java-chassis

private LinkedHashMap<String, AbstractSerializableParameter<?>> getFlattenParams(Model paramModel) {
 LinkedHashMap<String, AbstractSerializableParameter<?>> flattenParamMap = new LinkedHashMap<>();
 // traversal the properties of current paramModel
 // create simple parameters, nesting object param is ignored
 for (Entry<String, Property> propertyEntry : paramModel.getProperties().entrySet()) {
  if (ParamUtils.isComplexProperty(propertyEntry.getValue())) {
   throw new Error(
     "A nesting complex field is found in the query object and this is not supported, field name  = ["
       + propertyEntry.getKey() + "]. Please remove this field or tag @JsonIgnore on it.");
  }
  AbstractSerializableParameter<?> newParameter = createSimpleParam(propertyEntry);
  flattenParamMap.put(propertyEntry.getKey(), newParameter);
 }
 return flattenParamMap;
}

代码示例来源:origin: kongchen/swagger-maven-plugin

/**
 * Remove property from {@link Model} for provided {@link ApiModelProperty}.
 * @param apiModelPropertyAnnotation annotation
 * @param model model with properties
 */
private void processProperty(ApiModelProperty apiModelPropertyAnnotation, Model model) {
  if (apiModelPropertyAnnotation == null) {
    return;
  }
  String apiModelPropertyAccess = apiModelPropertyAnnotation.access();
  String apiModelPropertyName = apiModelPropertyAnnotation.name();
  // If the @ApiModelProperty is not populated with both #name and #access, skip it
  if (apiModelPropertyAccess.isEmpty() || apiModelPropertyName.isEmpty()) {
    return;
  }
  // Check to see if the value of @ApiModelProperty#access is one to exclude.
  // If so, remove it from the previously-calculated model.
  if (apiModelPropertyAccessExclusions.contains(apiModelPropertyAccess)) {
    model.getProperties().remove(apiModelPropertyName);
  }
}

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

@Override
public Model getUPDATEModel(Representation rep) {
  Model model = getCREATEModel(rep);
  model.getProperties().remove("property");
  return model;
}

代码示例来源:origin: com.reprezen.genflow/genflow-api

@Override
public void model(Model model) {
  model.setProperties(fillMap(model.getProperties()));
  if (model instanceof ModelImpl) {
  }
}

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

@Override
public Model getGETModel(Representation rep) {
  Model model = super.getGETModel(rep);
  model.getProperties().remove("memberIds");
  return model;
}

代码示例来源:origin: io.syndesis.server/server-api-generator

private static void defineElementPropertiesOf(final Element parent, final Model model, final Swagger swagger,
  final Map<String, SchemaPrefixAndElement> moreSchemas) {
  final Map<String, Property> properties = model.getProperties();
  for (final Entry<String, Property> propertyEntry : properties.entrySet()) {
    final String propertyName = propertyEntry.getKey();
    final Property property = propertyEntry.getValue();
    if (XmlSchemaHelper.isElement(property)) {
      defineElementProperty(propertyName, property, parent, swagger, moreSchemas);
    }
  }
}

代码示例来源:origin: io.syndesis.server/server-connector-generator

private static void defineElementPropertiesOf(final Element parent, final Model model, final Swagger swagger,
  final Map<String, SchemaPrefixAndElement> moreSchemas) {
  final Map<String, Property> properties = model.getProperties();
  for (final Entry<String, Property> propertyEntry : properties.entrySet()) {
    final String propertyName = propertyEntry.getKey();
    final Property property = propertyEntry.getValue();
    if (isElement(property)) {
      defineElementProperty(propertyName, property, parent, swagger, moreSchemas);
    }
  }
}

代码示例来源:origin: org.teiid.connectors/translator-swagger

@Override
  public void visit(String name, RefProperty property) {
    parents.add(property);
    Model model = swagger.getDefinitions().get(property.getSimpleRef());
    walkProperties(swagger, parents,
        model.getProperties(), fqn(namePrefix, name),
        nis(nisPrefix, name, false), pa);
    parents.remove(property);
  }           
};

代码示例来源:origin: io.syndesis.server/server-api-generator

private static boolean schemaIsNotSpecified(final Model schema) {
  if (schema == null) {
    return true;
  }
  if (schema instanceof ArrayModel) {
    return ((ArrayModel) schema).getItems() == null;
  }
  final Map<String, Property> properties = schema.getProperties();
  final boolean noProperties = properties == null || properties.isEmpty();
  final boolean noReference = schema.getReference() == null;
  return noProperties && noReference;
}

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

@Override
  public Model getCREATEModel(Representation rep) {
    Model model = super.getCREATEModel(rep);
    model.getProperties().get("familyName").setRequired(false);
    return model;
  }
}

代码示例来源:origin: io.syndesis.server/server-connector-generator

private static boolean schemaIsNotSpecified(final Model schema) {
  if (schema == null) {
    return true;
  }
  if (schema instanceof ArrayModel) {
    return ((ArrayModel) schema).getItems() == null;
  }
  final Map<String, Property> properties = schema.getProperties();
  final boolean noProperties = properties == null || properties.isEmpty();
  final boolean noReference = schema.getReference() == null;
  return noProperties && noReference;
}

代码示例来源:origin: io.syndesis.rest/rest-connector-generator

private static boolean schemaIsNotSpecified(final Model schema) {
  if (schema == null) {
    return true;
  }
  if (schema instanceof ArrayModel) {
    return ((ArrayModel) schema).getItems() == null;
  }
  final Map<String, Property> properties = schema.getProperties();
  final boolean noProperties = properties == null || properties.isEmpty();
  final boolean noReference = schema.getReference() == null;
  return noProperties && noReference;
}

相关文章