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

x33g5p2x  于2022-01-29 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(210)

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

Swagger.getDefinitions介绍

暂无

代码示例

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

ResponseComponent(Swagger2MarkupConverter.Context context,
         DocumentResolver definitionDocumentResolver) {
  super(context);
  this.definitions = context.getSwagger().getDefinitions();
  this.definitionDocumentResolver = Validate.notNull(definitionDocumentResolver, "DocumentResolver must not be null");
  this.tableComponent = new TableComponent(context);
}

代码示例来源:origin: blox/blox

@Override
 public void apply(Swagger swagger) {
  if (swagger.getDefinitions() != null) {
   swagger.setDefinitions(new TreeMap<>(swagger.getDefinitions()));
  }

  if (swagger.getPaths() != null) {
   swagger.setPaths(new TreeMap<>(swagger.getPaths()));
  }
 }
}

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

private MarkupDocBuilder applyDefinitionsDocument() {
  return definitionsDocument.apply(
      context.createMarkupDocBuilder(),
      DefinitionsDocument.parameters(context.getSwagger().getDefinitions()));
}

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

public DefinitionComponent(Swagger2MarkupConverter.Context context,
              DocumentResolver definitionsDocumentResolver) {
  super(context);
  this.definitions = context.getSwagger().getDefinitions();
  this.definitionsDocumentResolver = definitionsDocumentResolver;
  POLYMORPHISM_NATURE = new HashMap<ObjectTypePolymorphism.Nature, String>() {{
    put(ObjectTypePolymorphism.Nature.COMPOSITION, labels.getLabel(POLYMORPHISM_NATURE_COMPOSITION));
    put(ObjectTypePolymorphism.Nature.INHERITANCE, labels.getLabel(POLYMORPHISM_NATURE_INHERITANCE));
  }};
  propertiesTableComponent = new PropertiesTableComponent(context, definitionsDocumentResolver);
}

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

public PathOperationComponent(Swagger2MarkupConverter.Context context,
               DocumentResolver definitionDocumentResolver,
               DocumentResolver securityDocumentResolver) {
  super(context);
  this.definitions = context.getSwagger().getDefinitions();
  this.definitionDocumentResolver = Validate.notNull(definitionDocumentResolver, "DocumentResolver must not be null");
  this.propertiesTableComponent = new PropertiesTableComponent(context, definitionDocumentResolver);
  this.parameterTableComponent = new ParameterTableComponent(context, definitionDocumentResolver);
  this.consumesComponent = new ConsumesComponent(context);
  this.producesComponent = new ProducesComponent(context);
  this.securitySchemeComponent = new SecuritySchemeComponent(context, securityDocumentResolver);
  this.bodyParameterComponent = new BodyParameterComponent(context, definitionDocumentResolver);
  this.responseComponent = new ResponseComponent(context, definitionDocumentResolver);
}

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

public ParameterAdapter(Swagger2MarkupConverter.Context context,
            PathOperation operation,
            Parameter parameter,
            DocumentResolver definitionDocumentResolver) {
  Validate.notNull(parameter, "parameter must not be null");
  this.parameter = parameter;
  type = getType(context.getSwagger().getDefinitions(), definitionDocumentResolver);
  config = context.getConfig();
  if (config.isInlineSchemaEnabled()) {
    if (config.isFlatBodyEnabled()) {
      if (!(type instanceof ObjectType)) {
        type = InlineSchemaUtils.createInlineType(type, parameter.getName(), operation.getId() + " " + parameter.getName(), inlineDefinitions);
      }
    } else {
      type = InlineSchemaUtils.createInlineType(type, parameter.getName(), operation.getId() + " " + parameter.getName(), inlineDefinitions);
    }
  }
}

代码示例来源: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

@Test
  public void testDefinitionComponent() throws URISyntaxException {
    //Given
    Path file = Paths.get(DefinitionComponentTest.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();

    //When
    markupDocBuilder = new DefinitionComponent(context, new DefinitionDocumentResolverFromDefinition(context))
        .apply(markupDocBuilder, DefinitionComponent.parameters("Pet", petModel, 2));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

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

  }
}

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

protected void convertDefinitions() {
 if (swagger.getDefinitions() == null) {
  return;
 }
 for (Entry<String, Model> entry : swagger.getDefinitions().entrySet()) {
  convertModel(entry.getKey(), entry.getValue());
 }
}

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

private void convertDefinitions() {
 if (swagger.getDefinitions() == null) {
  return;
 }
 for (Entry<String, Model> entry : swagger.getDefinitions().entrySet()) {
  convertDefinition(entry.getKey(), (ModelImpl) entry.getValue());
 }
}

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

public static void appendDefinition(Swagger swagger, Map<String, Model> newDefinitions) {
 if (newDefinitions.isEmpty()) {
  return;
 }
 Map<String, Model> definitions = swagger.getDefinitions();
 if (definitions == null) {
  definitions = new LinkedHashMap<>();
  swagger.setDefinitions(definitions);
 }
 definitions.putAll(newDefinitions);
}

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

public JavaType convertRef(String ref) {
  return convertModel(ref, swagger.getDefinitions().get(ref));
 }
}

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

if (swagger.getDefinitions() != null) {
  TreeMap<String, Model> defs = new TreeMap<String, Model>();
  defs.putAll(swagger.getDefinitions());
  swagger.setDefinitions(defs);

代码示例来源:origin: org.apache.servicecomb/common-protobuf

private void convertDefinitions() {
 if (swagger.getDefinitions() == null) {
  return;
 }
 for (Entry<String, Model> entry : swagger.getDefinitions().entrySet()) {
  convertDefinition(entry.getKey(), (ModelImpl) entry.getValue());
 }
}

代码示例来源:origin: org.apache.servicecomb/swagger-generator-core

public static void appendDefinition(Swagger swagger, Map<String, Model> newDefinitions) {
 if (newDefinitions.isEmpty()) {
  return;
 }
 Map<String, Model> definitions = swagger.getDefinitions();
 if (definitions == null) {
  definitions = new LinkedHashMap<>();
  swagger.setDefinitions(definitions);
 }
 definitions.putAll(newDefinitions);
}

代码示例来源:origin: tminglei/binder-swagger-java

public void scanAndRegisterNamedModels(Framework.Mapping<?> mapping) {
  synchronized (swagger) {
    mConverter.scanModels(mapping).forEach(p -> {
      Model existed = swagger.getDefinitions() == null ? null : swagger.getDefinitions().get(p.getKey());
      if (existed == null) swagger.model(p.getKey(), p.getValue());
      else if (!existed.equals(p.getValue())) {
        throw new IllegalArgumentException("CONFLICTED model definitions for '" + p.getKey() + "'!!!");
      }
    });
  }
}

代码示例来源:origin: amazon-archives/aws-apigateway-importer

private void updateModel(RestApi api, String modelName, io.swagger.models.Model model) {
  LOG.info(format("Updating model for api id %s and model name %s", api.getId(), modelName));
  updateModel(api, modelName, generateSchema(model, modelName, swagger.getDefinitions()));
}

代码示例来源:origin: amazon-archives/aws-apigateway-importer

private void createModel(RestApi api, String modelName, Property model, String modelContentType) {
  LOG.info(format("Creating model for api id %s with name %s", api.getId(), modelName));
  createModel(api, modelName, model.getDescription(), generateSchema(model, modelName, swagger.getDefinitions()), modelContentType);
}

代码示例来源:origin: io.github.swagger2markup/swagger2markup

private MarkupDocBuilder applyDefinitionsDocument() {
  return definitionsDocument.apply(
      context.createMarkupDocBuilder(),
      DefinitionsDocument.parameters(context.getSwagger().getDefinitions()));
}

代码示例来源:origin: io.github.swagger2markup/swagger2markup

public DefinitionComponent(Swagger2MarkupConverter.Context context,
              DocumentResolver definitionsDocumentResolver) {
  super(context);
  this.definitions = context.getSwagger().getDefinitions();
  this.definitionsDocumentResolver = definitionsDocumentResolver;
  POLYMORPHISM_NATURE = new HashMap<ObjectTypePolymorphism.Nature, String>() {{
    put(ObjectTypePolymorphism.Nature.COMPOSITION, labels.getLabel(POLYMORPHISM_NATURE_COMPOSITION));
    put(ObjectTypePolymorphism.Nature.INHERITANCE, labels.getLabel(POLYMORPHISM_NATURE_INHERITANCE));
  }};
  propertiesTableComponent = new PropertiesTableComponent(context, definitionsDocumentResolver);
}

相关文章