Java Code Examples for io.swagger.models.ModelImpl#getEnum()

The following examples show how to use io.swagger.models.ModelImpl#getEnum() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultCodegen.java    From TypeScript-Microservices with MIT License 6 votes vote down vote up
/**
 * Determine all of the types in the model definitions that are aliases of
 * simple types.
 * @param allDefinitions The complete set of model definitions.
 * @return A mapping from model name to type alias
 */
private static Map<String, String> getAllAliases(Map<String, Model> allDefinitions) {
    Map<String, String> aliases = new HashMap<>();
    if (allDefinitions != null) {
        for (Map.Entry<String, Model> entry : allDefinitions.entrySet()) {
            String swaggerName = entry.getKey();
            Model m = entry.getValue();
            if (m instanceof ModelImpl) {
                ModelImpl impl = (ModelImpl) m;
                if (impl.getType() != null &&
                        !impl.getType().equals("object") &&
                        impl.getEnum() == null) {
                    aliases.put(swaggerName, impl.getType());
                }
            }
        }
    }
    return aliases;
}
 
Example 2
Source File: PlantUMLCodegen.java    From swagger2puml with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param model
 * @return
 */
private List<ClassMembers> getClassMembers(ModelImpl model, Map<String, Model> modelsMap) {
	LOGGER.entering(LOGGER.getName(), "getClassMembers-ModelImpl");

	List<ClassMembers> classMembers = new ArrayList<ClassMembers>();

	Map<String, Property> modelMembers = model.getProperties();
	if (modelMembers != null && !modelMembers.isEmpty()) {
		classMembers.addAll(convertModelPropertiesToClassMembers(modelMembers, model, modelsMap));
	} else {
		Property modelAdditionalProps = model.getAdditionalProperties();

		if (modelAdditionalProps instanceof RefProperty) {
			classMembers.add(getRefClassMembers((RefProperty) modelAdditionalProps));
		}

		if (modelAdditionalProps == null) {
			List<String> enumValues = model.getEnum();

			if (enumValues != null && !enumValues.isEmpty()) {
				classMembers.addAll(getEnum(enumValues));
			}
		}
	}

	LOGGER.exiting(LOGGER.getName(), "getClassMembers-ModelImpl");

	return classMembers;
}
 
Example 3
Source File: DocumentationDrivenValidator.java    From assertj-swagger with Apache License 2.0 5 votes vote down vote up
private void validateDefinitionEnum(Model actualDefinition, Model expectedDefinition) {
    ModelImpl expectedDefModelImpl = (ModelImpl) expectedDefinition;
    ModelImpl actualDefModelImpl = (ModelImpl) actualDefinition;
    List<String> actualEnums = actualDefModelImpl.getEnum();
    List<String> expectedEnums = expectedDefModelImpl.getEnum();
    if (CollectionUtils.isNotEmpty(expectedEnums)) {
        softAssertions.assertThat(actualEnums).hasSameElementsAs(expectedEnums);
    } else {
        softAssertions.assertThat(actualEnums).isNullOrEmpty();
    }
}