Repository: apache/servicecomb-toolkit Branch: master Commit: 03b709c7dfe9 Files: 1059 Total size: 2.4 MB Directory structure: gitextract_jkg1t5v4/ ├── .gitignore ├── LICENSE ├── NOTICE ├── README-ZH.md ├── README.md ├── cli/ │ ├── pom.xml │ ├── scripts/ │ │ ├── cli.cmd │ │ └── cli.sh │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── cli/ │ │ │ ├── CheckCompatibility.java │ │ │ ├── CheckCompatibilityAbbr.java │ │ │ ├── CheckCompatibilityBase.java │ │ │ ├── CheckStyle.java │ │ │ ├── CheckStyleAbbr.java │ │ │ ├── CheckStyleBase.java │ │ │ ├── CodeGenerate.java │ │ │ ├── DocGenerate.java │ │ │ ├── ToolkitMain.java │ │ │ └── ValidationFailedException.java │ │ └── resources/ │ │ ├── application.properties │ │ └── log4j2.xml │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── cli/ │ │ └── CliTest.java │ └── resources/ │ ├── contracts/ │ │ ├── CalculateEndpoint.yaml │ │ ├── HelloEndPoint.yaml │ │ └── pojo/ │ │ └── CodeFirstHelloEndPoint.yaml │ ├── log4j2-test.xml │ ├── oas/ │ │ ├── compatibility-left.yaml │ │ ├── compatibility-right.yaml │ │ ├── style-rules.properties │ │ └── style.yaml │ └── swagger.yaml ├── codegen/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── codegen/ │ │ │ ├── AbstractConsumerDirectoryStrategy.java │ │ │ ├── AbstractDirectoryStrategy.java │ │ │ ├── AbstractJavaCodegenExt.java │ │ │ ├── AbstractMultiDirectoryStrategy.java │ │ │ ├── AbstractProviderDirectoryStrategy.java │ │ │ ├── ConsumerDirectoryStrategy.java │ │ │ ├── DefaultCodeGenerator.java │ │ │ ├── DefaultDirectoryStrategy.java │ │ │ ├── DirectoryStrategy.java │ │ │ ├── GeneratorExternalConfigConstant.java │ │ │ ├── GetGenericClassTypeLambda.java │ │ │ ├── GetRelativeBasePathLambda.java │ │ │ ├── MicroServiceFramework.java │ │ │ ├── MultiContractGenerator.java │ │ │ ├── ProjectMetaConstant.java │ │ │ ├── ProviderDirectoryStrategy.java │ │ │ ├── ServiceCombCodegen.java │ │ │ ├── ServiceType.java │ │ │ ├── ShowBasePathLambda.java │ │ │ ├── SpringCloudCodegen.java │ │ │ ├── SpringCloudConsumerDirectoryStrategy.java │ │ │ ├── SpringCloudMultiDirectoryStrategy.java │ │ │ └── SpringCloudProviderDirectoryStrategy.java │ │ └── resources/ │ │ ├── META-INF/ │ │ │ └── services/ │ │ │ ├── org.apache.servicecomb.toolkit.CodeGenerator │ │ │ └── org.openapitools.codegen.CodegenConfig │ │ ├── ServiceComb/ │ │ │ ├── consumer/ │ │ │ │ ├── Application.mustache │ │ │ │ ├── apiConsumer.mustache │ │ │ │ ├── bodyParamsConsumer.mustache │ │ │ │ ├── formParamsConsumer.mustache │ │ │ │ ├── headerParamsConsumer.mustache │ │ │ │ ├── microservice.mustache │ │ │ │ ├── pathParamsConsumer.mustache │ │ │ │ ├── pojo/ │ │ │ │ │ ├── apiConsumer.mustache │ │ │ │ │ └── apiInterface.mustache │ │ │ │ ├── pom.mustache │ │ │ │ ├── queryParamsConsumer.mustache │ │ │ │ └── springboot/ │ │ │ │ ├── Application.mustache │ │ │ │ └── pom.mustache │ │ │ ├── enumClass.mustache │ │ │ ├── enumOuterClass.mustache │ │ │ ├── libraries/ │ │ │ │ ├── JAX-RS/ │ │ │ │ │ ├── Application.mustache │ │ │ │ │ ├── api.mustache │ │ │ │ │ ├── bodyParams.mustache │ │ │ │ │ ├── formParams.mustache │ │ │ │ │ ├── headerParams.mustache │ │ │ │ │ ├── pathParams.mustache │ │ │ │ │ ├── pom.mustache │ │ │ │ │ └── queryParams.mustache │ │ │ │ ├── POJO/ │ │ │ │ │ ├── Application.mustache │ │ │ │ │ ├── api.mustache │ │ │ │ │ ├── bodyParams.mustache │ │ │ │ │ ├── formParams.mustache │ │ │ │ │ ├── headerParams.mustache │ │ │ │ │ ├── pathParams.mustache │ │ │ │ │ ├── pom.mustache │ │ │ │ │ └── queryParams.mustache │ │ │ │ ├── SpringBoot/ │ │ │ │ │ ├── Application.mustache │ │ │ │ │ ├── api.mustache │ │ │ │ │ ├── bodyParams.mustache │ │ │ │ │ ├── formParams.mustache │ │ │ │ │ ├── headerParams.mustache │ │ │ │ │ ├── operationMethod.mustache │ │ │ │ │ ├── pathParams.mustache │ │ │ │ │ ├── pom.mustache │ │ │ │ │ └── queryParams.mustache │ │ │ │ └── SpringMVC/ │ │ │ │ ├── Application.mustache │ │ │ │ ├── api.mustache │ │ │ │ ├── bodyParams.mustache │ │ │ │ ├── formParams.mustache │ │ │ │ ├── headerParams.mustache │ │ │ │ ├── pathParams.mustache │ │ │ │ ├── pom.mustache │ │ │ │ └── queryParams.mustache │ │ │ ├── log4j2.mustache │ │ │ ├── model/ │ │ │ │ ├── model.mustache │ │ │ │ └── pom.mustache │ │ │ ├── pojo.mustache │ │ │ ├── project/ │ │ │ │ └── pom.mustache │ │ │ ├── provider/ │ │ │ │ └── microservice.mustache │ │ │ └── returnTypes.mustache │ │ └── SpringCloud/ │ │ ├── consumer/ │ │ │ └── openfeign/ │ │ │ ├── Application.mustache │ │ │ ├── apiConsumer.mustache │ │ │ ├── applicationYml.mustache │ │ │ ├── bodyParamsConsumer.mustache │ │ │ ├── formParamsConsumer.mustache │ │ │ ├── headerParamsConsumer.mustache │ │ │ ├── pathParamsConsumer.mustache │ │ │ ├── pom.mustache │ │ │ └── queryParamsConsumer.mustache │ │ ├── model/ │ │ │ ├── enumClass.mustache │ │ │ ├── enumOuterClass.mustache │ │ │ ├── model.mustache │ │ │ ├── pojo.mustache │ │ │ └── pom.mustache │ │ ├── project/ │ │ │ └── pom.mustache │ │ └── provider/ │ │ └── servlet/ │ │ ├── Application.mustache │ │ ├── api.mustache │ │ ├── applicationYml.mustache │ │ ├── bodyParams.mustache │ │ ├── formParams.mustache │ │ ├── headerParams.mustache │ │ ├── pathParams.mustache │ │ ├── pom.mustache │ │ ├── queryParams.mustache │ │ └── returnTypes.mustache │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── codegen/ │ │ ├── CustomPropertiesTest.java │ │ ├── GeneratorTest.java │ │ ├── ReflectUtils.java │ │ ├── ServiceCombCodegenTest.java │ │ ├── SpringCloudCodegenTest.java │ │ └── TemplateTest.java │ └── resources/ │ ├── examples/ │ │ ├── v2.0/ │ │ │ ├── json/ │ │ │ │ ├── api-with-examples.json │ │ │ │ ├── petstore-expanded.json │ │ │ │ ├── petstore-minimal.json │ │ │ │ ├── petstore-separate/ │ │ │ │ │ ├── common/ │ │ │ │ │ │ └── Error.json │ │ │ │ │ └── spec/ │ │ │ │ │ ├── NewPet.json │ │ │ │ │ ├── Pet.json │ │ │ │ │ ├── parameters.json │ │ │ │ │ └── swagger.json │ │ │ │ ├── petstore-simple.json │ │ │ │ ├── petstore-with-external-docs.json │ │ │ │ ├── petstore.json │ │ │ │ └── uber.json │ │ │ └── yaml/ │ │ │ ├── api-with-examples.yaml │ │ │ ├── petstore-expanded.yaml │ │ │ ├── petstore-minimal.yaml │ │ │ ├── petstore-separate/ │ │ │ │ ├── common/ │ │ │ │ │ └── Error.yaml │ │ │ │ └── spec/ │ │ │ │ ├── NewPet.yaml │ │ │ │ ├── Pet.yaml │ │ │ │ ├── parameters.yaml │ │ │ │ └── swagger.yaml │ │ │ ├── petstore-simple.yaml │ │ │ ├── petstore-with-external-docs.yaml │ │ │ ├── petstore.yaml │ │ │ └── uber.yaml │ │ └── v3.0/ │ │ ├── api-with-examples.yaml │ │ ├── callback-example.yaml │ │ ├── link-example.yaml │ │ ├── petstore-expanded.yaml │ │ ├── petstore.yaml │ │ └── uspto.yaml │ ├── log4j2-test.xml │ ├── no-model.yaml │ ├── swagger.yaml │ └── with-model.yaml ├── common/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ └── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── common/ │ │ ├── ClassMaker.java │ │ ├── CompareAlgorithm.java │ │ ├── ComparisionType.java │ │ ├── Comparison.java │ │ ├── ContractComparator.java │ │ ├── ContractFileType.java │ │ ├── DocumentType.java │ │ ├── FileUtils.java │ │ ├── ImmediateClassLoader.java │ │ ├── MyersAlgorithm.java │ │ ├── SourceType.java │ │ └── SplitDiffFormatter.java │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── common/ │ │ ├── ClassMakerTest.java │ │ ├── FileUtilsTest.java │ │ └── TextCompareTest.java │ └── resources/ │ ├── compare/ │ │ ├── HelloEndPoint.yaml │ │ └── HelloEndPoint2.yaml │ └── projects/ │ ├── demo-with-correct-pom/ │ │ └── pom.xml │ └── demo-with-invaild-pom/ │ └── pom.xml ├── contractgen/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── contractgen/ │ │ │ └── DefaultContractsGenerator.java │ │ └── resources/ │ │ └── META-INF/ │ │ └── services/ │ │ └── org.apache.servicecomb.toolkit.ContractsGenerator │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── contractgen/ │ │ ├── ContractTestUtil.java │ │ └── DefaultContractsGeneratorTest.java │ ├── projects/ │ │ └── demo/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── java/ │ │ └── demo/ │ │ ├── Application.java │ │ └── HelloEndPoint.java │ └── resources/ │ └── log4j2-test.xml ├── core/ │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── org/ │ └── apache/ │ └── servicecomb/ │ └── toolkit/ │ ├── CodeGenerator.java │ ├── ContractsGenerator.java │ ├── DocGenerator.java │ ├── Generator.java │ └── GeneratorFactory.java ├── docgen/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── docgen/ │ │ │ └── ContractsSwaggerUIGenerator.java │ │ └── resources/ │ │ ├── META-INF/ │ │ │ └── services/ │ │ │ └── org.apache.servicecomb.toolkit.DocGenerator │ │ └── webroot/ │ │ └── swagger-ui.html │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── docgen/ │ │ └── ContractsSwaggerUIGeneratorTest.java │ └── resources/ │ └── HelloEndPoint.yaml ├── integration-tests/ │ ├── coverage-aggregate/ │ │ └── pom.xml │ └── pom.xml ├── oas-generator/ │ ├── oas-generator-core/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ └── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── generator/ │ │ │ ├── HttpStatuses.java │ │ │ ├── MediaTypes.java │ │ │ ├── annotation/ │ │ │ │ ├── AnnotationProcessor.java │ │ │ │ ├── ApiResponseMethodAnnotationProcessor.java │ │ │ │ ├── ApiResponsesMethodAnnotationProcessor.java │ │ │ │ ├── ClassAnnotationProcessor.java │ │ │ │ ├── MethodAnnotationProcessor.java │ │ │ │ ├── ModelInterceptor.java │ │ │ │ ├── OpenApiDefinitionClassAnnotationProcessor.java │ │ │ │ ├── OperationMethodAnnotationProcessor.java │ │ │ │ ├── ParamAnnotationProcessor.java │ │ │ │ ├── ParameterAnnotationProcessor.java │ │ │ │ └── RequestBodyParamAnnotationProcessor.java │ │ │ ├── context/ │ │ │ │ ├── Context.java │ │ │ │ ├── IExtensionsContext.java │ │ │ │ ├── ISchemaContext.java │ │ │ │ ├── OasContext.java │ │ │ │ ├── OasGenerator.java │ │ │ │ ├── OperationContext.java │ │ │ │ └── ParameterContext.java │ │ │ ├── parser/ │ │ │ │ ├── AbstractAnnotationParser.java │ │ │ │ └── api/ │ │ │ │ └── OpenApiAnnotationParser.java │ │ │ └── util/ │ │ │ ├── ArrayModelConverter.java │ │ │ ├── LocalVariableVisitor.java │ │ │ ├── ModelConverter.java │ │ │ ├── ParamUtils.java │ │ │ ├── RequestResponse.java │ │ │ └── SwaggerAnnotationUtils.java │ │ └── test/ │ │ └── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── generator/ │ │ ├── AnnotationProcessorTest.java │ │ ├── ContextTest.java │ │ ├── OasGeneratorTest.java │ │ ├── ParserTest.java │ │ └── UtilsTest.java │ ├── oas-generator-jaxrs/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── org/ │ │ │ │ └── apache/ │ │ │ │ └── servicecomb/ │ │ │ │ └── toolkit/ │ │ │ │ └── generator/ │ │ │ │ ├── annotation/ │ │ │ │ │ ├── ConsumesAnnotationProcessor.java │ │ │ │ │ ├── CookieParamAnnotationProcessor.java │ │ │ │ │ ├── FormParamAnnotationProcessor.java │ │ │ │ │ ├── HeaderParamAnnotationProcessor.java │ │ │ │ │ ├── HttpMethodAnnotationProcessor.java │ │ │ │ │ ├── PathClassAnnotationProcessor.java │ │ │ │ │ ├── PathMethodAnnotationProcessor.java │ │ │ │ │ ├── PathParamAnnotationProcessor.java │ │ │ │ │ └── QueryParamAnnotationProcessor.java │ │ │ │ └── parser/ │ │ │ │ └── JaxRsAnnotationParser.java │ │ │ └── resources/ │ │ │ └── META-INF/ │ │ │ └── services/ │ │ │ └── org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser │ │ └── test/ │ │ └── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── generator/ │ │ ├── JaxrsAnnotationProcessorTest.java │ │ └── JaxrsParserTest.java │ ├── oas-generator-servicecomb/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── org/ │ │ │ │ └── apache/ │ │ │ │ └── servicecomb/ │ │ │ │ └── toolkit/ │ │ │ │ └── generator/ │ │ │ │ └── parser/ │ │ │ │ ├── ServicecombJaxrsParser.java │ │ │ │ ├── ServicecombPojoParser.java │ │ │ │ └── ServicecombSpringmvcParser.java │ │ │ └── resources/ │ │ │ └── META-INF/ │ │ │ └── services/ │ │ │ └── org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser │ │ └── test/ │ │ └── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── generator/ │ │ └── ServiceCombParserTest.java │ ├── oas-generator-spring/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── org/ │ │ │ │ └── apache/ │ │ │ │ └── servicecomb/ │ │ │ │ └── toolkit/ │ │ │ │ └── generator/ │ │ │ │ ├── MultipartFileInterceptor.java │ │ │ │ ├── annotation/ │ │ │ │ │ ├── AbstractHttpMethodMappingAnnotationProcessor.java │ │ │ │ │ ├── DeleteMappingMethodAnnotationProcessor.java │ │ │ │ │ ├── GetMappingMethodAnnotationProcessor.java │ │ │ │ │ ├── PathVariableAnnotationProcessor.java │ │ │ │ │ ├── PostMappingMethodAnnotationProcessor.java │ │ │ │ │ ├── PutMappingMethodAnnotationProcessor.java │ │ │ │ │ ├── RequestBodyAnnotationProcessor.java │ │ │ │ │ ├── RequestHeaderAnnotationProcessor.java │ │ │ │ │ ├── RequestMappingClassAnnotationProcessor.java │ │ │ │ │ ├── RequestMappingMethodAnnotationProcessor.java │ │ │ │ │ ├── RequestParamAnnotationProcessor.java │ │ │ │ │ └── RequestPartAnnotationProcessor.java │ │ │ │ └── parser/ │ │ │ │ └── SpringmvcAnnotationParser.java │ │ │ └── resources/ │ │ │ └── META-INF/ │ │ │ └── services/ │ │ │ ├── org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor │ │ │ └── org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser │ │ └── test/ │ │ └── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── generator/ │ │ ├── SpringAnnotationProcessorTest.java │ │ └── SpringParserTest.java │ └── pom.xml ├── oas-validator/ │ ├── .gitignore │ ├── README-ZH.md │ ├── README.md │ ├── doc/ │ │ ├── INSTALLATION.MD │ │ └── USAGE.MD │ ├── oas-validator-compatibility/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ └── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ └── compatibility/ │ │ │ ├── CompatibilityCheckParser.java │ │ │ ├── factory/ │ │ │ │ ├── DefaultCallbackDiffValidatorFactory.java │ │ │ │ ├── DefaultComponentsDiffValidatorFactory.java │ │ │ │ ├── DefaultEncodingDiffValidatorFactory.java │ │ │ │ ├── DefaultHeaderDiffValidatorFactory.java │ │ │ │ ├── DefaultInfoDiffValidatorFactory.java │ │ │ │ ├── DefaultLinkDiffValidatorFactory.java │ │ │ │ ├── DefaultMediaTypeDiffValidatorFactory.java │ │ │ │ ├── DefaultOasSpecDiffValidatorFactory.java │ │ │ │ ├── DefaultOpenApiDiffValidatorFactory.java │ │ │ │ ├── DefaultOperationDiffValidatorFactory.java │ │ │ │ ├── DefaultParameterDiffValidatorFactory.java │ │ │ │ ├── DefaultPathItemDiffValidatorFactory.java │ │ │ │ ├── DefaultPathsDiffValidatorFactory.java │ │ │ │ ├── DefaultRequestBodyDiffValidatorFactory.java │ │ │ │ ├── DefaultResponseDiffValidatorFactory.java │ │ │ │ ├── DefaultResponsesDiffValidatorFactory.java │ │ │ │ ├── DefaultSchemaDiffValidatorFactory.java │ │ │ │ ├── DefaultSecuritySchemeDiffValidatorFactory.java │ │ │ │ ├── DefaultServerDiffValidatorFactory.java │ │ │ │ └── DefaultTagDiffValidatorFactory.java │ │ │ └── validators/ │ │ │ ├── encoding/ │ │ │ │ ├── EncodingAddNotAllowedDiffValidator.java │ │ │ │ ├── EncodingAllowedReservedChangeDiffValidator.java │ │ │ │ ├── EncodingContentTypeNotSameDiffValidator.java │ │ │ │ ├── EncodingDelNotAllowedDiffValidator.java │ │ │ │ ├── EncodingExplodeNotSameDiffValidator.java │ │ │ │ └── EncodingStyleNotSameDiffValidator.java │ │ │ ├── header/ │ │ │ │ ├── HeaderAddInRequestBodyNotAllowedDiffValidator.java │ │ │ │ └── HeaderDelInResponseNotAllowedDiffValidator.java │ │ │ ├── mediatype/ │ │ │ │ ├── MediaTypeAddInParameterNotAllowedDiffValidator.java │ │ │ │ ├── MediaTypeDelInParameterNotAllowedDiffValidator.java │ │ │ │ ├── MediaTypeDelInRequestBodyNotAllowedDiffValidator.java │ │ │ │ └── MediaTypeDelInResponseNotAllowedDiffValidator.java │ │ │ ├── operation/ │ │ │ │ ├── OperationDeleteNotAllowedDiffValidator.java │ │ │ │ └── OperationIdNotSameDiffValidator.java │ │ │ ├── parameter/ │ │ │ │ ├── ParameterAddDiffValidator.java │ │ │ │ ├── ParameterAllowEmptyValueChangeDiffValidator.java │ │ │ │ ├── ParameterAllowReservedChangeDiffValidator.java │ │ │ │ ├── ParameterExplodeNotSameDiffValidator.java │ │ │ │ ├── ParameterRequiredChangeDiffValidator.java │ │ │ │ └── ParameterStyleNotSameDiffValidator.java │ │ │ ├── pathitem/ │ │ │ │ └── PathItemDeleteNotAllowedDiffValidator.java │ │ │ ├── requestbody/ │ │ │ │ └── RequestBodyRequiredChangeDiffValidator.java │ │ │ ├── response/ │ │ │ │ └── ResponseAddNotAllowedDiffValidator.java │ │ │ └── schema/ │ │ │ ├── SchemaDiscriminatorChangeValidator.java │ │ │ ├── SchemaPropertyChangeValidator.java │ │ │ ├── SchemaReadOnlyChangeValidator.java │ │ │ ├── SchemaTypeFormatChangeValidator.java │ │ │ ├── SchemaWriteOnlyChangeValidator.java │ │ │ ├── SchemaXmlChangeValidator.java │ │ │ ├── TypeFormat.java │ │ │ ├── request/ │ │ │ │ ├── SchemaEnumChangeInRequestValidator.java │ │ │ │ ├── SchemaExclusiveMaximumChangeInRequestValidator.java │ │ │ │ ├── SchemaExclusiveMinimumChangeInRequestValidator.java │ │ │ │ ├── SchemaMaxItemsChangeInRequestValidator.java │ │ │ │ ├── SchemaMaxLengthChangeInRequestValidator.java │ │ │ │ ├── SchemaMaxPropertiesChangeInRequestValidator.java │ │ │ │ ├── SchemaMaximumChangeInRequestValidator.java │ │ │ │ ├── SchemaMinItemsChangeInRequestValidator.java │ │ │ │ ├── SchemaMinLengthChangeInRequestValidator.java │ │ │ │ ├── SchemaMinPropertiesChangeInRequestValidator.java │ │ │ │ ├── SchemaMinimumChangeInRequestValidator.java │ │ │ │ ├── SchemaMultipleOfChangeInRequestValidator.java │ │ │ │ ├── SchemaNullableChangeInRequestValidator.java │ │ │ │ ├── SchemaRequiredChangeInRequestValidator.java │ │ │ │ ├── SchemaTypeFormatChangeInRequestValidator.java │ │ │ │ └── SchemaUniqueItemsChangeInRequestValidator.java │ │ │ └── response/ │ │ │ ├── SchemaEnumChangeInResponseValidator.java │ │ │ ├── SchemaExclusiveMaximumChangeInResponseValidator.java │ │ │ ├── SchemaExclusiveMinimumChangeInResponseValidator.java │ │ │ ├── SchemaMaxItemsChangeInResponseValidator.java │ │ │ ├── SchemaMaxLengthChangeInResponseValidator.java │ │ │ ├── SchemaMaxPropertiesChangeInResponseValidator.java │ │ │ ├── SchemaMaximumChangeInResponseValidator.java │ │ │ ├── SchemaMinItemsChangeInResponseValidator.java │ │ │ ├── SchemaMinLengthChangeInResponseValidator.java │ │ │ ├── SchemaMinPropertiesChangeInResponseValidator.java │ │ │ ├── SchemaMinimumChangeInResponseValidator.java │ │ │ ├── SchemaMultipleOfChangeInResponseValidator.java │ │ │ ├── SchemaNullableChangeInResponseValidator.java │ │ │ ├── SchemaRequiredChangeInResponseValidator.java │ │ │ ├── SchemaTypeFormatChangeInResponseValidator.java │ │ │ └── SchemaUniqueItemsChangeInResponseValidator.java │ │ └── test/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ └── compatibility/ │ │ │ ├── CompatibilityCheckParserTest.java │ │ │ ├── factory/ │ │ │ │ ├── DefaultCallbackDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultComponentsDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultEncodingDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultInfoDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultLinkDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultMediaTypeDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultOasSpecDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultOpenApiDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultOperationDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultParameterDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultPathItemDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultPathsDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultRequestBodyDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultResponseDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultResponsesDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultSchemaDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultSecuritySchemeDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultServerDiffValidatorFactoryTest.java │ │ │ │ ├── DefaultTagDiffValidatorFactoryTest.java │ │ │ │ └── DiffValidatorFactoryTestConfiguration.java │ │ │ └── validators/ │ │ │ ├── OasCompatibilityTestBase.java │ │ │ ├── encoding/ │ │ │ │ ├── EncodingAddNotAllowedDiffValidatorTest.java │ │ │ │ ├── EncodingAllowedReservedChangeDiffValidatorTest.java │ │ │ │ ├── EncodingContentTypeNotSameDiffValidatorTest.java │ │ │ │ ├── EncodingDelNotAllowedDiffValidatorTest.java │ │ │ │ ├── EncodingExplodeNotSameDiffValidatorTest.java │ │ │ │ └── EncodingStyleNotSameDiffValidatorTest.java │ │ │ ├── header/ │ │ │ │ ├── HeaderAddInRequestBodyNotAllowedDiffValidatorTest.java │ │ │ │ └── HeaderDelInResponseNotAllowedDiffValidatorTest.java │ │ │ ├── mediatype/ │ │ │ │ ├── MediaTypeAddInParameterNotAllowedDiffValidatorTest.java │ │ │ │ ├── MediaTypeDelInParameterNotAllowedDiffValidatorTest.java │ │ │ │ ├── MediaTypeDelInRequestBodyNotAllowedDiffValidatorTest.java │ │ │ │ └── MediaTypeDelInResponseNotAllowedDiffValidatorTest.java │ │ │ ├── operation/ │ │ │ │ ├── OperationDeleteNotAllowedDiffValidatorTest.java │ │ │ │ └── OperationIdNotSameDiffValidatorTest.java │ │ │ ├── parameter/ │ │ │ │ ├── ParameterAddDiffValidatorTest.java │ │ │ │ ├── ParameterAllowEmptyValueChangeDiffValidatorTest.java │ │ │ │ ├── ParameterAllowReservedChangeDiffValidatorTest.java │ │ │ │ ├── ParameterExplodeNotSameDiffValidatorTest.java │ │ │ │ ├── ParameterRequiredChangeDiffValidatorTest.java │ │ │ │ └── ParameterStyleNotSameDiffValidatorTest.java │ │ │ ├── pathitem/ │ │ │ │ └── PathItemDeleteNotAllowedDiffValidatorTest.java │ │ │ ├── requestbody/ │ │ │ │ └── RequestBodyRequiredChangeDiffValidatorTest.java │ │ │ ├── response/ │ │ │ │ └── ResponseAddNotAllowedDiffValidatorTest.java │ │ │ └── schema/ │ │ │ ├── SchemaDiscriminatorChangeValidatorTest.java │ │ │ ├── SchemaReadOnlyChangeValidatorTest.java │ │ │ ├── SchemaWriteOnlyChangeValidatorTest.java │ │ │ ├── SchemaXmlChangeValidatorTest.java │ │ │ ├── request/ │ │ │ │ ├── SchemaEnumChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaExclusiveMaximumChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaExclusiveMinimumChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMaxItemsChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMaxLengthChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMaxPropertiesChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMaximumChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMinItemsChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMinLengthChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMinPropertiesChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMinimumChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaMultipleOfChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaNullableChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaRequiredChangeInRequestValidatorTest.java │ │ │ │ ├── SchemaTypeFormatChangeInRequestValidatorTest.java │ │ │ │ └── SchemaUniqueItemsChangeInRequestValidatorTest.java │ │ │ └── response/ │ │ │ ├── SchemaEnumChangeInResponseValidatorTest.java │ │ │ ├── SchemaExclusiveMaximumChangeInResponseValidatorTest.java │ │ │ ├── SchemaExclusiveMinimumChangeInResponseValidatorTest.java │ │ │ ├── SchemaMaxItemsChangeInResponseValidatorTest.java │ │ │ ├── SchemaMaxLengthChangeInResponseValidatorTest.java │ │ │ ├── SchemaMaxPropertiesChangeInResponseValidatorTest.java │ │ │ ├── SchemaMaximumChangeInResponseValidatorTest.java │ │ │ ├── SchemaMinItemsChangeInResponseValidatorTest.java │ │ │ ├── SchemaMinLengthChangeInResponseValidatorTest.java │ │ │ ├── SchemaMinPropertiesChangeInResponseValidatorTest.java │ │ │ ├── SchemaMinimumChangeInResponseValidatorTest.java │ │ │ ├── SchemaMultipleOfChangeInResponseValidatorTest.java │ │ │ ├── SchemaNullableChangeInResponseValidatorTest.java │ │ │ ├── SchemaRequiredChangeInResponseValidatorTest.java │ │ │ ├── SchemaTypeFormatChangeInResponseValidatorTest.java │ │ │ └── SchemaUniqueItemsChangeInResponseValidatorTest.java │ │ └── resources/ │ │ ├── logback-test.xml │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── oasv/ │ │ └── compatibility/ │ │ ├── parser-test.yaml │ │ └── validators/ │ │ ├── encoding/ │ │ │ ├── petstore-encoding-add-a.yaml │ │ │ ├── petstore-encoding-add-b.yaml │ │ │ ├── petstore-encoding-allow-reserved-a.yaml │ │ │ ├── petstore-encoding-allow-reserved-b.yaml │ │ │ ├── petstore-encoding-content-type-a.yaml │ │ │ ├── petstore-encoding-content-type-b.yaml │ │ │ ├── petstore-encoding-del-a.yaml │ │ │ ├── petstore-encoding-del-b.yaml │ │ │ ├── petstore-encoding-explode-a.yaml │ │ │ ├── petstore-encoding-explode-b.yaml │ │ │ ├── petstore-encoding-style-a.yaml │ │ │ └── petstore-encoding-style-b.yaml │ │ ├── header/ │ │ │ ├── petstore-header-add-in-request-body-a.yaml │ │ │ ├── petstore-header-add-in-request-body-b.yaml │ │ │ ├── petstore-header-del-in-response-a.yaml │ │ │ └── petstore-header-del-in-response-b.yaml │ │ ├── mediatype/ │ │ │ ├── petstore-media-type-add-in-parameter-a.yaml │ │ │ ├── petstore-media-type-add-in-parameter-b.yaml │ │ │ ├── petstore-media-type-del-in-parameter-a.yaml │ │ │ ├── petstore-media-type-del-in-parameter-b.yaml │ │ │ ├── petstore-media-type-del-in-request-body-a.yaml │ │ │ ├── petstore-media-type-del-in-request-body-b.yaml │ │ │ ├── petstore-media-type-del-in-response-a.yaml │ │ │ └── petstore-media-type-del-in-response-b.yaml │ │ ├── operation/ │ │ │ ├── petstore-operation-delete-a.yaml │ │ │ ├── petstore-operation-delete-b.yaml │ │ │ ├── petstore-operation-id-a.yaml │ │ │ └── petstore-operation-id-b.yaml │ │ ├── parameter/ │ │ │ ├── petstore-parameter-add-a.yaml │ │ │ ├── petstore-parameter-add-b.yaml │ │ │ ├── petstore-parameter-allow-empty-value-a.yaml │ │ │ ├── petstore-parameter-allow-empty-value-b.yaml │ │ │ ├── petstore-parameter-allow-reserved-a.yaml │ │ │ ├── petstore-parameter-allow-reserved-b.yaml │ │ │ ├── petstore-parameter-explode-a.yaml │ │ │ ├── petstore-parameter-explode-b.yaml │ │ │ ├── petstore-parameter-required-a.yaml │ │ │ ├── petstore-parameter-required-b.yaml │ │ │ ├── petstore-parameter-style-a.yaml │ │ │ └── petstore-parameter-style-b.yaml │ │ ├── pathitem/ │ │ │ ├── petstore-path-item-delete-a.yaml │ │ │ └── petstore-path-item-delete-b.yaml │ │ ├── requestbody/ │ │ │ ├── petstore-request-body-required-a.yaml │ │ │ └── petstore-request-body-required-b.yaml │ │ ├── response/ │ │ │ ├── petstore-response-add-a.yaml │ │ │ └── petstore-response-add-b.yaml │ │ └── schema/ │ │ ├── petstore-schema-discriminator-a.yaml │ │ ├── petstore-schema-discriminator-b.yaml │ │ ├── petstore-schema-read-only-a.yaml │ │ ├── petstore-schema-read-only-b.yaml │ │ ├── petstore-schema-write-only-a.yaml │ │ ├── petstore-schema-write-only-b.yaml │ │ ├── petstore-schema-xml-a.yaml │ │ ├── petstore-schema-xml-b.yaml │ │ ├── request/ │ │ │ ├── petstore-schema-enum-in-request-a.yaml │ │ │ ├── petstore-schema-enum-in-request-b.yaml │ │ │ ├── petstore-schema-exclusive-maximum-in-request-a.yaml │ │ │ ├── petstore-schema-exclusive-maximum-in-request-b.yaml │ │ │ ├── petstore-schema-exclusive-minimum-in-request-a.yaml │ │ │ ├── petstore-schema-exclusive-minimum-in-request-b.yaml │ │ │ ├── petstore-schema-max-items-in-request-a.yaml │ │ │ ├── petstore-schema-max-items-in-request-b.yaml │ │ │ ├── petstore-schema-max-length-in-request-a.yaml │ │ │ ├── petstore-schema-max-length-in-request-b.yaml │ │ │ ├── petstore-schema-max-properties-in-request-a.yaml │ │ │ ├── petstore-schema-max-properties-in-request-b.yaml │ │ │ ├── petstore-schema-maximum-in-request-a.yaml │ │ │ ├── petstore-schema-maximum-in-request-b.yaml │ │ │ ├── petstore-schema-min-items-in-request-a.yaml │ │ │ ├── petstore-schema-min-items-in-request-b.yaml │ │ │ ├── petstore-schema-min-length-in-request-a.yaml │ │ │ ├── petstore-schema-min-length-in-request-b.yaml │ │ │ ├── petstore-schema-min-properties-in-request-a.yaml │ │ │ ├── petstore-schema-min-properties-in-request-b.yaml │ │ │ ├── petstore-schema-minimum-in-request-a.yaml │ │ │ ├── petstore-schema-minimum-in-request-b.yaml │ │ │ ├── petstore-schema-multiple-of-in-request-a.yaml │ │ │ ├── petstore-schema-multiple-of-in-request-b.yaml │ │ │ ├── petstore-schema-nullable-in-request-a.yaml │ │ │ ├── petstore-schema-nullable-in-request-b.yaml │ │ │ ├── petstore-schema-required-in-request-a.yaml │ │ │ ├── petstore-schema-required-in-request-b.yaml │ │ │ ├── petstore-schema-type-format-in-request-a.yaml │ │ │ ├── petstore-schema-type-format-in-request-b.yaml │ │ │ ├── petstore-schema-unique-items-in-request-a.yaml │ │ │ └── petstore-schema-unique-items-in-request-b.yaml │ │ └── response/ │ │ ├── petstore-schema-enum-in-response-a.yaml │ │ ├── petstore-schema-enum-in-response-b.yaml │ │ ├── petstore-schema-exclusive-maximum-in-response-a.yaml │ │ ├── petstore-schema-exclusive-maximum-in-response-b.yaml │ │ ├── petstore-schema-exclusive-minimum-in-response-a.yaml │ │ ├── petstore-schema-exclusive-minimum-in-response-b.yaml │ │ ├── petstore-schema-max-items-in-response-a.yaml │ │ ├── petstore-schema-max-items-in-response-b.yaml │ │ ├── petstore-schema-max-length-in-response-a.yaml │ │ ├── petstore-schema-max-length-in-response-b.yaml │ │ ├── petstore-schema-max-properties-in-response-a.yaml │ │ ├── petstore-schema-max-properties-in-response-b.yaml │ │ ├── petstore-schema-maximum-in-response-a.yaml │ │ ├── petstore-schema-maximum-in-response-b.yaml │ │ ├── petstore-schema-min-items-in-response-a.yaml │ │ ├── petstore-schema-min-items-in-response-b.yaml │ │ ├── petstore-schema-min-length-in-response-a.yaml │ │ ├── petstore-schema-min-length-in-response-b.yaml │ │ ├── petstore-schema-min-properties-in-response-a.yaml │ │ ├── petstore-schema-min-properties-in-response-b.yaml │ │ ├── petstore-schema-minimum-in-response-a.yaml │ │ ├── petstore-schema-minimum-in-response-b.yaml │ │ ├── petstore-schema-multiple-of-in-response-a.yaml │ │ ├── petstore-schema-multiple-of-in-response-b.yaml │ │ ├── petstore-schema-nullable-in-response-a.yaml │ │ ├── petstore-schema-nullable-in-response-b.yaml │ │ ├── petstore-schema-required-in-response-a.yaml │ │ ├── petstore-schema-required-in-response-b.yaml │ │ ├── petstore-schema-type-format-in-response-a.yaml │ │ ├── petstore-schema-type-format-in-response-b.yaml │ │ ├── petstore-schema-unique-items-in-response-a.yaml │ │ └── petstore-schema-unique-items-in-response-b.yaml │ ├── oas-validator-compatibility-spring/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ ├── java/ │ │ │ │ └── org/ │ │ │ │ └── apache/ │ │ │ │ └── servicecomb/ │ │ │ │ └── toolkit/ │ │ │ │ └── oasv/ │ │ │ │ └── compatibility/ │ │ │ │ └── config/ │ │ │ │ ├── EncodingDiffValidatorsConfiguration.java │ │ │ │ ├── HeaderDiffValidatorsConfiguration.java │ │ │ │ ├── MediaTypeDiffValidatorsConfiguration.java │ │ │ │ ├── OperationDiffValidatorsConfiguration.java │ │ │ │ ├── ParameterDiffValidatorsConfiguration.java │ │ │ │ ├── PathItemDiffValidatorsConfiguration.java │ │ │ │ ├── RequestBodyDiffValidatorsConfiguration.java │ │ │ │ ├── ResponseDiffValidatorsConfiguration.java │ │ │ │ └── SchemaDiffValidatorsConfiguration.java │ │ │ └── resources/ │ │ │ └── META-INF/ │ │ │ └── spring.factories │ │ └── test/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ └── compatibility/ │ │ │ └── config/ │ │ │ └── ValidatorConfigurationsTest.java │ │ └── resources/ │ │ └── logback-test.xml │ ├── oas-validator-core/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ └── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ ├── FactoryOptions.java │ │ │ ├── common/ │ │ │ │ ├── OasObjectProperty.java │ │ │ │ ├── OasObjectPropertyLocation.java │ │ │ │ └── OasObjectType.java │ │ │ ├── diffvalidation/ │ │ │ │ ├── api/ │ │ │ │ │ ├── CallbackDiffValidator.java │ │ │ │ │ ├── ComponentsDiffValidator.java │ │ │ │ │ ├── DefaultOasSpecDiffValidator.java │ │ │ │ │ ├── DiffViolationMessages.java │ │ │ │ │ ├── EncodingDiffValidator.java │ │ │ │ │ ├── HeaderDiffValidator.java │ │ │ │ │ ├── InfoDiffValidator.java │ │ │ │ │ ├── LinkDiffValidator.java │ │ │ │ │ ├── ListPropertyDiffValidator.java │ │ │ │ │ ├── MapPropertyDiffValidator.java │ │ │ │ │ ├── MediaTypeDiffValidator.java │ │ │ │ │ ├── OasDiffValidationContext.java │ │ │ │ │ ├── OasDiffValidationException.java │ │ │ │ │ ├── OasDiffViolation.java │ │ │ │ │ ├── OasObjectDiffValidator.java │ │ │ │ │ ├── OasObjectDiffValidatorTemplate.java │ │ │ │ │ ├── OasSpecDiffValidator.java │ │ │ │ │ ├── ObjectPropertyDiffValidator.java │ │ │ │ │ ├── OpenApiDiffValidator.java │ │ │ │ │ ├── OperationDiffValidator.java │ │ │ │ │ ├── ParameterDiffValidator.java │ │ │ │ │ ├── PathItemDiffValidator.java │ │ │ │ │ ├── PathsDiffValidator.java │ │ │ │ │ ├── RequestBodyDiffValidator.java │ │ │ │ │ ├── ResponseDiffValidator.java │ │ │ │ │ ├── ResponsesDiffValidator.java │ │ │ │ │ ├── SchemaAddValidator.java │ │ │ │ │ ├── SchemaCompareValidator.java │ │ │ │ │ ├── SchemaDelValidator.java │ │ │ │ │ ├── SchemaDiffValidator.java │ │ │ │ │ ├── SecuritySchemeDiffValidator.java │ │ │ │ │ ├── ServerDiffValidator.java │ │ │ │ │ └── TagDiffValidator.java │ │ │ │ ├── factory/ │ │ │ │ │ ├── CallbackDiffValidatorFactory.java │ │ │ │ │ ├── ComponentsDiffValidatorFactory.java │ │ │ │ │ ├── EncodingDiffValidatorFactory.java │ │ │ │ │ ├── HeaderDiffValidatorFactory.java │ │ │ │ │ ├── InfoDiffValidatorFactory.java │ │ │ │ │ ├── LinkDiffValidatorFactory.java │ │ │ │ │ ├── MediaTypeDiffValidatorFactory.java │ │ │ │ │ ├── OasObjectDiffValidatorFactory.java │ │ │ │ │ ├── OasSpecDiffValidatorFactory.java │ │ │ │ │ ├── OpenApiDiffValidatorFactory.java │ │ │ │ │ ├── OperationDiffValidatorFactory.java │ │ │ │ │ ├── ParameterDiffValidatorFactory.java │ │ │ │ │ ├── PathItemDiffValidatorFactory.java │ │ │ │ │ ├── PathsDiffValidatorFactory.java │ │ │ │ │ ├── RequestBodyDiffValidatorFactory.java │ │ │ │ │ ├── ResponseDiffValidatorFactory.java │ │ │ │ │ ├── ResponsesDiffValidatorFactory.java │ │ │ │ │ ├── SchemaDiffValidatorFactory.java │ │ │ │ │ ├── SecuritySchemeDiffValidatorFactory.java │ │ │ │ │ ├── ServerDiffValidatorFactory.java │ │ │ │ │ └── TagDiffValidatorFactory.java │ │ │ │ ├── skeleton/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── ComponentsCallbacksDiffValidator.java │ │ │ │ │ │ ├── ComponentsHeadersDiffValidator.java │ │ │ │ │ │ ├── ComponentsLinksDiffValidator.java │ │ │ │ │ │ ├── ComponentsParametersDiffValidator.java │ │ │ │ │ │ ├── ComponentsRequestBodiesDiffValidator.java │ │ │ │ │ │ └── ComponentsResponsesDiffValidator.java │ │ │ │ │ ├── encoding/ │ │ │ │ │ │ └── EncodingHeadersDiffValidator.java │ │ │ │ │ ├── header/ │ │ │ │ │ │ └── HeaderSchemaDiffValidator.java │ │ │ │ │ ├── mediatype/ │ │ │ │ │ │ ├── MediaTypeEncodingDiffValidator.java │ │ │ │ │ │ └── MediaTypeSchemaDiffValidator.java │ │ │ │ │ ├── openapi/ │ │ │ │ │ │ ├── OpenApiComponentsDiffValidator.java │ │ │ │ │ │ ├── OpenApiInfoDiffValidator.java │ │ │ │ │ │ ├── OpenApiPathsDiffValidator.java │ │ │ │ │ │ ├── OpenApiServersDiffValidator.java │ │ │ │ │ │ └── OpenApiTagsDiffValidator.java │ │ │ │ │ ├── operation/ │ │ │ │ │ │ ├── OperationParametersDiffValidator.java │ │ │ │ │ │ ├── OperationRequestBodyDiffValidator.java │ │ │ │ │ │ └── OperationResponsesDiffValidator.java │ │ │ │ │ ├── parameter/ │ │ │ │ │ │ ├── ParameterContentDiffValidator.java │ │ │ │ │ │ └── ParameterSchemaDiffValidator.java │ │ │ │ │ ├── pathitem/ │ │ │ │ │ │ ├── PathItemOperationsDiffValidator.java │ │ │ │ │ │ └── PathItemParametersDiffValidator.java │ │ │ │ │ ├── paths/ │ │ │ │ │ │ └── PathsPathItemsDiffValidator.java │ │ │ │ │ ├── requestbody/ │ │ │ │ │ │ └── RequestBodyContentDiffValidator.java │ │ │ │ │ ├── response/ │ │ │ │ │ │ ├── ResponseContentDiffValidator.java │ │ │ │ │ │ └── ResponseHeadersDiffValidator.java │ │ │ │ │ ├── responses/ │ │ │ │ │ │ └── ResponsesResponsesDiffValidator.java │ │ │ │ │ └── schema/ │ │ │ │ │ └── SchemaDiffValidatorEngine.java │ │ │ │ └── util/ │ │ │ │ ├── ChangeRangeCheckUtils.java │ │ │ │ ├── OasDiffValidationContextUtils.java │ │ │ │ ├── OasObjectDiffValidatorUtils.java │ │ │ │ └── ParameterUtils.java │ │ │ ├── util/ │ │ │ │ ├── StringCaseUtils.java │ │ │ │ └── SyntaxChecker.java │ │ │ └── validation/ │ │ │ ├── api/ │ │ │ │ ├── CallbackValidator.java │ │ │ │ ├── ComponentsValidator.java │ │ │ │ ├── DefaultOasSpecValidator.java │ │ │ │ ├── EncodingValidator.java │ │ │ │ ├── ExampleValidator.java │ │ │ │ ├── HeaderValidator.java │ │ │ │ ├── InfoValidator.java │ │ │ │ ├── LinkValidator.java │ │ │ │ ├── ListPropertyRequiredValidator.java │ │ │ │ ├── ListPropertyValidator.java │ │ │ │ ├── MapPropertyKeysValidator.java │ │ │ │ ├── MapPropertyValuesValidator.java │ │ │ │ ├── MediaTypeValidator.java │ │ │ │ ├── OasObjectValidator.java │ │ │ │ ├── OasSpecValidator.java │ │ │ │ ├── OasValidationContext.java │ │ │ │ ├── OasViolation.java │ │ │ │ ├── ObjectPropertyRequiredValidator.java │ │ │ │ ├── ObjectPropertyValidator.java │ │ │ │ ├── OpenApiValidator.java │ │ │ │ ├── OperationValidator.java │ │ │ │ ├── ParameterValidator.java │ │ │ │ ├── PathItemValidator.java │ │ │ │ ├── PathsValidator.java │ │ │ │ ├── RequestBodyValidator.java │ │ │ │ ├── ResponseValidator.java │ │ │ │ ├── ResponsesValidator.java │ │ │ │ ├── SchemaValidator.java │ │ │ │ ├── SecuritySchemeValidator.java │ │ │ │ ├── ServerValidator.java │ │ │ │ ├── TagValidator.java │ │ │ │ └── ViolationMessages.java │ │ │ ├── factory/ │ │ │ │ ├── CallbackValidatorFactory.java │ │ │ │ ├── ComponentsValidatorFactory.java │ │ │ │ ├── EncodingValidatorFactory.java │ │ │ │ ├── ExampleValidatorFactory.java │ │ │ │ ├── HeaderValidatorFactory.java │ │ │ │ ├── InfoValidatorFactory.java │ │ │ │ ├── LinkValidatorFactory.java │ │ │ │ ├── MediaTypeValidatorFactory.java │ │ │ │ ├── OasObjectValidatorFactory.java │ │ │ │ ├── OasSpecValidatorFactory.java │ │ │ │ ├── OpenApiValidatorFactory.java │ │ │ │ ├── OperationValidatorFactory.java │ │ │ │ ├── ParameterValidatorFactory.java │ │ │ │ ├── PathItemValidatorFactory.java │ │ │ │ ├── PathsValidatorFactory.java │ │ │ │ ├── RequestBodyValidatorFactory.java │ │ │ │ ├── ResponseValidatorFactory.java │ │ │ │ ├── ResponsesValidatorFactory.java │ │ │ │ ├── SchemaValidatorFactory.java │ │ │ │ ├── SecuritySchemeValidatorFactory.java │ │ │ │ ├── ServerValidatorFactory.java │ │ │ │ └── TagValidatorFactory.java │ │ │ ├── skeleton/ │ │ │ │ ├── components/ │ │ │ │ │ ├── ComponentsCallbacksKeysValidator.java │ │ │ │ │ ├── ComponentsCallbacksValuesValidator.java │ │ │ │ │ ├── ComponentsExamplesKeysValidator.java │ │ │ │ │ ├── ComponentsExamplesValuesValidator.java │ │ │ │ │ ├── ComponentsHeadersKeysValidator.java │ │ │ │ │ ├── ComponentsHeadersValuesValidator.java │ │ │ │ │ ├── ComponentsLinksKeysValidator.java │ │ │ │ │ ├── ComponentsLinksValuesValidator.java │ │ │ │ │ ├── ComponentsParametersKeysValidator.java │ │ │ │ │ ├── ComponentsParametersValuesValidator.java │ │ │ │ │ ├── ComponentsRequestBodiesKeysValidator.java │ │ │ │ │ ├── ComponentsRequestBodiesValuesValidator.java │ │ │ │ │ ├── ComponentsResponsesKeysValidator.java │ │ │ │ │ ├── ComponentsResponsesValuesValidator.java │ │ │ │ │ ├── ComponentsSchemasKeysValidator.java │ │ │ │ │ ├── ComponentsSchemasValuesValidator.java │ │ │ │ │ ├── ComponentsSecuritySchemesKeysValidator.java │ │ │ │ │ └── ComponentsSecuritySchemesValuesValidator.java │ │ │ │ ├── encoding/ │ │ │ │ │ ├── EncodingHeadersKeysValidator.java │ │ │ │ │ └── EncodingHeadersValuesValidator.java │ │ │ │ ├── header/ │ │ │ │ │ └── HeaderSchemaValidator.java │ │ │ │ ├── mediatype/ │ │ │ │ │ ├── MediaTypeEncodingValidator.java │ │ │ │ │ └── MediaTypeSchemaValidator.java │ │ │ │ ├── openapi/ │ │ │ │ │ ├── OpenApiComponentsValidator.java │ │ │ │ │ ├── OpenApiInfoValidator.java │ │ │ │ │ ├── OpenApiPathsValidator.java │ │ │ │ │ ├── OpenApiServersValidator.java │ │ │ │ │ └── OpenApiTagsValidator.java │ │ │ │ ├── operation/ │ │ │ │ │ ├── OperationParametersValidator.java │ │ │ │ │ ├── OperationRequestBodyValidator.java │ │ │ │ │ └── OperationResponsesValidator.java │ │ │ │ ├── parameter/ │ │ │ │ │ ├── ParameterContentValidator.java │ │ │ │ │ └── ParameterSchemaValidator.java │ │ │ │ ├── pathitem/ │ │ │ │ │ ├── PathItemOperationsValidator.java │ │ │ │ │ └── PathItemParametersValidator.java │ │ │ │ ├── paths/ │ │ │ │ │ └── PathsPathItemsValidator.java │ │ │ │ ├── requestbody/ │ │ │ │ │ └── RequestBodyContentValidator.java │ │ │ │ ├── response/ │ │ │ │ │ ├── ResponseContentValidator.java │ │ │ │ │ ├── ResponseHeadersKeysValidator.java │ │ │ │ │ └── ResponseHeadersValuesValidator.java │ │ │ │ ├── responses/ │ │ │ │ │ └── ResponsesResponsesValidator.java │ │ │ │ └── schema/ │ │ │ │ ├── SchemaPropertiesKeysValidator.java │ │ │ │ └── SchemaRecursiveValidatorTemplate.java │ │ │ └── util/ │ │ │ └── OasObjectValidatorUtils.java │ │ └── test/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ ├── common/ │ │ │ │ └── OasObjectPropertyLocationTest.java │ │ │ └── util/ │ │ │ ├── StringCaseUtilsTest.java │ │ │ └── SyntaxCheckerTest.java │ │ └── resources/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── oasv/ │ │ └── util/ │ │ ├── syntax-bad.yaml │ │ └── syntax-good.yaml │ ├── oas-validator-core-spring/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ └── diffvalidation/ │ │ │ └── config/ │ │ │ └── OasDiffValidatorsSkeletonConfiguration.java │ │ └── resources/ │ │ └── META-INF/ │ │ └── spring.factories │ ├── oas-validator-style/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ └── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ └── style/ │ │ │ ├── StyleCheckParser.java │ │ │ ├── factory/ │ │ │ │ ├── DefaultComponentsValidatorFactory.java │ │ │ │ ├── DefaultEncodingValidatorFactory.java │ │ │ │ ├── DefaultHeaderValidatorFactory.java │ │ │ │ ├── DefaultInfoValidatorFactory.java │ │ │ │ ├── DefaultMediaTypeValidatorFactory.java │ │ │ │ ├── DefaultOasSpecValidatorFactory.java │ │ │ │ ├── DefaultOpenApiValidatorFactory.java │ │ │ │ ├── DefaultOperationValidatorFactory.java │ │ │ │ ├── DefaultParameterValidatorFactory.java │ │ │ │ ├── DefaultPathItemValidatorFactory.java │ │ │ │ ├── DefaultPathsValidatorFactory.java │ │ │ │ ├── DefaultRequestBodyValidatorFactory.java │ │ │ │ ├── DefaultResponseValidatorFactory.java │ │ │ │ ├── DefaultResponsesValidatorFactory.java │ │ │ │ ├── DefaultSchemaValidatorFactory.java │ │ │ │ ├── DefaultSecuritySchemeValidatorFactory.java │ │ │ │ ├── DefaultServerValidatorFactory.java │ │ │ │ ├── DefaultTagValidatorFactory.java │ │ │ │ └── ValidatorFactoryComponents.java │ │ │ └── validator/ │ │ │ ├── components/ │ │ │ │ ├── ComponentsCallbacksKeysCaseValidator.java │ │ │ │ ├── ComponentsExamplesKeysCaseValidator.java │ │ │ │ ├── ComponentsHeadersKeysCaseValidator.java │ │ │ │ ├── ComponentsLinksKeysCaseValidator.java │ │ │ │ ├── ComponentsParametersKeysCaseValidator.java │ │ │ │ ├── ComponentsRequestBodiesKeysCaseValidator.java │ │ │ │ ├── ComponentsResponsesKeysCaseValidator.java │ │ │ │ ├── ComponentsSchemasKeysCaseValidator.java │ │ │ │ └── ComponentsSecuritySchemesKeysCaseValidator.java │ │ │ ├── encoding/ │ │ │ │ └── EncodingHeadersKeysCaseValidator.java │ │ │ ├── header/ │ │ │ │ └── HeaderDescriptionRequiredValidator.java │ │ │ ├── info/ │ │ │ │ └── InfoDescriptionRequiredValidator.java │ │ │ ├── openapi/ │ │ │ │ ├── OpenApiSecuritySizeEqValidator.java │ │ │ │ ├── OpenApiTagsSizeGteValidator.java │ │ │ │ └── OpenApiVersionGteValidator.java │ │ │ ├── operation/ │ │ │ │ ├── OperationIdCaseValidator.java │ │ │ │ ├── OperationServersSizeEqValidator.java │ │ │ │ ├── OperationSummaryRequiredValidator.java │ │ │ │ ├── OperationTagsReferenceValidator.java │ │ │ │ └── OperationTagsSizeEqValidator.java │ │ │ ├── parameter/ │ │ │ │ ├── ParameterDescriptionRequiredValidator.java │ │ │ │ ├── ParameterNameCookieCaseValidator.java │ │ │ │ ├── ParameterNameHeaderCaseValidator.java │ │ │ │ ├── ParameterNamePathCaseValidator.java │ │ │ │ └── ParameterNameQueryCaseValidator.java │ │ │ ├── paths/ │ │ │ │ └── PathsKeyCaseValidator.java │ │ │ ├── requestbody/ │ │ │ │ └── RequestBodyDescriptionRequiredValidator.java │ │ │ ├── response/ │ │ │ │ └── ResponseHeadersKeysCaseValidator.java │ │ │ ├── schema/ │ │ │ │ ├── SchemaPropertiesKeysCaseValidator.java │ │ │ │ └── SchemaTitleRequiredValidator.java │ │ │ └── tag/ │ │ │ ├── TagDescriptionRequiredValidator.java │ │ │ ├── TagMustBeReferencedValidator.java │ │ │ └── TagNameCaseValidator.java │ │ └── test/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ └── style/ │ │ │ ├── StyleCheckParserTest.java │ │ │ ├── factory/ │ │ │ │ ├── DefaultComponentsValidatorFactoryTest.java │ │ │ │ ├── DefaultEncodingValidatorFactoryTest.java │ │ │ │ ├── DefaultHeaderValidatorFactoryTest.java │ │ │ │ ├── DefaultInfoValidatorFactoryTest.java │ │ │ │ ├── DefaultMediaTypeValidatorFactoryTest.java │ │ │ │ ├── DefaultOasSpecValidatorFactoryTest.java │ │ │ │ ├── DefaultOpenApiValidatorFactoryTest.java │ │ │ │ ├── DefaultOperationValidatorFactoryTest.java │ │ │ │ ├── DefaultParameterValidatorFactoryTest.java │ │ │ │ ├── DefaultPathItemValidatorFactoryTest.java │ │ │ │ ├── DefaultPathsValidatorFactoryTest.java │ │ │ │ ├── DefaultRequestBodyValidatorFactoryTest.java │ │ │ │ ├── DefaultResponseValidatorFactoryTest.java │ │ │ │ ├── DefaultResponsesValidatorFactoryTest.java │ │ │ │ ├── DefaultSchemaValidatorFactoryTest.java │ │ │ │ ├── DefaultSecuritySchemeValidatorFactoryTest.java │ │ │ │ ├── DefaultServerValidatorFactoryTest.java │ │ │ │ └── DefaultTagValidatorFactoryTest.java │ │ │ └── validator/ │ │ │ ├── OasStyleCheckTestBase.java │ │ │ ├── components/ │ │ │ │ ├── ComponentsCallbacksKeysCaseValidatorTest.java │ │ │ │ ├── ComponentsExamplesKeysCaseValidatorTest.java │ │ │ │ ├── ComponentsHeadersKeysCaseValidatorTest.java │ │ │ │ ├── ComponentsLinksKeysCaseValidatorTest.java │ │ │ │ ├── ComponentsParametersKeysCaseValidatorTest.java │ │ │ │ ├── ComponentsRequestBodiesKeysCaseValidatorTest.java │ │ │ │ ├── ComponentsResponsesKeysCaseValidatorTest.java │ │ │ │ ├── ComponentsSchemasKeysCaseValidatorTest.java │ │ │ │ └── ComponentsSecuritySchemesKeysCaseValidatorTest.java │ │ │ ├── encoding/ │ │ │ │ └── EncodingHeadersKeysCaseValidatorTest.java │ │ │ ├── header/ │ │ │ │ └── HeaderDescriptionRequiredValidatorTest.java │ │ │ ├── info/ │ │ │ │ └── InfoDescriptionRequiredValidatorTest.java │ │ │ ├── openapi/ │ │ │ │ ├── OpenApiSecuritySizeEqValidatorTest.java │ │ │ │ ├── OpenApiTagsSizeGteValidatorTest.java │ │ │ │ └── OpenApiVersionGteValidatorTest.java │ │ │ ├── operation/ │ │ │ │ ├── OperationIdCaseValidatorTest.java │ │ │ │ ├── OperationServersSizeEqValidatorTest.java │ │ │ │ ├── OperationSummaryRequiredValidatorTest.java │ │ │ │ ├── OperationTagsReferenceValidatorTest.java │ │ │ │ └── OperationTagsSizeEqValidatorTest.java │ │ │ ├── parameter/ │ │ │ │ ├── ParameterDescriptionRequiredValidatorTest.java │ │ │ │ ├── ParameterNameCookieCaseValidatorTest.java │ │ │ │ ├── ParameterNameHeaderCaseValidatorTest.java │ │ │ │ ├── ParameterNamePathCaseValidatorTest.java │ │ │ │ └── ParameterNameQueryCaseValidatorTest.java │ │ │ ├── paths/ │ │ │ │ └── PathsKeyCaseValidatorTest.java │ │ │ ├── requestbody/ │ │ │ │ └── RequestBodyDescriptionRequiredValidatorTest.java │ │ │ ├── response/ │ │ │ │ └── ResponseHeadersKeysCaseValidatorTest.java │ │ │ ├── schema/ │ │ │ │ ├── SchemaPropertiesKeysCaseValidatorTest.java │ │ │ │ └── SchemaTitleRequiredValidatorTest.java │ │ │ └── tag/ │ │ │ ├── TagDescriptionRequiredValidatorTest.java │ │ │ ├── TagMustBeReferencedValidatorTest.java │ │ │ └── TagNameCaseValidatorTest.java │ │ └── resources/ │ │ ├── logback-test.xml │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── oasv/ │ │ └── style/ │ │ ├── parser-test.yaml │ │ └── validator/ │ │ ├── components/ │ │ │ ├── petstore-callbacks-upper-camel-case.yaml │ │ │ ├── petstore-examples-upper-camel-case.yaml │ │ │ ├── petstore-headers-upper-camel-case.yaml │ │ │ ├── petstore-links-upper-camel-case.yaml │ │ │ ├── petstore-parameters-upper-camel-case.yaml │ │ │ ├── petstore-request-bodies-upper-camel-case.yaml │ │ │ ├── petstore-responses-upper-camel-case.yaml │ │ │ ├── petstore-schemas-upper-camel-case.yaml │ │ │ └── petstore-security-schemes-upper-camel-case.yaml │ │ ├── encoding/ │ │ │ ├── petstore-encoding-headers-key-case-1.yaml │ │ │ ├── petstore-encoding-headers-key-case-2.yaml │ │ │ ├── petstore-encoding-headers-key-case-3.yaml │ │ │ └── petstore-encoding-headers-key-case-4.yaml │ │ ├── header/ │ │ │ └── petstore-header-no-desc.yaml │ │ ├── info/ │ │ │ └── petstore-info-no-desc.yaml │ │ ├── openapi/ │ │ │ ├── petstore-openapi-wrong.yaml │ │ │ ├── petstore-security-empty-good.yaml │ │ │ ├── petstore-security-empty.yaml │ │ │ └── petstore-tag-not-provided.yaml │ │ ├── operation/ │ │ │ ├── petstore-operation-id-lower-camel-case.yaml │ │ │ ├── petstore-operation-servers-empty.yaml │ │ │ ├── petstore-operation-summary-required.yaml │ │ │ ├── petstore-operation-tags-only-one.yaml │ │ │ └── petstore-operation-tags-reference.yaml │ │ ├── parameter/ │ │ │ ├── petstore-parameter-cookie-lower-camel-case.yaml │ │ │ ├── petstore-parameter-desc-none.yaml │ │ │ ├── petstore-parameter-header-upper-hyphen-case.yaml │ │ │ ├── petstore-parameter-path-lower-camel-case.yaml │ │ │ └── petstore-parameter-query-lower-camel-case.yaml │ │ ├── paths/ │ │ │ └── petstore-paths-lower-camel-case.yaml │ │ ├── requestbody/ │ │ │ └── petstore-request-body-desc-required.yaml │ │ ├── response/ │ │ │ └── petstore-response-headers-key-case.yaml │ │ ├── schema/ │ │ │ ├── petstore-schema-p-keys-lower-camel-case-all-of.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-any-of.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-array.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-comp.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-nested.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-one-of.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-param-1.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-param-2.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-req-1.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-req-2.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-resp-1.yaml │ │ │ ├── petstore-schema-p-keys-lower-camel-case-resp-2.yaml │ │ │ ├── petstore-schema-title-comp.yaml │ │ │ ├── petstore-schema-title-nested.yaml │ │ │ ├── petstore-schema-title-param.yaml │ │ │ ├── petstore-schema-title-req.yaml │ │ │ └── petstore-schema-title-resp.yaml │ │ └── tag/ │ │ ├── petstore-tag-name-not-upper-camel-case.yaml │ │ ├── petstore-tag-no-desc.yaml │ │ └── petstore-tag-redundant.yaml │ ├── oas-validator-test/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── oasv/ │ │ ├── OasSpecLoader.java │ │ ├── diffvalidation/ │ │ │ └── test/ │ │ │ └── OasDiffValidatorTestBase.java │ │ └── validation/ │ │ └── test/ │ │ └── OasValidatorTestBase.java │ ├── oas-validator-web/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── apache/ │ │ │ └── servicecomb/ │ │ │ └── toolkit/ │ │ │ └── oasv/ │ │ │ └── web/ │ │ │ ├── Application.java │ │ │ ├── api/ │ │ │ │ └── controller/ │ │ │ │ ├── CompatibilityController.java │ │ │ │ ├── ImportError.java │ │ │ │ ├── ImportError2.java │ │ │ │ └── StyleController.java │ │ │ ├── config/ │ │ │ │ └── StyleCheckValidatorsConfiguration.java │ │ │ └── page/ │ │ │ └── controller/ │ │ │ ├── EditorController.java │ │ │ ├── IndexController.java │ │ │ ├── ValidatorController.java │ │ │ └── ViewerController.java │ │ └── resources/ │ │ ├── application.properties │ │ ├── samples/ │ │ │ └── petstore-openapi-wrong.yaml │ │ ├── style-check-rules.properties │ │ └── templates/ │ │ ├── index.html │ │ └── validator/ │ │ ├── compatibility.html │ │ └── style.html │ └── pom.xml ├── pom.xml ├── samples/ │ ├── README-ZH.md │ ├── README.md │ ├── generate-from-code-sample/ │ │ ├── GoodbyeService/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ ├── java/ │ │ │ │ └── org/ │ │ │ │ └── apache/ │ │ │ │ └── servicecomb/ │ │ │ │ └── toolkit/ │ │ │ │ └── goodbye/ │ │ │ │ ├── GoodbyeApplication.java │ │ │ │ └── GoodbyeController.java │ │ │ └── resources/ │ │ │ └── application.yaml │ │ ├── HelloService/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ ├── java/ │ │ │ │ └── org/ │ │ │ │ └── apache/ │ │ │ │ └── servicecomb/ │ │ │ │ └── toolkit/ │ │ │ │ └── hello/ │ │ │ │ ├── HelloApplication.java │ │ │ │ └── HelloController.java │ │ │ └── resources/ │ │ │ └── application.yaml │ │ ├── README-ZH.md │ │ ├── README.md │ │ └── pom.xml │ ├── generate-from-contract-sample/ │ │ ├── README-ZH.md │ │ ├── README.md │ │ ├── contract/ │ │ │ ├── GoodByeService/ │ │ │ │ └── GoodbyeController.yaml │ │ │ └── HelloService/ │ │ │ └── HelloController.yaml │ │ └── pom.xml │ ├── pom.xml │ └── verify-with-code-sample/ │ ├── GreetingService/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── java/ │ │ └── org/ │ │ └── apache/ │ │ └── servicecomb/ │ │ └── toolkit/ │ │ └── goodbye/ │ │ ├── GreetingController.java │ │ └── GreetingService.java │ ├── README-ZH.md │ ├── README.md │ ├── contract/ │ │ └── GreetingService/ │ │ └── GreetingController.yaml │ └── pom.xml ├── scripts/ │ ├── cliTest.sh │ ├── deploy.sh │ └── test.sh ├── toolkit-distribution/ │ ├── pom.xml │ └── src/ │ ├── assembly/ │ │ ├── bin.xml │ │ └── src.xml │ └── release/ │ ├── LICENSE │ ├── NOTICE │ └── licenses/ │ ├── LICENSE-asm │ ├── LICENSE-automaton │ ├── LICENSE-cal10n │ ├── LICENSE-cc0 │ ├── LICENSE-cddl │ ├── LICENSE-commonmark │ ├── LICENSE-epl-v10 │ ├── LICENSE-hamcrest │ ├── LICENSE-jmustache │ ├── LICENSE-jopt │ ├── LICENSE-jsch │ ├── LICENSE-jzlib │ ├── LICENSE-lombok │ ├── LICENSE-mit │ ├── LICENSE-mockito │ ├── LICENSE-mozilla-v20 │ ├── LICENSE-slf4j │ ├── LICENSE-threetenbp │ ├── LICENSE-webjars │ ├── LICENSE-woodstox-stax2-api │ ├── NOTICE-airline │ ├── NOTICE-apache-commons-cli │ ├── NOTICE-apache-commons-codec │ └── NOTICE-servicecomb-java-chassis └── toolkit-maven-plugin/ ├── pom.xml └── src/ ├── main/ │ └── java/ │ └── org/ │ └── apache/ │ └── servicecomb/ │ └── toolkit/ │ └── plugin/ │ ├── GenerateMojo.java │ ├── GenerateUtil.java │ ├── MavenPluginUtil.java │ ├── ServiceConfig.java │ └── VerifyMojo.java └── test/ ├── java/ │ └── org/ │ └── apache/ │ └── servicecomb/ │ └── toolkit/ │ └── plugin/ │ ├── GenerateMojoTest.java │ ├── GenerateUtilTest.java │ ├── InvokeStaticMethodTest.java │ ├── MavenPluginUtilTest.java │ ├── TestResourcesEx.java │ └── VerifyMojoTest.java ├── projects/ │ ├── contract-destination/ │ │ └── HelloEndPoint.yaml │ ├── contract-source/ │ │ └── HelloEndPoint.yaml │ ├── demo-multi-module/ │ │ ├── first-module/ │ │ │ └── pom.xml │ │ └── pom.xml │ ├── demo-with-contract/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── java/ │ │ └── demo/ │ │ ├── Application.java │ │ └── HelloEndPoint.java │ └── demo-without-contract/ │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── demo/ │ └── Application.java └── resources/ └── log4j2-test.xml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Output Directory target/ # C pre-compile *.gch *.pch # C compile *.a *.o *.ko *.la *.lo *.obj *.elf *.so *.so.* *.dylib *.exe *.lib *.dll *.out *.app *.hex # Debug files *.dSYM/ # Java *.class # Java Package Files *.jar *.war *.ear # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* # Zip Files *.rar *.zip *.7z *.tar *.gz # Ant build/ # Compiled Python __pycache__/ *.py[cod] *py.class # Eclipse .settings/ .classpath .project # IntelliJ, based on http://devnet.jetbrains.net/docs/DOC-1186 .idea/ *.iml *.ipr *.iws # logs and trace *.log *.trace *.dat # vi swap *.swp # Backup Files *.bak *.old # SVN metadata .svn/ # Mac .DS_Store # gradle .gradle ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================================ For codegen/src/main/resources/ServiceComb/* For cli/src/test/resources/swagger.yaml For codegen/src/test/resources/swagger.yaml ================================================================ This product bundles files from swagger-codegen which is licensed under the Apache License v2. For details, see https://github.com/swagger-api/swagger-codegen ================================================================ For codegen/src/main/resources/examples/* ================================================================ This product bundles files from swagger-codegen which is licensed under the Apache License v2. For details, see https://github.com/OAI/OpenAPI-Specification ================================================ FILE: NOTICE ================================================ Apache ServiceComb Toolkit Copyright 2019-present The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). ================================================ FILE: README-ZH.md ================================================ # Toolkit | [English](./README.md) [![Build Status](https://travis-ci.org/apache/servicecomb-toolkit.svg?branch=master)](https://travis-ci.org/apache/servicecomb-toolkit?branch=master)[![Coverage Status](https://coveralls.io/repos/github/apache/servicecomb-toolkit/badge.svg?branch=master)](https://coveralls.io/github/apache/servicecomb-toolkit?branch=master)[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=servicecomb-toolkit&metric=alert_status)](https://sonarcloud.io/dashboard?id=servicecomb-toolkit) [![Gitter](https://img.shields.io/badge/ServiceComb-Gitter-ff69b4.svg)](https://gitter.im/ServiceCombUsers/Lobby) Apache ServiceComb Toolkit 是基于契约的微服务开发工具套件 > 贡献者: 这个项目缺少维护者,如果您愿意为项目维护提供支持,请联系我们,可以将您加入项目的commiter群组,继续维护该项目. > 用户:这个项目缺少维护者,在我们找到持续的维护者之前,建议您尽可能不要使用这个项目,避免碰到问题得不到技术支持. ## 1 简介 ### 1.1 目标 * 提供契约、代码、文档相互转换及校验的能力,帮助用户一键式快速构建基于流行微服务框架和流行编程模型的微服务工程,降低微服务入门成本,使用户聚焦业务开发,提升遗留系统重构、开发效率。 ![image](./images/scene-zh.png) ### 1.2 特性 * 遗留应用提取契约文件 在基于SpringMVC/POJO/JAX-RS模型开发的应用中,一键提取符合OpenAPI规范的服务契约文件。 * 契约文件生成微服务工程 输入符合OpenAPI规范的服务契约,一键生成以ServiceComb/SpringCloud/Swagger为底座,以及以SpringMVC/POJO/JAX-RS或SpringBoot为开发模型的微服务项目。 * 契约与代码一致性校验 校验应用的实际实现(如数据和服务API)是否与样本服务契约描述一致。 * 契约的风格校验和兼容性校验 风格校验检查契约是否符合[OAS 3.0.2规范][openapi-3.0.2]以及自定义的规则; 兼容性校验检查新旧两个版本的OAS的兼容性 * 契约/代码生成文档 输入符合OpenAPI规范的服务契约,一键生成html格式的文档。 * Todo List * 支持gradle plugin, eclipse plugin, intellij plugin。 * 支持word、pdf等流行格式文档。 * 支持契约增量生成代码。 * 工具能力服务化。 * Server端自动/半自动测试 * Interface匹配性校验 * 支持生成包含连接Mysql/Redis等常见DB的代码片段的微服务脚手架 ### 1.3 适用场景 * 集成多厂商应用的企业 问题:厂商数据、服务标准不一致,开发语言、习惯、框架不一致,集成商难集成,企业难管控。 措施:通过统一定义的接口描述标准(服务契约),使用工具套件一键生成基于指定微服务框架的微服务工程,并且通过服务契约校验手段协同维护整体系统的一致性。以此协调多个开发团队,降低沟通成本且避免后期的混乱。 * 遗留系统微服务化快速改造 问题:用户需要额外学习和理解微服务及相关框架后,再设计微服务工程,学习成本高。 措施:使用工具套件分析遗留应用提取服务契约,再一键生成基于指定微服务框架的微服务工程后,即可聚焦业务开发,减少用户对微服务框架的学习成本。 ## 2 设计 ### 2.1 主体架构 ![image](./images/architecture-zh.png) ### 2.2 工作原理 ![image](./images/workingprinciple-zh.png) ## 3 快速入门 ### 3.1 从源码构建工具和插件 构建环境要求: * [Java 8](http://java.oracle.com) * [Apache maven 3.5.0 or greater](http://maven.apache.org/) ```shell # 从github获取toolkit最新源码 $ git clone https://github.com/apache/servicecomb-toolkit.git $ cd toolkit # 构建打包 $ mvn clean install ``` ### 3.2 使用toolkit-maven-plugin插件 #### 3.2.1 配置 在maven项目的pom文件中配置 ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code yaml html ./target ./contract ./target/contract ./contract all domain.orgnization.project sample 0.1.0-SNAPSHOT domain.orgnization.project.sample ServiceComb servicecomb-provider servicecomb-consumer value value ... value ``` #### 3.2.2 命令 ```shell # 生成契约,文档和微服务工程 mvn toolkit:generate # 校验代码和契约一致性 mvn toolkit:verify ``` #### 3.2.2.1 解析代码,生成微服务代码工程、OpenAPI规范契约、文档 配置项(不显式设置 `` 则使用默认配置) 例: ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./target all ``` 运行命令 ```shell mvn toolkit:generate ``` 代码生成契约现已支持以下注解(类级别)编写的restful接口 >RestController, RestSchema, RpcSchema, RequestMapping 代码生成契约时,restful接口方法修饰符必须指定为public #### 3.2.2.2 解析契约,生成微服务工程、文档 配置项(不显式设置 `` 则使用默认配置) 例: ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT contract ./contract ./target provider ``` 运行命令 ```shell mvn toolkit:generate ``` #### 3.2.2.3 代码和契约一致性校验 配置项 例: ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./contract ``` 运行命令 ```shell mvn toolkit:verify ``` ### 3.3 使用toolkit cli工具 #### 3.3.0 获取 * 如果你使用的是正式发布版本(>=0.2.0),可以在解压二进制包后直接使用里面的脚本文件 * 在Linux及Mac环境,请使用cli.sh * 在Windows环境,请使用cli.cmd * 如果你是通过源码构建,可以将`cli/scripts/cli.*`与`cli/target/bin/toolkit-cli-{version}.jar`放置在同一目录,然后根据不同环境选择不同脚本 以下所有示例均通过Linux环境的cli.sh进行介绍 ```shell $ ./cli.sh help ``` #### 3.3.1 契约生成微服务工程 ```shell $ ./cli.sh codegenerate -m ServiceComb -i swagger.yaml -o ./project -p SpringMVC ``` > **codegenerate** 命令选项说明: * -m, --microservice-framework : 指定微服务框架,现支持ServiceComb 例:-m ServiceComb * -p, --programming-model : 指定编程模型,可选JAX-RS,POJO,SpringMVC,SpringBoot 例:-p SpringMvc * -i, --input : 指定遵循OpenAPI规范的契约文件,支持yaml和json格式,支持指定本地和网络文件 例:-i http://petstore.swagger.io/v2/swagger.json * -o, --output : 生成的项目代码输出路径 例:-o ./project * --group-id : 指定生成的项目的group id 例:--group-id com.demo * --artifact-id : 指定生成的项目的artifact id 例:--artifact-id springmvc-example * --artifact-version : 指定生成的项目的artifact version 例:--artifact-version 1.0.0 * --api-package : 指定生成项目的api package 例:--api-package com.demo.api * --model-package : 指定生成项目的model package 例:--model-package com.demo.model * -t, --service-type : 指定生成的微服务项目的微服务类型。可选值为provider,consumer,all 例:--service-type provider * --properties : 指定额外的属性值,这些属性值可以被mustach模板引用 例:--properties applicationId=app,providerServiceId=provider #### 3.3.2 契约生成文档 ```shell $ ./cli.sh docgenerate -i swagger.yaml -o ./document ``` > **docgenerate** 命令选项说明: * -i, --input : 指定遵循OpenAPI规范的契约文件,支持yaml和json格式,支持指定本地和网络文件 例:-i http://petstore.swagger.io/v2/swagger.json * -o, --output : 文档输出路径 例:-o ./document * -f, --format : 指定输出文档风格,现支持swagger-ui 例:-f swagger-ui #### 3.3.3 契约风格检查 ```shell $ ./cli.sh checkstyle -r style-check-rules.yaml -f oas.yaml or $ ./cli.sh cs -r style-check-rules.yaml -f oas.yaml ``` > **checkstyle** Command argument * -r, --rules-file. Rules properties file. * -f, --file. OpenAPI v3 spec yaml. 见[风格检查规则](oas-validator/README-ZH.md) #### 3.3.4 契约兼容性检查 ```shell $ ./cli.sh checkcompatibility left-oas.yaml right-oas.yaml 或者 $ ./cli.sh cc left-oas.yaml right-oas.yaml ``` > **checkcompatibility** Command argument * <files> Two OpenAPI v3 spec yaml file 见[兼容性检查规则](oas-validator/README-ZH.md) ### 3.4 使用案例 可以在[这里](./samples/README-ZH.md)找到使用插件的一些示例 ## 4 社区互动 * [提交issues](https://issues.apache.org/jira/browse/SCB) * [gitter聊天室](https://gitter.im/ServiceCombUsers/Lobby) * 邮件列表: [订阅](mailto:dev-subscribe@servicecomb.apache.org) [浏览](https://lists.apache.org/list.html?dev@servicecomb.apache.org) ## 5 参与开发 See [Pull Request Guide](http://servicecomb.apache.org/developers/submit-codes/) for details. ================================================ FILE: README.md ================================================ # Toolkit | [中文](./README-ZH.md) [![Build Status](https://travis-ci.org/apache/servicecomb-toolkit.svg?branch=master)](https://travis-ci.org/apache/servicecomb-toolkit?branch=master)[![Coverage Status](https://coveralls.io/repos/github/apache/servicecomb-toolkit/badge.svg?branch=master)](https://coveralls.io/github/apache/servicecomb-toolkit?branch=master)[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=servicecomb-toolkit&metric=alert_status)](https://sonarcloud.io/dashboard?id=servicecomb-toolkit) [![Gitter](https://img.shields.io/badge/ServiceComb-Gitter-ff69b4.svg)](https://gitter.im/ServiceCombUsers/Lobby) Apache ServiceComb Toolkit is a contract-based microservice development toolkit > Notice to contributors: this project is not active due to lack of maintainers. If you are interested in this project, please cantact us and we will help you to be a committer. > Notice to users: this project is not active due to lack of maintainers. Before we find enough resources, do not use this project if possible. ## 1 Introduction ### 1.1 Conceptions * Provides the ability to convert and verify contracts, code, and documents, helping users quickly build microservice projects based on popular microservices frameworks and popular programming models, reducing the cost of microservices entry, enabling users to focus on business development, enhance refactoring and development efficiency. ![image](./images/scene-en.png) ### 1.2 Features * Code extraction service contract In applications developed based on the SpringMVC/POJO/JAX-RS model, one-click generation of service contract files conforming to the OpenAPI specification. * Service contract generation microservice project Enter a service contract that conforms to the OpenAPI specification, one-click generation of a microservice project with ServiceComb/SpringCloud/Swagger as the base microservice framework and SpringMVC/POJO/JAX-RS or SpringBoot as programming model. * Service contract and code consistency check Verify that the actual implementation of the application (such as the data and service API) is consistent with the agreed service contract description. * Service contract style checking and compatibility checking The style checking checks whether the contract conforms to [OAS 3.0.2 specification] [openapi-3.0.2] and custom rules; the compatibility checking checks whether new OAS spec compatible with old spec * Service contract/code generation document Enter a service contract that conforms to the OpenAPI specification, one-click generation of a document in html format. * Todo List * Support gradle plugin, eclipse plugin, intellij plugin. * Support for generating popular format documents such as word, pdf. * Support contract incremental generation code. * Make capability as a service. * Server-side automatic / semi-automatic test * Interface matching check * Support for generating microservice scaffolding containing code snippets that connect to common DBs such as Mysql / Redis ### 1.3 Applicable Scene * For users who integrate multi-vendor applications Scene: the development languages, habits, and frameworks of different vendors are different, the entire system data and service standards are inconsistent, users are difficult to integrate, and it is difficult to manage and control the final delivery quality. Solution:Through a uniformly defined interface description standard (service contract), a toolkit is used to generate a microservice project based on a specified microservices framework, and the consistency of the whole system is coordinated through service contract verification. Coordinate multiple development teams to reduce communication costs and avoid post-chaos. * For users who have evolved from legacy systems to microservices Scene: additional learning and understanding of the microservices-related framework details is required before the microservices project can be designed, built, and developed according to the selected microservices framework. For users, Need to be distracted to focus on things outside the business. Solution: Using the toolkit to analyze the legacy application extraction service contract, and then generate the microservices project based on the specified microservices framework, you can focus on business development and reduce the learning cost of the microservices framework. ## 2 Design ### 2.1 Architecture ![image](./images/architecture-en.png) ### 2.2 Working Principle ![image](./images/workingprinciple-en.png) ## 3 Quick Start ### 3.1 Build tool and plugins from source > Build environment requirements * [Java 8](http://java.oracle.com) * [Apache maven 3.5.0 or greater](http://maven.apache.org/) ```shell # Get the latest source code for toolkit from github $ git clone https://github.com/apache/servicecomb-toolkit.git $ cd toolkit # Build package $ mvn clean install ``` ### 3.2 Use the toolkit-maven-plugin plugin #### 3.2.1 configuration Configured in the pom file of the maven project ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code yaml html ./target ./contract ./target/contract ./contract all domain.orgnization.project sample 0.1.0-SNAPSHOT domain.orgnization.project.sample value value ... value ``` #### 3.2.2 Command ```shell # Generating contract, document and microservice project mvn toolkit:generate # Verify code and contract consistency mvn toolkit:verify ``` #### 3.2.2.1 Extract the microservice project, OpenAPI contract file and document from the code Configuration(use default configuration if not set ``) example ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./target all ``` Run in shell ```shell mvn toolkit:generate ``` When generating contracts from code,support for identifying restful interfaces written by the following annotations (class level) >RestController, RestSchema, RpcSchema, RequestMapping When generating contracts from code,the restful interface method access modifier must be specified as public #### 3.2.2.2 Generate the microservice project and document from contract Configuration(use default configuration if not set ``) example ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT contract ./target ./contract provider ``` Run in shell ```shell mvn toolkit:generate ``` #### 3.2.2.3 Contract verify Configuration example ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./contract ``` Run in shell ```shell mvn toolkit:verify ``` ### 3.3 Use the toolkit cli * If you are using the official release version ( >=0.2.0 ), you can use the script files directly after decompressing the binary package * In Linux and Mac environment, please use cli.sh * In the Windows environment, please use cli.cmd * If you are building from source, you can put `cli/scripts/cli.*` in the same directory as`cli/target/bin/toolkit-cli-{version}.jar` and then choose different scripts according to different environments All the examples below are introduced through cli.sh for Linux environment ```shell $ ./cli.sh help ``` #### 3.3.1 Service contract generation microservice project ```shell $ ./cli.sh codegenerate -m ServiceComb -i swagger.yaml -o ./project -p SpringMVC ``` > **codegenerate** Command option * -m, --microservice-framework. Specify microservices framework, now supports ServiceComb. e.g.:-m ServiceComb * -p, --programming-model. Specify programming model, optional JAX-RS, POJO, SpringMVC, SpringBoot. e.g.:-p SpringMvc * -i, --input. Specifies contract files that follow the OpenAPI specification, supports yaml and json formats, and supports specifying local and network files. e.g.:-i http://petstore.swagger.io/v2/swagger.json * -o, --output. Generated project code output path. e.g.:-o ./project * --group-id. Specify the group id of the generated project. e.g.:--group-id com.demo * --artifact-id. Specify the artifact id of the generated project. e.g.:--artifact-id springmvc-example * --artifact-version. Specify the artifact version of the generated project. e.g.:--artifact-version 1.0.0 * --api-package : Specify the api package of the generated project. e.g.:--api-package com.demo.api * --model-package : Specify the model package of the generated project. e.g.:--model-package com.demo.model * -t, --service-type : Specify microservice type of generated microservice project. optional value is provider,consumer,all e.g.:--service-type provider * --properties : Specify additional attribute values that can be referenced by the mustache template e.g.:--properties applicationId=app,providerServiceId=provider #### 3.3.2 Service contract generation document ```shell $ ./cli.sh docgenerate -i swagger.yaml -o ./document ``` > **docgenerate** Command option * -i, --input. Specifies contract files that follow the OpenAPI specification, supports yaml and json formats, and supports specifying local and network files. e.g:-i http://petstore.swagger.io/v2/swagger.json * -o, --output. Document output path. e.g:-o ./document * -f, --format. Specifies the output document format, now supports swagger-ui e.g:-f swagger-ui #### 3.3.3 Service contract style checking ```shell $ ./cli.sh checkstyle -r style-check-rules.yaml -f oas.yaml or $ ./cli.sh cs -r style-check-rules.yaml -f oas.yaml ``` > **checkstyle** Command argument * -r, --rules-file. Rules properties file. * -f, --file. OpenAPI v3 spec yaml. See [style check rules](oas-validator/README.md) #### 3.3.4 Service contract compatibility checking ```shell $ ./cli.sh checkcompatibility left-oas.yaml right-oas.yaml or $ ./cli.sh cc left-oas.yaml right-oas.yaml ``` > **checkcompatibility** Command argument * <files> Two OpenAPI v3 spec yaml file See [compatibilty check rules](oas-validator/README.md) ### 3.4 Use case some example of using plugin can be found [here](./samples) ## 4 Contact us * [issues](https://issues.apache.org/jira/browse/SCB) * [gitter](https://gitter.im/ServiceCombUsers/Lobby) * mailing list: [subscribe](mailto:dev-subscribe@servicecomb.apache.org) [view](https://lists.apache.org/list.html?dev@servicecomb.apache.org) ## 5 Contribute PR: [Pull request](https://github.com/apache/servicecomb-toolkit/pulls) ================================================ FILE: cli/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT ../ 4.0.0 cli org.apache.servicecomb.toolkit.cli.ToolkitMain io.airlift airline com.google.code.findbugs annotations org.apache.servicecomb.toolkit codegen junit junit test org.apache.servicecomb.toolkit docgen org.apache.logging.log4j log4j-slf4j-impl org.apache.logging.log4j log4j-api org.apache.logging.log4j log4j-core org.apache.servicecomb.toolkit oas-validator-style org.apache.servicecomb.toolkit oas-validator-compatibility com.github.stefanbirkner system-rules test org.apache.maven.plugins maven-compiler-plugin org.apache.maven.plugins maven-resources-plugin org.springframework.boot spring-boot-maven-plugin true ${main.class} target/bin toolkit-cli-${project.version} repackage src/main/resources true ================================================ FILE: cli/scripts/cli.cmd ================================================ @REM Licensed to the Apache Software Foundation (ASF) under one or more @REM contributor license agreements. See the NOTICE file distributed with @REM this work for additional information regarding copyright ownership. @REM The ASF licenses this file to You under the Apache License, Version 2.0 @REM (the "License"); you may not use this file except in compliance with @REM the License. You may obtain a copy of the License at @REM @REM http://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, software @REM distributed under the License is distributed on an "AS IS" BASIS, @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @REM See the License for the specific language governing permissions and @REM limitations under the License. @echo off && rem set SUCCESS_CODE=0 set ERROR_CODE=1 @REM check if java install if "%JAVA_HOME%" == "" goto JAVA_HOME_ERROR if not exist "%JAVA_HOME%\bin\java.exe" goto JAVA_HOME_ERROR set jarFile= for /f "delims=" %%t in ('dir /S /B cli-*.jar') do set jarFile=%%t @REM check if jar file exist if "%jarFile%" == "" ( echo Error: cli.jar not exist. make sure it is placed in the current directory or subdirectory of this script exit /B %ERROR_CODE% ) set allparam= :param set str=%1 if "%str%"=="" ( goto end ) set allparam=%allparam% %str% shift /0 goto param :end if "%allparam%"=="" ( goto eof ) rem remove left right blank :intercept_left if "%allparam:~0,1%"==" " set "allparam=%allparam:~1%"&goto intercept_left :intercept_right if "%allparam:~-1%"==" " set "allparam=%allparam:~0,-1%"&goto intercept_right :eof java -Dscript.name="cli.cmd" -jar %jarFile% %allparam% exit /B %SUCCESS_CODE% :JAVA_HOME_ERROR echo. echo Error: JAVA_HOME invalid in your environment. >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2 echo location of your Java installation. >&2 echo. exit /B %ERROR_CODE% ================================================ FILE: cli/scripts/cli.sh ================================================ #!/bin/bash ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- # check if java install if [ -z "$JAVA_HOME" -o ! -f "$JAVA_HOME/bin/java" ]; then echo Error: JAVA_HOME invalid in your environment. >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2 echo location of your Java installation. >&2 exit 1 fi # resolve links - $0 may be a softlink PRG="$0" while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done shellDir=`dirname "$PRG"` # check if jar file exist jarFile=$(find ${shellDir} -name "cli-*.jar" | head -n 1) if [[ ! -f ${jarFile} ]]; then echo "error: cli.jar not exist. make sure it is placed in the current directory or subdirectory of this script" exit 1 fi java -Dscript.name="cli.sh" -jar ${jarFile} $* ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/CheckCompatibility.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import io.airlift.airline.Command; @Command(name = "checkcompatibility", description = "(Or cc for abbr). Check compatibility for two OpenAPI v3 spec yamls, right one should be semantically compatible with left one") public class CheckCompatibility extends CheckCompatibilityBase { } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/CheckCompatibilityAbbr.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import io.airlift.airline.Command; @Command(name = "cc", description = "Check compatibility for two OpenAPI v3 spec yamls," + " right one should be semantically compatible with left one", hidden = true) public class CheckCompatibilityAbbr extends CheckCompatibilityBase { } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/CheckCompatibilityBase.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.StringJoiner; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.compatibility.CompatibilityCheckParser; import org.apache.servicecomb.toolkit.oasv.compatibility.factory.DefaultOasSpecDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasSpecDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.OasSpecDiffValidatorFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import io.airlift.airline.Arguments; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.parser.core.models.SwaggerParseResult; public class CheckCompatibilityBase implements Runnable { private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); @Arguments( title = "files", required = true, description = "Two OpenAPI v3 spec yamls" ) private List filePaths; @Override public void run() { if (filePaths.size() != 2) { LOGGER.error("Require 2 files"); return; } OpenAPI oldOas = null; OpenAPI newOas = null; try { oldOas = loadOpenApi(filePaths.get(0)); newOas = loadOpenApi(filePaths.get(1)); } catch (Exception e) { LOGGER.error(e.getMessage()); return; } OasSpecDiffValidator diffValidator = createOasSpecDiffValidator(); List violations = diffValidator.validate(createContext(oldOas, newOas), oldOas, newOas); if (CollectionUtils.isNotEmpty(violations)) { for (OasDiffViolation violation : violations) { LOGGER.info("left : {}\nright : {}\nerror : {}\n------", OasObjectPropertyLocation.toPathString(violation.getLeftLocation()), OasObjectPropertyLocation.toPathString(violation.getRightLocation()), violation.getError() ); } throw new ValidationFailedException("check not passed"); } LOGGER.info("Everything is good"); } private OpenAPI loadOpenApi(String filePath) throws IOException { String yaml = loadFileContent(filePath); SwaggerParseResult oldParseResult = CompatibilityCheckParser.parseYaml(yaml); OpenAPI openAPI = oldParseResult.getOpenAPI(); if (openAPI == null) { StringJoiner errors = new StringJoiner("\n", "Parse errors:", ""); if (CollectionUtils.isNotEmpty(oldParseResult.getMessages())) { for (String message : oldParseResult.getMessages()) { errors.add(message); } } throw new RuntimeException(errors.toString()); } return openAPI; } private OasSpecDiffValidator createOasSpecDiffValidator() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( DefaultOasSpecDiffValidatorFactory.class.getPackage().getName()); try { OasSpecDiffValidatorFactory diffValidatorFactory = ctx.getBean(OasSpecDiffValidatorFactory.class); return diffValidatorFactory.create(); } finally { ctx.close(); } } private String loadFileContent(String filePath) throws IOException { Path specPath = Paths.get(filePath); specPath.toAbsolutePath().toString(); return FileUtils.readFileToString(specPath.toFile()); } private OasDiffValidationContext createContext(OpenAPI leftOpenAPI, OpenAPI rightOpenAPI) { OasDiffValidationContext context = new OasDiffValidationContext(leftOpenAPI, rightOpenAPI); return context; } } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/CheckStyle.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import io.airlift.airline.Command; @Command(name = "checkstyle", description = "(Or cs for abbr). Check style for OpenAPI v3 spec yaml.") public class CheckStyle extends CheckStyleBase { } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/CheckStyleAbbr.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import io.airlift.airline.Command; @Command(name = "cs", description = "Check style for OpenAPI v3 spec yaml", hidden = true) public class CheckStyleAbbr extends CheckStyleBase { } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/CheckStyleBase.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import com.google.common.base.Charsets; import io.airlift.airline.Option; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.parser.core.models.SwaggerParseResult; import java.io.FileInputStream; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.Properties; import java.util.StringJoiner; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.style.StyleCheckParser; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.factory.OasSpecValidatorFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class CheckStyleBase implements Runnable { private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); @Option(name = { "-r", "--rules-file" }, title = "rules properties file", required = true, description = "rules properties file") private String rulesFile; @Option(name = { "-f", "--file" }, title = "OpenAPI v3 spec yaml", required = true, description = "OpenAPI v3 spec yaml") private String filePath; @Override public void run() { FactoryOptions factoryOptions; try { factoryOptions = loadFactoryOptions(); } catch (IOException e) { throw new RuntimeException(e); } String yaml = null; try { yaml = loadFileContent(filePath); } catch (IOException e) { throw new RuntimeException(e); } SwaggerParseResult parseResult = StyleCheckParser.parseYaml(yaml); OpenAPI openAPI = parseResult.getOpenAPI(); if (openAPI == null) { StringJoiner sj = new StringJoiner("\n"); if (CollectionUtils.isNotEmpty(parseResult.getMessages())) { for (String message : parseResult.getMessages()) { sj.add(message); } } throw new RuntimeException(sj.toString()); } OasSpecValidator oasSpecValidator = createOasSpecValidator(factoryOptions); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); if (CollectionUtils.isNotEmpty(violations)) { for (OasViolation violation : violations) { LOGGER.info("path : {}\nerror : {}\n------", OasObjectPropertyLocation.toPathString(violation.getLocation()), violation.getError()); } throw new ValidationFailedException("check not passed"); } LOGGER.info("Everything is good"); } private OasSpecValidator createOasSpecValidator(FactoryOptions factoryOptions) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( ValidatorFactoryComponents.class); try { OasSpecValidatorFactory oasSpecValidatorFactory = ctx.getBean(OasSpecValidatorFactory.class); return oasSpecValidatorFactory.create(factoryOptions); } finally { ctx.close(); } } private String loadFileContent(String filePath) throws IOException { Path specPath = Paths.get(filePath); return FileUtils.readFileToString(specPath.toFile(), Charsets.UTF_8); } private OasValidationContext createContext(OpenAPI openAPI) { OasValidationContext oasValidationContext = new OasValidationContext(openAPI); return oasValidationContext; } private FactoryOptions loadFactoryOptions() throws IOException { Path specPath = Paths.get(rulesFile); specPath.toAbsolutePath().toString(); Properties properties = new Properties(); try (FileInputStream fis = new FileInputStream(specPath.toFile())) { properties.load(fis); } return new FactoryOptions(properties); } } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import static org.apache.commons.lang3.StringUtils.isNotEmpty; import java.io.File; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.Collections; import java.util.Optional; import org.apache.servicecomb.toolkit.CodeGenerator; import org.apache.servicecomb.toolkit.GeneratorFactory; import org.apache.servicecomb.toolkit.codegen.ProjectMetaConstant; import org.openapitools.codegen.config.CodegenConfigurator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.airlift.airline.Command; import io.airlift.airline.Option; @Command(name = "codegenerate", description = "Generate multiple models of microservice project by OpenAPI specification file") public class CodeGenerate implements Runnable { private final static Logger LOGGER = LoggerFactory.getLogger(CodeGenerate.class); @Option(name = {"-p", "--programming-model"}, title = "programming model", required = false, description = "programming model, as SpringMVC, POJO, JAX-RS, and SpringBoot") private String programmingModel; @Option(name = {"-m", "--microservice-framework"}, title = "framework", description = "microservice-framework") private String framework = "ServiceComb"; @Option(name = {"-i", "--input"}, title = "OpenAPI specification file", required = true, description = "location of the OpenAPI specification file, as URL or file (required)") private String specFile; @Option(name = {"-o", "--output"}, title = "output directory", description = "location of the generated document (current dir by default)") private String output = ""; @Option(name = {"--group-id"}, title = "group id", description = "groupId in generated microservice project") private String groupId; @Option(name = {"--artifact-id"}, title = "artifact id", description = "artifact id in generated microservice project") private String artifactId; @Option(name = {"--artifact-version"}, title = "artifact version", description = "artifact version in generated microservice project") private String artifactVersion; @Option(name = {"--api-package"}, title = "api package", description = "api package in generated microservice project") private String apiPackage; @Option(name = {"--model-package"}, title = "model package", description = "model package in generated microservice project") private String modelPackage; @Option(name = {"-t", "--service-type"}, title = "service type", description = "microservice type of generated microservice project. optional value is provider,consumer,all") private String serviceType = "all"; @Option( name = {"--properties"}, title = "additional properties", description = "usage: --properties name=value,name=value. These Properties can be referenced by the mustache templates." + " You can specify one or more value") private String properties; @Override public void run() { CodeGenerator codegenerator = GeneratorFactory.getGenerator(CodeGenerator.class, "default"); if (codegenerator == null) { LOGGER.warn("Not CodeGenerator found"); return; } CodegenConfigurator configurator = new CodegenConfigurator(); // add additional property Optional.ofNullable(properties).ifPresent(properties -> Arrays.stream(properties.split(",")).forEach(property -> { String[] split = property.split("="); if (split != null && split.length == 2) { configurator.addAdditionalProperty(split[0], split[1]); } }) ); configurator.setOutputDir(output) .setGroupId(groupId) .setArtifactId(artifactId) .setArtifactVersion(artifactVersion) .setLibrary(programmingModel) .setGeneratorName(framework) .setApiPackage(apiPackage) .setModelPackage(modelPackage); configurator.addAdditionalProperty(ProjectMetaConstant.SERVICE_TYPE, serviceType); if (isNotEmpty(specFile)) { File contractFile = new File(specFile); if (contractFile.isDirectory()) { try { Files.walkFileTree(Paths.get(contractFile.toURI()), new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { configurator.setInputSpec(file.toFile().getCanonicalPath()) .addAdditionalProperty("apiName", file.toFile().getName().split("\\.")[0]); try { codegenerator.configure(Collections.singletonMap("configurator", configurator)); codegenerator.generate(); } catch (RuntimeException e) { throw new RuntimeException("Failed to generate code base on file " + file.toFile().getName()); } return super.visitFile(file, attrs); } }); } catch (RuntimeException | IOException e) { LOGGER.error(e.getMessage()); return; } } else { configurator.setInputSpec(specFile).addAdditionalProperty("apiName", contractFile.getName().split("\\.")[0]); codegenerator.configure(Collections.singletonMap("configurator", configurator)); codegenerator.generate(); } LOGGER.info("Success to generate code, the directory is: {}", output); } } } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import java.io.File; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.HashMap; import java.util.Map; import org.apache.servicecomb.toolkit.DocGenerator; import org.apache.servicecomb.toolkit.GeneratorFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.airlift.airline.Command; import io.airlift.airline.Option; import io.swagger.parser.OpenAPIParser; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.parser.core.models.SwaggerParseResult; @Command(name = "docgenerate", description = "Generate document by OpenAPI specification file") public class DocGenerate implements Runnable { private final static Logger LOGGER = LoggerFactory.getLogger(CodeGenerate.class); @Option(name = {"-i", "--input"}, title = "OpenAPI specification file", required = true, description = "location of the OpenAPI specification file, as URL or file (required)") private String specFile; @Option(name = {"-f", "--format"}, title = "document format", required = false, description = "format of document, as swagger-ui or asciidoc-html (swagger-ui by default)") private String format = "swagger-ui"; @Option(name = {"-o", "--output"}, title = "output directory", description = "location of the generated document (current dir by default)") private String output = ""; @Override public void run() { try { Path specPath = Paths.get(specFile); String[] fileName = new String[1]; DocGenerator docGenerator = GeneratorFactory.getGenerator(DocGenerator.class, format); Map docGeneratorConfig = new HashMap<>(); if (Files.isDirectory(specPath)) { Files.walkFileTree(specPath, new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { docGeneratorConfig.put("contractContent", parseOpenApi(specPath)); docGeneratorConfig.put("outputPath", output + File.separator + file.toFile().getName().substring(0, file.toFile().getName().indexOf("."))); docGenerator.configure(docGeneratorConfig); docGenerator.generate(); return super.visitFile(file, attrs); } }); } else if (Files.isRegularFile(specPath)) { fileName[0] = specPath.toFile().getName(); docGeneratorConfig.put("contractContent", parseOpenApi(specPath)); docGeneratorConfig.put("outputPath", output + File.separator + new File(specFile).getName() .substring(0, new File(specFile).getName().indexOf("."))); docGenerator.configure(docGeneratorConfig); docGenerator.generate(); } else { fileName[0] = specFile; docGeneratorConfig.put("contractContent", parseOpenApi(specPath)); docGeneratorConfig.put("outputPath", output + File.separator + new File(specFile).getName() .substring(0, new File(specFile).getName().indexOf("."))); docGenerator.configure(docGeneratorConfig); docGenerator.generate(); } LOGGER.info("Success to generate document, the directory is: {}", output); } catch (IOException e) { LOGGER.error(e.getMessage()); } } public OpenAPI parseOpenApi(Path file) { SwaggerParseResult swaggerParseResult = new OpenAPIParser() .readLocation(file.toString(), null, null); OpenAPI openAPI = swaggerParseResult.getOpenAPI(); return openAPI; } } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/ToolkitMain.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import java.io.IOException; import java.util.Optional; import java.util.Properties; import org.apache.commons.lang3.StringUtils; import io.airlift.airline.Cli; import io.airlift.airline.Help; public class ToolkitMain { private static String projectVersion; @SuppressWarnings("unchecked") public static void main(String[] args) { initialProjectVersion(); String scriptName = System.getProperty("script.name"); Cli.CliBuilder builder = null; if (StringUtils.isNotEmpty(scriptName)) { builder = Cli.builder(scriptName); } else { builder = Cli.builder("java -jar cli-" + projectVersion + ".jar"); } builder.withDescription("Microservice development toolkit(version " + projectVersion + "). "); builder.withDefaultCommand(Help.class); builder.withCommands( CodeGenerate.class, DocGenerate.class, CheckStyle.class, CheckStyleAbbr.class, CheckCompatibility.class, CheckCompatibilityAbbr.class, Help.class ); try { Runnable cmd = builder.build().parse(args); cmd.run(); } catch (ValidationFailedException ex) { ex.printStackTrace(System.err); System.exit(1); } } private static void initialProjectVersion() { Properties properties = new Properties(); try { properties.load(ToolkitMain.class.getClassLoader().getResourceAsStream("application.properties")); projectVersion = Optional.ofNullable(properties.getProperty("version")).orElse("unknown"); } catch (IOException e) { e.printStackTrace(); } } } ================================================ FILE: cli/src/main/java/org/apache/servicecomb/toolkit/cli/ValidationFailedException.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; public class ValidationFailedException extends RuntimeException { public ValidationFailedException(String msg) { super(msg); } } ================================================ FILE: cli/src/main/resources/application.properties ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # version=${project.version} ================================================ FILE: cli/src/main/resources/log4j2.xml ================================================ ================================================ FILE: cli/src/test/java/org/apache/servicecomb/toolkit/cli/CliTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.cli; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.contrib.java.lang.system.ExpectedSystemExit; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import org.apache.commons.io.FileUtils; public class CliTest { @Rule public final ExpectedSystemExit exit = ExpectedSystemExit.none(); @Test public void testGenerateServiceCombCodeFromSingleContract() throws IOException { String[] programModels = new String[] {"SpringMVC", "POJO", "JAX-RS", "SpringBoot"}; Path tempDir = Files.createTempDirectory(null); Arrays.stream(programModels).forEach(model -> { try { Path tempFile = Paths.get(tempDir.toFile().getCanonicalPath() + "/" + model + "Server"); CliTest.class.getClassLoader().getResource("swagger.yaml"); String[] args = new String[] { "codegenerate", "-m", "ServiceComb", "-i", Paths.get("./src/test/resources/swagger.yaml").toFile().getCanonicalPath(), "-o", tempFile.toFile().getCanonicalPath(), "-p", model, "--properties", "prop1=value,prop2=value" }; Assert.assertTrue(!Files.exists(tempFile)); ToolkitMain.main(args); Assert.assertTrue(Files.exists(tempFile)); Assert.assertTrue(FileUtils.sizeOfDirectory(tempFile.toFile()) > 0); } catch (IOException e) { e.printStackTrace(); } }); tempDir.toFile().deleteOnExit(); } @Test public void testGenerateCodeFromMultiContract() throws IOException { Path tempDir = Files.createTempDirectory(null); Path tempFile = Paths.get(tempDir.toFile().getCanonicalPath() + "/ServiceComb"); String[] args = new String[] { "codegenerate", "-i", Paths.get("./src/test/resources/contracts").toFile().getCanonicalPath(), "--artifact-id", "ServiceComb", "--group-id", "org.apache.servicecomb.demo", "--artifact-version", "0.0.1", "--programming-model", "SpringMVC", "-o", tempFile.toFile().getCanonicalPath() }; Assert.assertTrue(!Files.exists(tempFile)); ToolkitMain.main(args); Assert.assertTrue(Files.exists(tempFile)); Assert.assertTrue(FileUtils.sizeOfDirectory(tempFile.toFile()) > 0); tempDir.toFile().deleteOnExit(); } @Test public void testCheckStyle() throws IOException { exit.expectSystemExitWithStatus(1); String[] args = new String[] { "checkstyle", "-r", Paths.get("./src/test/resources/oas/style-rules.properties").toFile().getCanonicalPath(), "-f", Paths.get("./src/test/resources/oas/style.yaml").toFile().getCanonicalPath() }; ToolkitMain.main(args); } @Test public void testCheckStyleAbbr() throws IOException { exit.expectSystemExitWithStatus(1); String[] args = new String[] { "cs", "-r", Paths.get("./src/test/resources/oas/style-rules.properties").toFile().getCanonicalPath(), "-f", Paths.get("./src/test/resources/oas/style.yaml").toFile().getCanonicalPath() }; ToolkitMain.main(args); } @Test public void testCheckCompatibility() throws IOException { exit.expectSystemExitWithStatus(1); String[] args = new String[] { "checkcompatibility", Paths.get("./src/test/resources/oas/compatibility-left.yaml").toFile().getCanonicalPath(), Paths.get("./src/test/resources/oas/compatibility-right.yaml").toFile().getCanonicalPath() }; ToolkitMain.main(args); } @Test public void testCheckCompatibilityAbbr() throws IOException { exit.expectSystemExitWithStatus(1); String[] args = new String[] { "cc", Paths.get("./src/test/resources/oas/compatibility-left.yaml").toFile().getCanonicalPath(), Paths.get("./src/test/resources/oas/compatibility-right.yaml").toFile().getCanonicalPath() }; ToolkitMain.main(args); } } ================================================ FILE: cli/src/test/resources/contracts/CalculateEndpoint.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for CalculateEndpoint" x-java-interface: "gen.swagger.CalculateEndpointIntf" basePath: "/" consumes: - "application/json" produces: - "application/json" paths: /bmi: get: operationId: "calculate" parameters: - name: "number1" in: "query" required: false type: "number" format: "double" - name: "number2" in: "query" required: false type: "number" format: "double" responses: 200: description: "response of 200" schema: $ref: "#/definitions/CalculateViewObject" definitions: CalculateViewObject: type: "object" properties: result: type: "number" format: "double" instanceId: type: "string" callTime: type: "string" x-java-class: "CalculateViewObject" ================================================ FILE: cli/src/test/resources/contracts/HelloEndPoint.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for HelloEndPoint" x-java-interface: "gen.swagger.HelloEndPointIntf" basePath: "/hello" consumes: - "application/json" produces: - "application/json" paths: /sayHello: get: operationId: "sayHello" parameters: - name: "name" in: "query" required: false type: "string" - name: "result" in: "query" required: false type: "number" format: "double" - name: "instanceId" in: "query" required: false type: "string" - name: "callTime" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" /sayHi: get: operationId: "sayHi" parameters: - name: "name" in: "query" required: false type: "string" - name: "Authorization" in: "header" description: "aa" required: true type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: cli/src/test/resources/contracts/pojo/CodeFirstHelloEndPoint.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for CodeFirstHelloEndPoint" x-java-interface: "gen.swagger.CodeFirstHelloEndPointIntf" basePath: "/codeFirstHello" consumes: - "application/json" produces: - "application/json" paths: /sayHello: post: operationId: "sayHello" parameters: - name: "name" in: "query" required: false type: "string" - name: "result" in: "query" required: false type: "number" format: "double" - name: "instanceId" in: "query" required: false type: "string" - name: "callTime" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" /sayHi: post: operationId: "sayHi" parameters: - name: "name" in: "query" required: false type: "string" - name: "Authorization" in: "header" description: "aa" required: true type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: cli/src/test/resources/log4j2-test.xml ================================================ ================================================ FILE: cli/src/test/resources/oas/compatibility-left.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: cli/src/test/resources/oas/compatibility-right.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' bar: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: cli/src/test/resources/oas/style-rules.properties ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- # OpenAPI Object openAPI.openapi.gte=3.0.2 openAPI.tags.size.gte=1 openAPI.security.size.eq=0 # Info Object info.description.required=true # Tag Object tag.name.case=upper-camel-case tag.name.must_be_referenced=true tag.description.required=true # Paths Object paths.key.case=lower-camel-case # Operation Object operation.summary.required=true operation.operationId.case=lower-camel-case operation.tags.size.eq=1 operation.tags.element.must_reference_root_tags=true operations.servers.size.eq=0 # Parameter Object parameter.description.required=true parameter.name.header.case=upper-hyphen-case parameter.name.cookie.case=lower-camel-case parameter.name.path.case=lower-camel-case parameter.name.query.case=lower-camel-case # RequestBody Object requestBody.description.required=true # Response Object response.headers.key.case=upper-hyphen-case # Schema Object schema.title.required=true schema.properties.key.case=lower-camel-case # Encoding Object encoding.headers.key.case=upper-hyphen-case # Header Object header.description.required=true # Components Object components.schemas.key.case=upper-camel-case components.responses.key.case=upper-camel-case components.parameters.key.case=upper-camel-case components.examples.key.case=upper-camel-case components.requestBodies.key.case=upper-camel-case components.headers.key.case=upper-hyphen-case components.links.key.case=upper-hyphen-case components.callbacks.key.case=upper-camel-case components.headers.key.case=upper-camel-case ================================================ FILE: cli/src/test/resources/oas/style.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Pet petstore paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: cli/src/test/resources/swagger.yaml ================================================ --- swagger: "2.0" info: description: "This is a sample server Petstore server. You can find out more about\ \ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\ \ For this sample, you can use the api key `special-key` to test the authorization\ \ filters." version: "1.0.0" title: "Swagger Petstore" termsOfService: "http://swagger.io/terms/" contact: email: "apiteam@swagger.io" license: name: "Apache 2.0" url: "http://www.apache.org/licenses/LICENSE-2.0.html" host: "petstore.swagger.io" basePath: "/v2" tags: - name: "pet" description: "Everything about your Pets" externalDocs: description: "Find out more" url: "http://swagger.io" - name: "store" description: "Access to Petstore orders" - name: "user" description: "Operations about user" externalDocs: description: "Find out more about our store" url: "http://swagger.io" schemes: - "https" - "http" paths: /pet: post: tags: - "pet" summary: "Add a new pet to the store" description: "" operationId: "addPet" consumes: - "application/json" - "application/xml" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" required: true schema: $ref: "#/definitions/Pet" responses: 405: description: "Invalid input" security: - petstore_auth: - "write:pets" - "read:pets" put: tags: - "pet" summary: "Update an existing pet" description: "" operationId: "updatePet" consumes: - "application/json" - "application/xml" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" required: true schema: $ref: "#/definitions/Pet" responses: 400: description: "Invalid ID supplied" 404: description: "Pet not found" 405: description: "Validation exception" security: - petstore_auth: - "write:pets" - "read:pets" /pet/findByStatus: get: tags: - "pet" summary: "Finds Pets by status" description: "Multiple status values can be provided with comma separated strings" operationId: "findPetsByStatus" produces: - "application/xml" - "application/json" parameters: - name: "status" in: "query" description: "Status values that need to be considered for filter" required: true type: "array" items: type: "string" enum: - "available" - "pending" - "sold" default: "available" collectionFormat: "multi" responses: 200: description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" 400: description: "Invalid status value" security: - petstore_auth: - "write:pets" - "read:pets" /pet/findByTags: get: tags: - "pet" summary: "Finds Pets by tags" description: "Multiple tags can be provided with comma separated strings. Use\ \ tag1, tag2, tag3 for testing." operationId: "findPetsByTags" produces: - "application/xml" - "application/json" parameters: - name: "tags" in: "query" description: "Tags to filter by" required: true type: "array" items: type: "string" collectionFormat: "multi" responses: 200: description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" 400: description: "Invalid tag value" security: - petstore_auth: - "write:pets" - "read:pets" deprecated: true /pet/{petId}: get: tags: - "pet" summary: "Find pet by ID" description: "Returns a single pet" operationId: "getPetById" produces: - "application/xml" - "application/json" parameters: - name: "petId" in: "path" description: "ID of pet to return" required: true type: "integer" format: "int64" responses: 200: description: "successful operation" schema: $ref: "#/definitions/Pet" 400: description: "Invalid ID supplied" 404: description: "Pet not found" security: - api_key: [] post: tags: - "pet" summary: "Updates a pet in the store with form data" description: "" operationId: "updatePetWithForm" consumes: - "application/x-www-form-urlencoded" produces: - "application/xml" - "application/json" parameters: - name: "petId" in: "path" description: "ID of pet that needs to be updated" required: true type: "integer" format: "int64" - name: "name" in: "formData" description: "Updated name of the pet" required: false type: "string" - name: "status" in: "formData" description: "Updated status of the pet" required: false type: "string" responses: 405: description: "Invalid input" security: - petstore_auth: - "write:pets" - "read:pets" delete: tags: - "pet" summary: "Deletes a pet" description: "" operationId: "deletePet" produces: - "application/xml" - "application/json" parameters: - name: "api_key" in: "header" required: false type: "string" - name: "petId" in: "path" description: "Pet id to delete" required: true type: "integer" format: "int64" responses: 400: description: "Invalid ID supplied" 404: description: "Pet not found" security: - petstore_auth: - "write:pets" - "read:pets" /pet/{petId}/uploadImage: post: tags: - "pet" summary: "uploads an image" description: "" operationId: "uploadFile" consumes: - "multipart/form-data" produces: - "application/json" parameters: - name: "petId" in: "path" description: "ID of pet to update" required: true type: "integer" format: "int64" - name: "additionalMetadata" in: "formData" description: "Additional data to pass to server" required: false type: "string" - name: "file" in: "formData" description: "file to upload" required: false type: "file" responses: 200: description: "successful operation" schema: $ref: "#/definitions/ApiResponse" security: - petstore_auth: - "write:pets" - "read:pets" /store/inventory: get: tags: - "store" summary: "Returns pet inventories by status" description: "Returns a map of status codes to quantities" operationId: "getInventory" produces: - "application/json" parameters: [] responses: 200: description: "successful operation" schema: type: "object" additionalProperties: type: "integer" format: "int32" security: - api_key: [] /store/order: post: tags: - "store" summary: "Place an order for a pet" description: "" operationId: "placeOrder" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "order placed for purchasing the pet" required: true schema: $ref: "#/definitions/Order" responses: 200: description: "successful operation" schema: $ref: "#/definitions/Order" 400: description: "Invalid Order" /store/order/{orderId}: get: tags: - "store" summary: "Find purchase order by ID" description: "For valid response try integer IDs with value >= 1 and <= 10.\ \ Other values will generated exceptions" operationId: "getOrderById" produces: - "application/xml" - "application/json" parameters: - name: "orderId" in: "path" description: "ID of pet that needs to be fetched" required: true type: "integer" maximum: 10.0 minimum: 1.0 format: "int64" responses: 200: description: "successful operation" schema: $ref: "#/definitions/Order" 400: description: "Invalid ID supplied" 404: description: "Order not found" delete: tags: - "store" summary: "Delete purchase order by ID" description: "For valid response try integer IDs with positive integer value.\ \ Negative or non-integer values will generate API errors" operationId: "deleteOrder" produces: - "application/xml" - "application/json" parameters: - name: "orderId" in: "path" description: "ID of the order that needs to be deleted" required: true type: "integer" minimum: 1.0 format: "int64" responses: 400: description: "Invalid ID supplied" 404: description: "Order not found" /user: post: tags: - "user" summary: "Create user" description: "This can only be done by the logged in user." operationId: "createUser" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "Created user object" required: true schema: $ref: "#/definitions/User" responses: default: description: "successful operation" /user/createWithArray: post: tags: - "user" summary: "Creates list of users with given input array" description: "" operationId: "createUsersWithArrayInput" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "List of user object" required: true schema: type: "array" items: $ref: "#/definitions/User" responses: default: description: "successful operation" /user/createWithList: post: tags: - "user" summary: "Creates list of users with given input array" description: "" operationId: "createUsersWithListInput" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "List of user object" required: true schema: type: "array" items: $ref: "#/definitions/User" responses: default: description: "successful operation" /user/login: get: tags: - "user" summary: "Logs user into the system" description: "" operationId: "loginUser" produces: - "application/xml" - "application/json" parameters: - name: "username" in: "query" description: "The user name for login" required: true type: "string" - name: "password" in: "query" description: "The password for login in clear text" required: true type: "string" responses: 200: description: "successful operation" schema: type: "string" headers: X-Rate-Limit: type: "integer" format: "int32" description: "calls per hour allowed by the user" X-Expires-After: type: "string" format: "date-time" description: "date in UTC when token expires" 400: description: "Invalid username/password supplied" /user/logout: get: tags: - "user" summary: "Logs out current logged in user session" description: "" operationId: "logoutUser" produces: - "application/xml" - "application/json" parameters: [] responses: default: description: "successful operation" /user/{username}: get: tags: - "user" summary: "Get user by user name" description: "" operationId: "getUserByName" produces: - "application/xml" - "application/json" parameters: - name: "username" in: "path" description: "The name that needs to be fetched. Use user1 for testing. " required: true type: "string" responses: 200: description: "successful operation" schema: $ref: "#/definitions/User" 400: description: "Invalid username supplied" 404: description: "User not found" put: tags: - "user" summary: "Updated user" description: "This can only be done by the logged in user." operationId: "updateUser" produces: - "application/xml" - "application/json" parameters: - name: "username" in: "path" description: "name that need to be updated" required: true type: "string" - in: "body" name: "body" description: "Updated user object" required: true schema: $ref: "#/definitions/User" responses: 400: description: "Invalid user supplied" 404: description: "User not found" delete: tags: - "user" summary: "Delete user" description: "This can only be done by the logged in user." operationId: "deleteUser" produces: - "application/xml" - "application/json" parameters: - name: "username" in: "path" description: "The name that needs to be deleted" required: true type: "string" responses: 400: description: "Invalid username supplied" 404: description: "User not found" securityDefinitions: petstore_auth: type: "oauth2" authorizationUrl: "https://petstore.swagger.io/oauth/authorize" flow: "implicit" scopes: write:pets: "modify pets in your account" read:pets: "read your pets" api_key: type: "apiKey" name: "api_key" in: "header" definitions: Order: type: "object" properties: id: type: "integer" format: "int64" petId: type: "integer" format: "int64" quantity: type: "integer" format: "int32" shipDate: type: "string" format: "date-time" status: type: "string" description: "Order Status" enum: - "placed" - "approved" - "delivered" complete: type: "boolean" default: false xml: name: "Order" User: type: "object" properties: id: type: "integer" format: "int64" username: type: "string" firstName: type: "string" lastName: type: "string" email: type: "string" password: type: "string" phone: type: "string" userStatus: type: "integer" format: "int32" description: "User Status" xml: name: "User" Category: type: "object" properties: id: type: "integer" format: "int64" name: type: "string" xml: name: "Category" Tag: type: "object" properties: id: type: "integer" format: "int64" name: type: "string" xml: name: "Tag" Pet: type: "object" required: - "name" - "photoUrls" properties: id: type: "integer" format: "int64" category: $ref: "#/definitions/Category" name: type: "string" example: "doggie" photoUrls: type: "array" xml: name: "photoUrl" wrapped: true items: type: "string" tags: type: "array" xml: name: "tag" wrapped: true items: $ref: "#/definitions/Tag" status: type: "string" description: "pet status in the store" enum: - "available" - "pending" - "sold" xml: name: "Pet" ApiResponse: type: "object" properties: code: type: "integer" format: "int32" type: type: "string" message: type: "string" externalDocs: description: "Find out more about Swagger" url: "http://swagger.io" ================================================ FILE: codegen/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 codegen org.apache.servicecomb.toolkit core io.swagger swagger-codegen org.checkerframework checker-compat-qual com.google.guava listenablefuture org.slf4j slf4j-simple org.apache.logging.log4j log4j-slf4j-impl org.apache.logging.log4j log4j-api org.apache.logging.log4j log4j-core org.apache.logging.log4j log4j-jcl junit junit test org.apache.maven.plugins maven-compiler-plugin src/main/resources **/*.* ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/AbstractConsumerDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.SupportingFile; public abstract class AbstractConsumerDirectoryStrategy extends AbstractDirectoryStrategy { @Override public void processSupportingFile(List supportingFiles) { correctServiceId(); } private void correctServiceId() { String serviceId = (String) propertiesMap.get(ProjectMetaConstant.SERVICE_ID); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.CONSUMER_SERVICE_ID, key -> { if (StringUtils.isNotEmpty(serviceId)) { return serviceId; } return propertiesMap.get("artifactId"); }); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_SERVICE_ID, key -> { throw new UnsupportedOperationException("In consumer type, providerServiceId is required"); }); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/AbstractDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.io.File; import java.util.Collections; import java.util.List; import java.util.Map; import org.openapitools.codegen.SupportingFile; public abstract class AbstractDirectoryStrategy implements DirectoryStrategy> { protected Map propertiesMap = Collections.emptyMap(); protected String projectFolder = "src" + File.separator + "main"; protected String sourceFolder = projectFolder + File.separator + "java"; @Override public void addCustomProperties(Map propertiesMap) { this.propertiesMap = propertiesMap; } protected String mainClassFolder(String projectPath) { return projectPath + File.separator + sourceFolder + File.separator + ((String) propertiesMap .get("mainClassPackage")).replace(".", File.separator); } protected String resourcesFolder(String projectPath) { return projectPath + File.separator + projectFolder + File.separator + "resources"; } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/AbstractJavaCodegenExt.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.languages.AbstractJavaCodegen; import org.openapitools.codegen.languages.SpringCodegen; public abstract class AbstractJavaCodegenExt extends AbstractJavaCodegen { protected final Map directoryStrategyMap = new LinkedHashMap<>(); protected DirectoryStrategy currentDirectoryStrategy; protected String mainClassPackage; public AbstractJavaCodegenExt() { modelDocTemplateFiles.remove("model_doc.mustache"); apiDocTemplateFiles.remove("api_doc.mustache"); apiTestTemplateFiles.remove("api_test.mustache"); groupId = "domain.orgnization.project"; artifactId = "sample"; apiPackage = groupId + "." + artifactId + ".api"; modelPackage = groupId + "." + artifactId + ".model"; mainClassPackage = groupId + "." + artifactId; } @Override public void processOpts() { super.processOpts(); if (StringUtils.isEmpty((String) additionalProperties.get("mainClassPackage"))) { mainClassPackage = apiPackage.substring(0, apiPackage.lastIndexOf(".")); additionalProperties.put("mainClassPackage", mainClassPackage); } else { mainClassPackage = (String) additionalProperties.get("mainClassPackage"); } } @Override public Map postProcessModelsEnum(Map objs) { objs = super.postProcessModelsEnum(objs); SpringCodegen springCodegen = new SpringCodegen(); return springCodegen.postProcessModelsEnum(objs); } @Override public Map postProcessOperationsWithModels(Map objs, List allModels) { SpringCodegen springCodegen = new SpringCodegen(); return springCodegen.postProcessOperationsWithModels(objs, allModels); } @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { super.postProcessModelProperty(model, property); model.imports.remove("ApiModelProperty"); model.imports.remove("ApiModel"); } /** * Register a custom VersionStrategy to apply to resource URLs that match the * given path patterns. * @param strategy the custom strategy * @param serviceTypes one or more service type, * relative to the service type that represent microservice type of generated microservice project * @see DirectoryStrategy */ public void addDirectoryStrategy(DirectoryStrategy strategy, String... serviceTypes) { for (String serviceType : serviceTypes) { getStrategyMap().put(serviceType, strategy); } } /** * Return the map with directory strategies keyed by service type. */ public Map getStrategyMap() { return this.directoryStrategyMap; } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/AbstractMultiDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.SupportingFile; public abstract class AbstractMultiDirectoryStrategy extends AbstractDirectoryStrategy { @Override public void processSupportingFile(List supportingFiles) { correctServiceId(); } private void correctServiceId() { String serviceId = (String) propertiesMap.get(ProjectMetaConstant.SERVICE_ID); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.CONSUMER_SERVICE_ID, key -> { if (StringUtils.isNotEmpty(serviceId)) { return String.format("%s-consumer", serviceId); } return consumerDirectory(); }); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_SERVICE_ID, key -> { if (StringUtils.isNotEmpty(serviceId)) { return serviceId; } return providerDirectory(); }); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/AbstractProviderDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import org.openapitools.codegen.SupportingFile; public abstract class AbstractProviderDirectoryStrategy extends AbstractDirectoryStrategy { @Override public void processSupportingFile(List supportingFiles) { correctServiceId(); } private void correctServiceId() { propertiesMap .computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_SERVICE_ID, key -> propertiesMap.get("artifactId")); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/ConsumerDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import java.util.Map; import org.openapitools.codegen.SupportingFile; public class ConsumerDirectoryStrategy extends AbstractConsumerDirectoryStrategy { private String consumerTemplateFolder = "consumer"; private String apiConsumerTemplate = consumerTemplateFolder + "/apiConsumer.mustache"; private String apiConsumerTemplateForPojo = consumerTemplateFolder + "/pojo/apiConsumer.mustache"; private String apiInterfaceTemplateForPojo = consumerTemplateFolder + "/pojo/apiInterface.mustache"; @Override public String modelDirectory() { return consumerDirectory(); } @Override public String providerDirectory() { throw new UnsupportedOperationException(); } @Override public String consumerDirectory() { return (String) propertiesMap.get("artifactId"); } @Override public void processSupportingFile(List supportingFiles) { super.processSupportingFile(supportingFiles); String newConsumerTemplateFolder = consumerTemplateFolder; if (ServiceCombCodegen.SPRING_BOOT_LIBRARY.equals(propertiesMap.get("library"))) { newConsumerTemplateFolder += "/springboot"; } supportingFiles.add(new SupportingFile(newConsumerTemplateFolder + "/pom.mustache", consumerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile(newConsumerTemplateFolder + "/Application.mustache", mainClassFolder(consumerDirectory()), "Application.java") ); supportingFiles.add(new SupportingFile("log4j2.mustache", resourcesFolder(consumerDirectory()), "log4j2.xml") ); supportingFiles.add(new SupportingFile(consumerTemplateFolder + "/microservice.mustache", resourcesFolder(consumerDirectory()), "microservice.yaml") ); propertiesMap .computeIfAbsent(GeneratorExternalConfigConstant.CONSUMER_ARTIFACT_ID, k -> propertiesMap.get("artifactId")); propertiesMap.put("apiConsumerTemplate", apiConsumerTemplate); propertiesMap.put("apiConsumerTemplateForPojo", apiConsumerTemplateForPojo); Map apiTemplateFiles = ((Map) propertiesMap.get("apiTemplateFiles")); apiTemplateFiles.remove("api.mustache"); if (ServiceCombCodegen.POJO_LIBRARY.equals(propertiesMap.get("library"))) { apiTemplateFiles.put(apiConsumerTemplateForPojo, "Consumer.java"); apiTemplateFiles.put(apiInterfaceTemplateForPojo, ".java"); propertiesMap.put("isPOJO", true); } else { apiTemplateFiles.put(apiConsumerTemplate, ".java"); } } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/DefaultCodeGenerator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import java.util.Map; import org.apache.servicecomb.toolkit.CodeGenerator; import org.openapitools.codegen.config.CodegenConfigurator; public class DefaultCodeGenerator implements CodeGenerator { private MultiContractGenerator generator = new MultiContractGenerator(); @Override public boolean canProcess(String type) { return "default".equals(type); } @Override public void configure(Map config) { generator.setGenerateMetadata(false); List optsList = (List) config.get("configurators"); if (optsList == null) { generator.addOpts(((CodegenConfigurator) config.get("configurator")).toClientOptInput()); return; } optsList.forEach(opts -> { generator.addOpts(opts.toClientOptInput()); }); } @Override public void generate() { generator.generate(); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/DefaultDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import java.util.Map; import java.util.Optional; import org.openapitools.codegen.SupportingFile; public class DefaultDirectoryStrategy extends AbstractMultiDirectoryStrategy { protected String providerTemplateFolder = "provider"; private String consumerTemplateFolder = "consumer"; private String apiConsumerTemplate = consumerTemplateFolder + "/apiConsumer.mustache"; private String apiConsumerTemplateForPojo = consumerTemplateFolder + "/pojo/apiConsumer.mustache"; private String apiInterfaceTemplateForPojo = consumerTemplateFolder + "/pojo/apiInterface.mustache"; @Override public String modelDirectory() { return Optional.ofNullable((String) propertiesMap.get(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME)) .orElse("model"); } @Override public String providerDirectory() { return Optional.ofNullable((String) propertiesMap.get(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME)) .orElse("provider"); } @Override public String consumerDirectory() { return Optional.ofNullable((String) propertiesMap.get(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME)) .orElse("consumer"); } @Override public void processSupportingFile(List supportingFiles) { super.processSupportingFile(supportingFiles); processProvider(supportingFiles); processConsumer(supportingFiles); processModel(supportingFiles); processParentProjectOpts(supportingFiles); propertiesMap.put("isMultipleModule", true); } private void processParentProjectOpts(List supportingFiles) { supportingFiles.add(new SupportingFile("project/pom.mustache", "", "pom.xml") ); } private void processModel(List supportingFiles) { propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.MODEL_ARTIFACT_ID, k -> modelDirectory()); supportingFiles.add(new SupportingFile("model/pom.mustache", modelDirectory(), "pom.xml") ); } private void processConsumer(List supportingFiles) { String newConsumerTemplateFolder = consumerTemplateFolder; if (ServiceCombCodegen.SPRING_BOOT_LIBRARY.equals(propertiesMap.get("library"))) { newConsumerTemplateFolder += "/springboot"; } supportingFiles.add(new SupportingFile(newConsumerTemplateFolder + "/pom.mustache", consumerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile(newConsumerTemplateFolder + "/Application.mustache", mainClassFolder(consumerDirectory()), "Application.java") ); supportingFiles.add(new SupportingFile("log4j2.mustache", resourcesFolder(consumerDirectory()), "log4j2.xml") ); supportingFiles.add(new SupportingFile(consumerTemplateFolder + "/microservice.mustache", resourcesFolder(consumerDirectory()), "microservice.yaml") ); propertiesMap .computeIfAbsent(GeneratorExternalConfigConstant.CONSUMER_ARTIFACT_ID, k -> consumerDirectory()); // propertiesMap.put("apiConsumerTemplate", apiConsumerTemplate); propertiesMap.put(apiConsumerTemplate, ServiceType.CONSUMER.getValue()); Map apiTemplateFiles = ((Map) propertiesMap.get("apiTemplateFiles")); if (ServiceCombCodegen.POJO_LIBRARY.equals(propertiesMap.get("library"))) { apiTemplateFiles.put(apiConsumerTemplateForPojo, "Consumer.java"); propertiesMap.put(apiConsumerTemplateForPojo, ServiceType.CONSUMER.getValue()); apiTemplateFiles.put(apiInterfaceTemplateForPojo, ".java"); propertiesMap.put(apiInterfaceTemplateForPojo, ServiceType.CONSUMER.getValue()); propertiesMap.put("isPOJO", true); } else { apiTemplateFiles.put(apiConsumerTemplate, ".java"); } } private void processProvider(List supportingFiles) { supportingFiles.add(new SupportingFile("pom.mustache", providerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile("Application.mustache", mainClassFolder(providerDirectory()), "Application.java") ); supportingFiles.add(new SupportingFile("log4j2.mustache", resourcesFolder(providerDirectory()), "log4j2.xml") ); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/microservice.mustache", resourcesFolder(providerDirectory()), "microservice.yaml") ); propertiesMap .computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_ARTIFACT_ID, k -> providerDirectory()); if (ServiceCombCodegen.POJO_LIBRARY.equals(propertiesMap.get("library"))) { // ((Map) propertiesMap.get("apiTemplateFiles")).put(pojoApiImplTemplate, ".java"); propertiesMap.put("isPOJO", true); } } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/DirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.Map; public interface DirectoryStrategy { String modelDirectory(); String providerDirectory(); String consumerDirectory(); void processSupportingFile(T t); void addCustomProperties(Map propertiesMap); } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/GeneratorExternalConfigConstant.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; public class GeneratorExternalConfigConstant { public final static String PROVIDER_PROJECT_NAME = "providerProjectName"; public final static String CONSUMER_PROJECT_NAME = "consumerProjectName"; public final static String MODEL_PROJECT_NAME = "modelProjectName"; public final static String PROVIDER_ARTIFACT_ID = "providerArtifactId"; public final static String CONSUMER_ARTIFACT_ID = "consumerArtifactId"; public final static String MODEL_ARTIFACT_ID = "modelArtifactId"; public final static String MICRO_SERVICE_FRAMEWORK = "microServiceFramework"; public final static String PROVIDER_SERVICE_ID = "providerServiceId"; public final static String CONSUMER_SERVICE_ID = "consumerServiceId"; } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/GetGenericClassTypeLambda.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.io.IOException; import java.io.Writer; import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Template; public class GetGenericClassTypeLambda implements Mustache.Lambda { @Override public void execute(Template.Fragment fragment, Writer writer) throws IOException { String text = fragment.execute(); if (text.contains("<")) { String className = text.substring(0, text.indexOf("<")); text = "(Class<" + text + ">)(Class)" + className; } writer.write(text); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/GetRelativeBasePathLambda.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.io.IOException; import java.io.Writer; import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Template.Fragment; public class GetRelativeBasePathLambda implements Mustache.Lambda { private static String HOST_PORT_PATTERN = "(\\w+://)([\\w\\.]+)?(:\\d*)?/?"; @Override public void execute(Fragment fragment, Writer writer) throws IOException { String text = fragment.execute(); String relativeBasePath = text.replaceAll(HOST_PORT_PATTERN, "/"); writer.write(relativeBasePath); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/MicroServiceFramework.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; public enum MicroServiceFramework { // ServiceComb SERVICECOMB, // SpringCloud SPRINGCLOUD } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/MultiContractGenerator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import org.openapitools.codegen.ClientOptInput; import org.openapitools.codegen.DefaultGenerator; import org.openapitools.codegen.Generator; public class MultiContractGenerator extends DefaultGenerator { private List optsList = new ArrayList<>(); public Generator addOpts(ClientOptInput opts) { optsList.add(opts); return this; } public void generateParentProject(List files, List> modules) { this.config = optsList.get(0).getConfig(); String outputFilename = opts.getConfig().outputFolder() + File.separator + "pom.xml"; if (!config.shouldOverwrite(outputFilename)) { LOGGER.info("Skipped overwriting " + outputFilename); } Map templateData = this.config.additionalProperties(); templateData.put("modules", modules); try { files.add(processTemplateToFile(templateData, "project/pom.mustache", outputFilename)); } catch (IOException e) { throw new RuntimeException("Failed to generate parent project pom.xml", e); } } @Override public List generate() { if (optsList == null || optsList.size() == 0) { return null; } List fileList = new ArrayList<>(); List> modules = new ArrayList<>(); Set moduleSet = new HashSet<>(); for (ClientOptInput opts : optsList) { moduleSet.add(opts.getConfig().additionalProperties().get(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME)); moduleSet.add(opts.getConfig().additionalProperties().get(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME)); moduleSet.add(opts.getConfig().additionalProperties().get(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME)); this.opts(opts); fileList.addAll(super.generate()); } moduleSet.forEach(module -> { modules.add(Collections.singletonMap("module", module)); }); if (ServiceType.ALL.getValue().equals( Optional.ofNullable(opts.getConfig().additionalProperties().get(ProjectMetaConstant.SERVICE_TYPE)) .orElse(ServiceType.ALL.getValue()))) { generateParentProject(fileList, modules); } return fileList; } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/ProjectMetaConstant.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; public class ProjectMetaConstant { public static final String SERVICE_TYPE = "serviceType"; public static final String PROVIDER_SERVICE_ID = "providerServiceId"; public static final String SERVICE_ID = "serviceId"; } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/ProviderDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import org.openapitools.codegen.SupportingFile; public class ProviderDirectoryStrategy extends AbstractProviderDirectoryStrategy { protected String providerTemplateFolder = "provider"; @Override public String modelDirectory() { return providerDirectory(); } @Override public String providerDirectory() { return (String) propertiesMap.get("artifactId"); } @Override public String consumerDirectory() { throw new UnsupportedOperationException(); } @Override public void processSupportingFile(List supportingFiles) { super.processSupportingFile(supportingFiles); supportingFiles.add(new SupportingFile("pom.mustache", providerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile("Application.mustache", mainClassFolder(providerDirectory()), "Application.java") ); supportingFiles.add(new SupportingFile("log4j2.mustache", resourcesFolder(providerDirectory()), "log4j2.xml") ); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/microservice.mustache", resourcesFolder(providerDirectory()), "microservice.yaml") ); propertiesMap .computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_ARTIFACT_ID, k -> propertiesMap.get("artifactId")); propertiesMap .put(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, providerDirectory()); if (ServiceCombCodegen.POJO_LIBRARY.equals(propertiesMap.get("library"))) { // ((Map) propertiesMap.get("apiTemplateFiles")).put(pojoApiImplTemplate, ".java"); propertiesMap.put("isPOJO", true); } propertiesMap.put("isMultipleModule", false); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/ServiceCombCodegen.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import static org.openapitools.codegen.utils.StringUtils.camelize; import java.io.File; import java.util.List; import java.util.Map; import java.util.Optional; import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.languages.SpringCodegen; import io.swagger.codegen.mustache.CamelCaseLambda; public class ServiceCombCodegen extends AbstractJavaCodegenExt { public static final String DEFAULT_LIBRARY = "SpringMVC"; public static final String POJO_LIBRARY = "POJO"; public static final String JAX_RS_LIBRARY = "JAX-RS"; public static final String SPRING_BOOT_LIBRARY = "SpringBoot"; private String applicationId = "defaultApp"; private String serviceId = "defaultService"; private String modelTemplateFolder = "model"; @Override public CodegenType getTag() { return CodegenType.SERVER; } @Override public String getName() { return "ServiceComb"; } @Override public String getHelp() { return "Generates a ServiceComb server library."; } public ServiceCombCodegen() { super(); outputFolder = "generated-code/ServiceComb"; embeddedTemplateDir = templateDir = "ServiceComb"; modelTemplateFiles.put(modelTemplateFolder + "/model.mustache", ".java"); modelTemplateFiles.remove("model.mustache"); supportedLibraries.put(DEFAULT_LIBRARY, "ServiceComb Server application using the SpringMVC programming model."); supportedLibraries.put(POJO_LIBRARY, "ServiceComb Server application using the POJO programming model."); supportedLibraries.put(JAX_RS_LIBRARY, "ServiceComb Server application using the JAX-RS programming model."); supportedLibraries .put(SPRING_BOOT_LIBRARY, "ServiceComb Server application using the SpringBoot programming model."); setLibrary(DEFAULT_LIBRARY); CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); library.setEnum(supportedLibraries); library.setDefault(DEFAULT_LIBRARY); cliOptions.add(library); addDirectoryStrategy(new ProviderDirectoryStrategy(), ServiceType.PROVIDER.getValue()); addDirectoryStrategy(new ConsumerDirectoryStrategy(), ServiceType.CONSUMER.getValue()); addDirectoryStrategy(new DefaultDirectoryStrategy(), ServiceType.ALL.getValue()); } @Override public String modelFileFolder() { return outputFolder + "/" + currentDirectoryStrategy.modelDirectory() + "/" + sourceFolder + "/" + modelPackage() .replace('.', '/'); } @Override public String apiFileFolder() { return outputFolder + "/" + currentDirectoryStrategy.providerDirectory() + "/" + sourceFolder + "/" + apiPackage() .replace('.', '/'); } @Override public String apiFilename(String templateName, String tag) { if (ServiceType.CONSUMER.getValue().equals(additionalProperties.get(ProjectMetaConstant.SERVICE_TYPE)) || ServiceType.CONSUMER.getValue().equals(additionalProperties.get(templateName))) { String suffix = apiTemplateFiles().get(templateName); return apiConsumerFolder() + File.separator + toApiFilename(tag) + suffix; } return super.apiFilename(templateName, tag); } private String apiConsumerFolder() { return outputFolder + "/" + currentDirectoryStrategy.consumerDirectory() + "/" + sourceFolder + "/" + apiPackage() .replace('.', '/'); } @Override public Map postProcessOperationsWithModels(Map objs, List allModels) { Map operations = (Map) objs.get("operations"); String classnameImpl = operations.get("classname") + "Impl"; operations.put("classnameImpl", classnameImpl); additionalProperties.put("classnameImpl", classnameImpl); return super.postProcessOperationsWithModels(objs, allModels); } @Override public void processOpts() { super.processOpts(); importMapping.put("OffsetDateTime", "java.time.OffsetDateTime"); additionalProperties.put("dateLibrary", "java8"); additionalProperties.put("camelcase", new CamelCaseLambda()); additionalProperties.put("getGenericClassType", new GetGenericClassTypeLambda()); additionalProperties.put("getRelativeBasePath", new GetRelativeBasePathLambda()); additionalProperties.put("applicationId", applicationId); additionalProperties.put("library", getLibrary()); additionalProperties.put("outputFolder", outputFolder); additionalProperties.put("apiTemplateFiles", apiTemplateFiles); additionalProperties.put("apiTestTemplateFiles", apiTestTemplateFiles); additionalProperties.put("modelTemplateFiles", modelTemplateFiles); additionalProperties.put("apiDocTemplateFiles", apiDocTemplateFiles); if (additionalProperties.get(ProjectMetaConstant.SERVICE_ID) != null) { serviceId = (String) additionalProperties.get(ProjectMetaConstant.SERVICE_ID); } additionalProperties.put(ProjectMetaConstant.SERVICE_ID, serviceId); currentDirectoryStrategy = getStrategyMap() .get(Optional.ofNullable(additionalProperties.get(ProjectMetaConstant.SERVICE_TYPE)) .orElse(ServiceType.ALL.getValue())); // when all additionalProperties are processed currentDirectoryStrategy.addCustomProperties(additionalProperties); currentDirectoryStrategy.processSupportingFile(supportingFiles); } @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { super.postProcessModelProperty(model, property); model.imports.remove("ApiModelProperty"); model.imports.remove("ApiModel"); } @Override public Map postProcessModelsEnum(Map objs) { objs = super.postProcessModelsEnum(objs); SpringCodegen springCodegen = new SpringCodegen(); return springCodegen.postProcessModelsEnum(objs); } @Override public String toApiName(String name) { if (name.length() == 0) { return "DefaultApi"; } String apiName = (String) additionalProperties.get("apiName"); if (apiName != null) { return apiName; } return camelize(name) + "Api"; } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/ServiceType.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; public enum ServiceType { /** * both consumer and provider */ ALL, /** * only consumer project */ CONSUMER, /** * only provider project */ PROVIDER; public String getValue() { return toString().toLowerCase(); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/ShowBasePathLambda.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.io.IOException; import java.io.Writer; import java.util.regex.Matcher; import java.util.regex.Pattern; import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Template.Fragment; public class ShowBasePathLambda implements Mustache.Lambda { private Pattern pattern = Pattern.compile("\"[ ]*[/]*[ ]*\""); @Override public void execute(Fragment fragment, Writer writer) throws IOException { String text = fragment.execute(); Matcher matcher = pattern.matcher(text); if (matcher.find()) { return; } writer.write(text); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/SpringCloudCodegen.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import static org.openapitools.codegen.utils.StringUtils.camelize; import java.io.File; import java.util.List; import java.util.Map; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.templating.mustache.CamelCaseLambda; public class SpringCloudCodegen extends AbstractJavaCodegenExt { private String applicationId = "defaultApp"; private String serviceId = "defaultService"; private String consumerTemplateFolder = "consumer/openfeign"; private String providerTemplateFolder = "provider/servlet"; private String modelTemplateFolder = "model"; private String apiConsumerTemplate = consumerTemplateFolder + "/apiConsumer.mustache"; public SpringCloudCodegen() { super(); outputFolder = "generated-code/SpringCloud"; apiTemplateFiles.remove("api.mustache"); apiTemplateFiles.put(providerTemplateFolder + "/api.mustache", ".java"); embeddedTemplateDir = templateDir = "SpringCloud"; modelTemplateFiles.put(modelTemplateFolder + "/model.mustache", ".java"); modelTemplateFiles.remove("model.mustache"); addDirectoryStrategy(new SpringCloudProviderDirectoryStrategy(), ServiceType.PROVIDER.getValue()); addDirectoryStrategy(new SpringCloudConsumerDirectoryStrategy(), ServiceType.CONSUMER.getValue()); addDirectoryStrategy(new SpringCloudMultiDirectoryStrategy(), ServiceType.ALL.getValue()); } @Override public void processOpts() { super.processOpts(); importMapping.put("OffsetDateTime", "java.time.OffsetDateTime"); additionalProperties.put("dateLibrary", "java8"); additionalProperties.put("camelcase", new CamelCaseLambda()); additionalProperties.put("apiTemplateFiles", apiTemplateFiles); additionalProperties.put("getGenericClassType", new GetGenericClassTypeLambda()); additionalProperties.put("getRelativeBasePath", new GetRelativeBasePathLambda()); additionalProperties.put("showBasePath", new ShowBasePathLambda()); additionalProperties.put("applicationId", applicationId); if (additionalProperties.get(ProjectMetaConstant.SERVICE_ID) != null) { serviceId = (String) additionalProperties.get(ProjectMetaConstant.SERVICE_ID); } additionalProperties.put(ProjectMetaConstant.SERVICE_ID, serviceId); currentDirectoryStrategy = getStrategyMap() .get(Optional.ofNullable(additionalProperties.get(ProjectMetaConstant.SERVICE_TYPE)) .orElse(ServiceType.ALL.getValue())); // when all additionalProperties are processed currentDirectoryStrategy.addCustomProperties(additionalProperties); currentDirectoryStrategy.processSupportingFile(supportingFiles); } @Override public String toApiName(String name) { if (name.length() == 0) { return "DefaultApi"; } String apiName = (String) additionalProperties.get("apiName"); if (apiName != null) { return apiName; } return camelize(name) + "Api"; } @Override public String apiFileFolder() { return outputFolder + "/" + currentDirectoryStrategy.providerDirectory() + "/" + sourceFolder + "/" + apiPackage() .replace('.', '/'); } @Override public String apiFilename(String templateName, String tag) { if (ServiceType.CONSUMER.getValue().equals(additionalProperties.get(ProjectMetaConstant.SERVICE_TYPE)) || ServiceType.CONSUMER.getValue().equals(additionalProperties.get(templateName))) { String suffix = apiTemplateFiles().get(templateName); return apiConsumerFolder() + File.separator + toApiFilename(tag) + suffix; } return super.apiFilename(templateName, tag); } private String apiConsumerFolder() { return outputFolder + "/" + currentDirectoryStrategy.consumerDirectory() + "/" + sourceFolder + "/" + apiPackage() .replace('.', '/'); } @Override public String modelFileFolder() { return outputFolder + "/" + currentDirectoryStrategy.modelDirectory() + "/" + sourceFolder + "/" + modelPackage() .replace('.', '/'); } @Override public Map postProcessOperationsWithModels(Map objs, List allModels) { Map operations = (Map) objs.get("operations"); String classnameImpl = (String) operations.get("classname") + "Impl"; operations.put("classnameImpl", classnameImpl); additionalProperties.put("classnameImpl", classnameImpl); return super.postProcessOperationsWithModels(objs, allModels); } @Override public CodegenType getTag() { return CodegenType.SERVER; } @Override public String getName() { return "SpringCloud"; } @Override public String getHelp() { return "Generates a SpringCloud server library."; } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/SpringCloudConsumerDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.SupportingFile; public class SpringCloudConsumerDirectoryStrategy extends AbstractConsumerDirectoryStrategy { private String consumerTemplateFolder = "consumer/openfeign"; private String apiConsumerTemplate = consumerTemplateFolder + "/apiConsumer.mustache"; @Override public String modelDirectory() { return consumerDirectory(); } @Override public String providerDirectory() { throw new UnsupportedOperationException(); } @Override public String consumerDirectory() { return (String) propertiesMap.get("artifactId"); } @Override public void processSupportingFile(List supportingFiles) { super.processSupportingFile(supportingFiles); supportingFiles.add(new SupportingFile(consumerTemplateFolder + "/applicationYml.mustache", resourcesFolder(consumerDirectory()), "application.yml")); supportingFiles.add(new SupportingFile(consumerTemplateFolder + "/pom.mustache", consumerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile(consumerTemplateFolder + "/Application.mustache", mainClassFolder(consumerDirectory()), "Application.java") ); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.CONSUMER_ARTIFACT_ID, k -> consumerDirectory()); propertiesMap .put(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME, consumerDirectory()); propertiesMap.put(apiConsumerTemplate, ServiceType.CONSUMER.getValue()); Map apiTemplateFiles = ((Map) propertiesMap.get("apiTemplateFiles")); apiTemplateFiles.remove("api.mustache"); apiTemplateFiles.put(apiConsumerTemplate, ".java"); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/SpringCloudMultiDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import java.util.Map; import java.util.Optional; import org.openapitools.codegen.SupportingFile; public class SpringCloudMultiDirectoryStrategy extends AbstractMultiDirectoryStrategy { private String consumerTemplateFolder = "consumer/openfeign"; private String providerTemplateFolder = "provider/servlet"; private String apiConsumerTemplate = consumerTemplateFolder + "/apiConsumer.mustache"; @Override public String modelDirectory() { return Optional.ofNullable((String) propertiesMap.get(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME)) .orElse("model"); } @Override public String providerDirectory() { return Optional.ofNullable((String) propertiesMap.get(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME)) .orElse("provider"); } @Override public String consumerDirectory() { return Optional.ofNullable((String) propertiesMap.get(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME)) .orElse("consumer"); } @Override public void processSupportingFile(List supportingFiles) { super.processSupportingFile(supportingFiles); processProvider(supportingFiles); processConsumer(supportingFiles); processModel(supportingFiles); propertiesMap.put("isMultipleModule", true); supportingFiles.add(new SupportingFile("project/pom.mustache", "", "pom.xml") ); } private void processModel(List supportingFiles) { propertiesMap .computeIfAbsent(GeneratorExternalConfigConstant.MODEL_ARTIFACT_ID, k -> modelDirectory()); propertiesMap.put(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME, modelDirectory()); supportingFiles.add(new SupportingFile("model/pom.mustache", modelDirectory(), "pom.xml") ); } private void processProvider(List supportingFiles) { supportingFiles.add(new SupportingFile(providerTemplateFolder + "/applicationYml.mustache", resourcesFolder(providerDirectory()), "application.yml")); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/pom.mustache", providerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/Application.mustache", mainClassFolder(providerDirectory()), "Application.java") ); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_ARTIFACT_ID, k -> providerDirectory()); propertiesMap .put(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, providerDirectory()); } private void processConsumer(List supportingFiles) { supportingFiles.add(new SupportingFile(consumerTemplateFolder + "/applicationYml.mustache", resourcesFolder(consumerDirectory()), "application.yml")); supportingFiles.add(new SupportingFile(consumerTemplateFolder + "/pom.mustache", consumerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile(consumerTemplateFolder + "/Application.mustache", mainClassFolder(consumerDirectory()), "Application.java") ); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.CONSUMER_ARTIFACT_ID, k -> consumerDirectory()); propertiesMap .put(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME, consumerDirectory()); propertiesMap.put(apiConsumerTemplate, ServiceType.CONSUMER.getValue()); Map apiTemplateFiles = ((Map) propertiesMap.get("apiTemplateFiles")); apiTemplateFiles.put(apiConsumerTemplate, ".java"); } } ================================================ FILE: codegen/src/main/java/org/apache/servicecomb/toolkit/codegen/SpringCloudProviderDirectoryStrategy.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.List; import org.openapitools.codegen.SupportingFile; public class SpringCloudProviderDirectoryStrategy extends AbstractProviderDirectoryStrategy { private String providerTemplateFolder = "provider/servlet"; @Override public String modelDirectory() { return providerDirectory(); } @Override public String providerDirectory() { return (String) propertiesMap.get("artifactId"); } @Override public String consumerDirectory() { throw new UnsupportedOperationException(); } @Override public void processSupportingFile(List supportingFiles) { super.processSupportingFile(supportingFiles); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/applicationYml.mustache", resourcesFolder(providerDirectory()), "application.yml")); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/pom.mustache", providerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/Application.mustache", mainClassFolder(providerDirectory()), "Application.java") ); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_ARTIFACT_ID, k -> providerDirectory()); propertiesMap .put(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, providerDirectory()); } } ================================================ FILE: codegen/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.CodeGenerator ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.apache.servicecomb.toolkit.codegen.DefaultCodeGenerator ================================================ FILE: codegen/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.apache.servicecomb.toolkit.codegen.ServiceCombCodegen org.apache.servicecomb.toolkit.codegen.SpringCloudCodegen ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/Application.mustache ================================================ package {{mainClassPackage}}; import org.apache.servicecomb.foundation.common.utils.BeanUtils; public class Application { public static void main(String[] args) throws Exception { BeanUtils.init(); } } ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/apiConsumer.mustache ================================================ package {{apiPackage}}; import static org.springframework.http.MediaType.*; import java.util.List; import java.util.Map; import java.util.HashMap; {{#imports}}import {{import}}; {{/imports}} import org.apache.servicecomb.provider.rest.common.RestSchema; import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; import org.springframework.util.MultiValueMap; import org.springframework.http.*; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; {{#operations}} public class {{classname}} { {{#operation}} public ResponseEntity<{{>returnTypes}}> {{operationId}}({{#allParams}}{{>consumer/queryParamsConsumer}}{{>consumer/pathParamsConsumer}}{{>consumer/headerParamsConsumer}}{{>consumer/bodyParamsConsumer}}{{>consumer/formParamsConsumer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { Map params = new HashMap<>(); HttpEntity httpEntity = null; HttpHeaders headers = new HttpHeaders(); {{#allParams}} {{#isPathParam}} params.put("{{paramName}}",{{paramName}}); {{/isPathParam}} {{#isQueryParam}} params.put("{{paramName}}",{{paramName}}); {{/isQueryParam}} {{#isHeaderParam}} headers.add("{{paramName}}",{{paramName}}); {{/isHeaderParam}} {{#isFormParam}} {{^isFile}} httpEntity = new HttpEntity<{{{dataType}}}>({{paramName}}, headers); {{/isFile}} {{#isFile}} httpEntity = new HttpEntity({{paramName}}, headers); {{/isFile}} {{/isFormParam}} {{#isBodyParam}} httpEntity = new HttpEntity<{{{dataType}}}>({{paramName}}, headers); {{/isBodyParam}} {{/allParams}} RestTemplate restTemplate = RestTemplateBuilder.create(); ResponseEntity<{{>returnTypes}}> result = restTemplate.exchange("cse://{{providerServiceId}}{{#getRelativeBasePath}}{{basePath}}{{/getRelativeBasePath}}{{path}}",HttpMethod.{{httpMethod}},httpEntity,{{#getGenericClassType}}{{>returnTypes}}{{/getGenericClassType}}.class,params); // do something return result; } {{/operation}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/bodyParamsConsumer.mustache ================================================ {{#isBodyParam}} {{{dataType}}} {{paramName}}{{/isBodyParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/formParamsConsumer.mustache ================================================ {{#isFormParam}}{{^isFile}}{{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}} {{#isPOJO}}File{{/isPOJO}}{{^isPOJO}}MultipartFile{{/isPOJO}} {{baseName}}{{/isFile}}{{/isFormParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/headerParamsConsumer.mustache ================================================ {{#isHeaderParam}} {{{dataType}}} {{paramName}}{{/isHeaderParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/microservice.mustache ================================================ #Indicates an application name APPLICATION_ID: {{applicationId}} service_description: #Indicates a microservice name #The microservice name should be unique within an application. #The name can contain digits, uppercase and lowercase letters, hyphens(-), underscores(_), and periods(.); and can neither start nor end with punctuations. #The naming rule is as follows: ^[a-zA-Z0-9]+$|^[a-zA-Z0-9][a-zA-Z0-9_-.]*[a-zA-Z0-9]$. name: {{consumerServiceId}} #Indicates a service version version: 1.0.0 servicecomb: service: #Specifies the service center IP address. registry: address: http://127.0.0.1:30100 ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/pathParamsConsumer.mustache ================================================ {{#isPathParam}} {{{dataType}}} {{paramName}}{{/isPathParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/pojo/apiConsumer.mustache ================================================ package {{apiPackage}}; import java.util.List; {{#imports}}import {{import}}; {{/imports}} import org.apache.servicecomb.provider.pojo.RpcReference; import org.springframework.stereotype.Component; {{#operations}} @Component public class {{classname}}Consumer{ @RpcReference(microserviceName = "{{providerServiceId}}", schemaId = "{{#camelcase}}{{classname}}{{/camelcase}}") private {{classname}} api; {{#operation}} public {{>returnTypes}} {{operationId}}({{#allParams}}{{>consumer/queryParamsConsumer}}{{>consumer/pathParamsConsumer}}{{>consumer/headerParamsConsumer}}{{>consumer/bodyParamsConsumer}}{{>consumer/formParamsConsumer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { return api.{{operationId}}({{#allParams}}{{#isQueryParam}}{{paramName}}{{/isQueryParam}}{{#isPathParam}}{{paramName}}{{/isPathParam}}{{#isHeaderParam}}{{paramName}}{{/isHeaderParam}}{{#isBodyParam}}{{paramName}}{{/isBodyParam}}{{#isFormParam}}{{paramName}}{{/isFormParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); } {{/operation}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/pojo/apiInterface.mustache ================================================ package {{apiPackage}}; import java.util.List; import java.util.Map; import java.util.HashMap; import java.io.File; {{#imports}}import {{import}}; {{/imports}} {{#operations}} public interface {{classname}} { {{#operation}} public {{>returnTypes}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/operation}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/pom.mustache ================================================ {{#isMultipleModule}} {{artifactId}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} 4.0.0 {{consumerArtifactId}} jar {{^isMultipleModule}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} {{consumerArtifactId}} UTF-8 1.2.0 org.apache.servicecomb java-chassis-dependencies ${java-chassis.version} pom import {{#isMultipleModule}} {{groupId}} {{modelArtifactId}} ${project.version} {{/isMultipleModule}} org.apache.servicecomb handler-bizkeeper org.apache.servicecomb handler-loadbalance org.apache.servicecomb transport-highway org.apache.servicecomb transport-rest-vertx org.apache.servicecomb handler-flowcontrol-qps org.apache.servicecomb provider-pojo org.apache.servicecomb provider-springmvc org.apache.logging.log4j log4j-slf4j-impl org.apache.logging.log4j log4j-api org.apache.logging.log4j log4j-core org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 org.apache.maven.plugins maven-resources-plugin 3.0.0 UTF-8 org.springframework.boot spring-boot-maven-plugin 1.5.12.RELEASE true {{mainClassPackage}}.Application target/bin repackage ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/queryParamsConsumer.mustache ================================================ {{#isQueryParam}}{{{dataType}}} {{paramName}}{{/isQueryParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/springboot/Application.mustache ================================================ package {{mainClassPackage}}; import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @EnableServiceComb public class Application { public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } } ================================================ FILE: codegen/src/main/resources/ServiceComb/consumer/springboot/pom.mustache ================================================ {{#isMultipleModule}} {{artifactId}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} 4.0.0 {{consumerArtifactId}} jar {{^isMultipleModule}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} {{consumerArtifactId}} UTF-8 1.2.0 org.apache.servicecomb java-chassis-dependencies ${java-chassis.version} pom import {{#isMultipleModule}} {{groupId}} {{modelArtifactId}} ${project.version} {{/isMultipleModule}} org.springframework.boot spring-boot-starter org.apache.servicecomb spring-boot-starter-provider org.springframework.boot spring-boot-starter org.apache.servicecomb spring-boot-starter-provider org.apache.servicecomb handler-flowcontrol-qps org.apache.servicecomb handler-bizkeeper org.apache.servicecomb handler-tracing-zipkin org.apache.servicecomb inspector org.hibernate.validator hibernate-validator javax.validation validation-api 2.0.1.Final org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 org.apache.maven.plugins maven-resources-plugin 3.0.0 UTF-8 org.springframework.boot spring-boot-maven-plugin 1.5.12.RELEASE true {{mainClassPackage}}.Application target/bin repackage ================================================ FILE: codegen/src/main/resources/ServiceComb/enumClass.mustache ================================================ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { {{#gson}} {{#allowableValues}} {{#enumVars}} @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}} {{/enumVars}} {{/allowableValues}} {{/gson}} {{^gson}} {{#allowableValues}} {{#enumVars}} {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}} {{/enumVars}} {{/allowableValues}} {{/gson}} private {{{datatype}}} value; {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) { this.value = value; } @Override public String toString() { return String.valueOf(value); } public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { if (String.valueOf(b.value).equals(text)) { return b; } } return null; } } ================================================ FILE: codegen/src/main/resources/ServiceComb/enumOuterClass.mustache ================================================ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { {{#gson}} {{#allowableValues}}{{#enumVars}} @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} {{/gson}} {{^gson}} {{#allowableValues}}{{#enumVars}} {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} {{/gson}} private {{{dataType}}} value; {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { this.value = value; } @Override public String toString() { return String.valueOf(value); } public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { if (String.valueOf(b.value).equals(text)) { return b; } } return null; } } ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/JAX-RS/Application.mustache ================================================ package {{mainClassPackage}}; import org.apache.servicecomb.foundation.common.utils.BeanUtils; public class Application { public static void main(String[] args) throws Exception { BeanUtils.init(); } } ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/JAX-RS/api.mustache ================================================ package {{apiPackage}}; import java.util.Map; import java.util.List; import java.io.InputStream; import javax.servlet.ServletConfig; import javax.servlet.http.Part; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.*; {{#imports}}import {{import}}; {{/imports}} import org.apache.servicecomb.provider.rest.common.RestSchema; import io.swagger.annotations.ApiParam; {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} {{#operations}} @RestSchema(schemaId = "{{#camelcase}}{{classname}}{{/camelcase}}") @Path("{{#getRelativeBasePath}}{{basePath}}{{/getRelativeBasePath}}") public class {{classname}} { {{#operation}} {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} @Path("{{{path}}}") @{{httpMethod}} public {{>returnTypes}} {{nickname}}({{#allParams}}{{>libraries/JAX-RS/queryParams}}{{>libraries/JAX-RS/pathParams}}{{>libraries/JAX-RS/headerParams}}{{>libraries/JAX-RS/bodyParams}}{{>libraries/JAX-RS/formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) { // do something return null; } {{/operation}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/JAX-RS/bodyParams.mustache ================================================ {{#isBodyParam}} {{{dataType}}} {{paramName}}{{/isBodyParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/JAX-RS/formParams.mustache ================================================ {{#isFormParam}}{{^isFile}} {{#vendorExtensions.x-multipart}} @FormDataParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/isFile}}{{#isFile}} Part {{paramName}}{{/isFile}}{{/isFormParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/JAX-RS/headerParams.mustache ================================================ {{#isHeaderParam}}@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/JAX-RS/pathParams.mustache ================================================ {{#isPathParam}}@PathParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/JAX-RS/pom.mustache ================================================ {{#isMultipleModule}} {{artifactId}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} 4.0.0 {{providerArtifactId}} jar {{^isMultipleModule}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} {{providerArtifactId}} UTF-8 1.2.0 org.apache.servicecomb java-chassis-dependencies ${java-chassis.version} pom import {{#isMultipleModule}} {{groupId}} {{modelArtifactId}} ${project.version} {{/isMultipleModule}} org.apache.servicecomb handler-bizkeeper org.apache.servicecomb handler-loadbalance org.apache.servicecomb handler-flowcontrol-qps org.apache.servicecomb transport-highway org.apache.servicecomb transport-rest-vertx org.apache.servicecomb provider-jaxrs org.apache.logging.log4j log4j-slf4j-impl org.apache.logging.log4j log4j-api org.apache.logging.log4j log4j-core org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 org.apache.maven.plugins maven-resources-plugin 3.0.0 UTF-8 org.springframework.boot spring-boot-maven-plugin 1.5.12.RELEASE true {{mainClassPackage}}.Application target/bin repackage ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/JAX-RS/queryParams.mustache ================================================ {{#isQueryParam}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/POJO/Application.mustache ================================================ package {{mainClassPackage}}; import org.apache.servicecomb.foundation.common.utils.BeanUtils; public class Application { public static void main(String[] args) throws Exception { BeanUtils.init(); } } ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/POJO/api.mustache ================================================ package {{apiPackage}}; import static org.springframework.http.MediaType.*; import java.util.List; import java.util.Map; import java.io.File; {{#imports}}import {{import}}; {{/imports}} import org.apache.servicecomb.provider.pojo.RpcSchema; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; @RpcSchema(schemaId = "{{#camelcase}}{{classname}}{{/camelcase}}") {{#operations}} public class {{classname}} { {{#operation}} public {{>returnTypes}} {{operationId}}({{#allParams}}{{>libraries/POJO/queryParams}}{{>libraries/POJO/pathParams}}{{>libraries/POJO/headerParams}}{{>libraries/POJO/bodyParams}}{{>libraries/POJO/formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { // do something return null; } {{/operation}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/POJO/bodyParams.mustache ================================================ {{#isBodyParam}} {{{dataType}}} {{paramName}}{{/isBodyParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/POJO/formParams.mustache ================================================ {{#isFormParam}}{{^isFile}}{{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}} File {{baseName}}{{/isFile}}{{/isFormParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/POJO/headerParams.mustache ================================================ {{#isHeaderParam}} {{{dataType}}} {{paramName}}{{/isHeaderParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/POJO/pathParams.mustache ================================================ {{#isPathParam}} {{{dataType}}} {{paramName}}{{/isPathParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/POJO/pom.mustache ================================================ {{#isMultipleModule}} {{artifactId}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} 4.0.0 {{providerArtifactId}} jar {{^isMultipleModule}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} {{providerArtifactId}} UTF-8 1.2.0 org.apache.servicecomb java-chassis-dependencies ${java-chassis.version} pom import {{#isMultipleModule}} {{groupId}} {{modelArtifactId}} ${project.version} {{/isMultipleModule}} org.apache.servicecomb handler-bizkeeper org.apache.servicecomb handler-loadbalance org.apache.servicecomb transport-highway org.apache.servicecomb transport-rest-vertx org.apache.servicecomb handler-flowcontrol-qps org.apache.servicecomb provider-pojo org.apache.logging.log4j log4j-slf4j-impl org.apache.logging.log4j log4j-api org.apache.logging.log4j log4j-core org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 org.apache.maven.plugins maven-resources-plugin 3.0.0 UTF-8 org.springframework.boot spring-boot-maven-plugin 1.5.12.RELEASE true {{mainClassPackage}}.Application target/bin repackage ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/POJO/queryParams.mustache ================================================ {{#isQueryParam}} {{{dataType}}} {{paramName}}{{/isQueryParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/Application.mustache ================================================ package {{mainClassPackage}}; import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @EnableServiceComb public class Application { public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } } ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/api.mustache ================================================ package {{apiPackage}}; import static org.springframework.http.MediaType.*; import java.util.List; import java.util.Map; {{#imports}}import {{import}}; {{/imports}} import org.apache.servicecomb.provider.rest.common.RestSchema; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; @RestSchema(schemaId = "{{#camelcase}}{{classname}}{{/camelcase}}") @RequestMapping(value = "{{#getRelativeBasePath}}{{basePath}}{{/getRelativeBasePath}}", produces = {APPLICATION_JSON_VALUE}) {{#operations}} public class {{classname}} { {{>libraries/SpringBoot/operationMethod}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/bodyParams.mustache ================================================ {{#isBodyParam}}@RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/formParams.mustache ================================================ {{#isFormParam}}{{^isFile}}@RequestPart(value="{{paramName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/headerParams.mustache ================================================ {{#isHeaderParam}}@RequestHeader(value="{{paramName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/operationMethod.mustache ================================================ {{#operation}} @RequestMapping(value = "{{path}}", {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}} {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}} method = RequestMethod.{{httpMethod}}) public ResponseEntity<{{>returnTypes}}> {{operationId}}({{#allParams}}{{>libraries/SpringBoot/queryParams}}{{>libraries/SpringBoot/pathParams}}{{>libraries/SpringBoot/headerParams}}{{>libraries/SpringBoot/bodyParams}}{{>libraries/SpringBoot/formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { // do something return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); } {{/operation}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/pathParams.mustache ================================================ {{#isPathParam}}@PathVariable("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/pom.mustache ================================================ {{#isMultipleModule}} {{artifactId}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} 4.0.0 {{providerArtifactId}} jar {{^isMultipleModule}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} {{providerArtifactId}} UTF-8 1.2.0 org.apache.servicecomb java-chassis-dependencies ${java-chassis.version} pom import {{#isMultipleModule}} {{groupId}} {{modelArtifactId}} ${project.version} {{/isMultipleModule}} org.springframework.boot spring-boot-starter org.apache.servicecomb spring-boot-starter-provider org.apache.servicecomb handler-flowcontrol-qps org.apache.servicecomb handler-bizkeeper org.apache.servicecomb handler-tracing-zipkin org.apache.servicecomb inspector org.hibernate.validator hibernate-validator javax.validation validation-api 2.0.1.Final org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 org.apache.maven.plugins maven-resources-plugin 3.0.0 UTF-8 org.springframework.boot spring-boot-maven-plugin 1.5.12.RELEASE true {{mainClassPackage}}.Application target/bin repackage ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringBoot/queryParams.mustache ================================================ {{#isQueryParam}}@RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringMVC/Application.mustache ================================================ package {{mainClassPackage}}; import org.apache.servicecomb.foundation.common.utils.BeanUtils; public class Application { public static void main(String[] args) throws Exception { BeanUtils.init(); } } ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringMVC/api.mustache ================================================ package {{apiPackage}}; import static org.springframework.http.MediaType.*; import java.util.List; import java.util.Map; {{#imports}}import {{import}}; {{/imports}} import org.apache.servicecomb.provider.rest.common.RestSchema; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; @RestSchema(schemaId = "{{#camelcase}}{{classname}}{{/camelcase}}") @RequestMapping(value = "{{#getRelativeBasePath}}{{basePath}}{{/getRelativeBasePath}}", produces = {APPLICATION_JSON_VALUE}) {{#operations}} public class {{classname}} { {{#operation}} @RequestMapping(value = "{{path}}", {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}} {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}method = RequestMethod.{{httpMethod}}) public ResponseEntity<{{>returnTypes}}> {{operationId}}({{#allParams}}{{>libraries/SpringMVC/queryParams}}{{>libraries/SpringMVC/pathParams}}{{>libraries/SpringMVC/headerParams}}{{>libraries/SpringMVC/bodyParams}}{{>libraries/SpringMVC/formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { // do something return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); } {{/operation}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringMVC/bodyParams.mustache ================================================ {{#isBodyParam}}@RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringMVC/formParams.mustache ================================================ {{#isFormParam}}{{^isFile}}@RequestPart(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringMVC/headerParams.mustache ================================================ {{#isHeaderParam}}@RequestHeader(value="{{paramName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringMVC/pathParams.mustache ================================================ {{#isPathParam}}@PathVariable("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringMVC/pom.mustache ================================================ {{#isMultipleModule}} {{artifactId}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} 4.0.0 {{providerArtifactId}} jar {{^isMultipleModule}} {{groupId}} {{artifactVersion}} {{/isMultipleModule}} {{providerArtifactId}} UTF-8 1.2.0 org.apache.servicecomb java-chassis-dependencies ${java-chassis.version} pom import {{#isMultipleModule}} {{groupId}} {{modelArtifactId}} ${project.version} {{/isMultipleModule}} org.apache.servicecomb transport-rest-vertx org.apache.servicecomb transport-highway org.apache.servicecomb provider-springmvc org.apache.logging.log4j log4j-slf4j-impl org.apache.logging.log4j log4j-api org.apache.logging.log4j log4j-core org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 org.apache.maven.plugins maven-resources-plugin 3.0.0 UTF-8 org.springframework.boot spring-boot-maven-plugin 1.5.12.RELEASE true {{mainClassPackage}}.Application target/bin repackage ================================================ FILE: codegen/src/main/resources/ServiceComb/libraries/SpringMVC/queryParams.mustache ================================================ {{#isQueryParam}}@RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}} ================================================ FILE: codegen/src/main/resources/ServiceComb/log4j2.mustache ================================================ ./target/log ================================================ FILE: codegen/src/main/resources/ServiceComb/model/model.mustache ================================================ package {{package}}; {{#imports}}import {{import}}; {{/imports}} {{#withXml}} import javax.xml.bind.annotation.*; {{/withXml}} {{#models}} {{#model}} {{#isEnum}} {{>enumOuterClass}} {{/isEnum}} {{^isEnum}} {{>pojo}} {{/isEnum}} {{/model}} {{/models}} ================================================ FILE: codegen/src/main/resources/ServiceComb/model/pom.mustache ================================================ {{artifactId}} {{groupId}} {{artifactVersion}} 4.0.0 {{modelArtifactId}} jar {{modelArtifactId}} UTF-8 1.2.0 {{^isPOJO}} org.springframework spring-web {{/isPOJO}} org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 ================================================ FILE: codegen/src/main/resources/ServiceComb/pojo.mustache ================================================ {{#useBeanValidation}}@Validated{{/useBeanValidation}} {{#discriminator}}{{/discriminator}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#serializableModel}} private static final long serialVersionUID = 1L; {{/serializableModel}} {{#vars}} {{#isEnum}} {{^isContainer}} {{>enumClass}} {{/isContainer}} {{/isEnum}} {{#items.isEnum}} {{#items}} {{^isContainer}} {{>enumClass}} {{/isContainer}} {{/items}} {{/items.isEnum}} {{#gson}} @SerializedName("{{baseName}}") {{/gson}} {{#isContainer}} {{#useBeanValidation}}@Valid{{/useBeanValidation}} private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; {{/isContainer}} {{^isContainer}} private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{defaultValue}}} {{/defaultValue}}{{/required}}; {{/isContainer}} {{/vars}} {{#vars}} public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { this.{{name}} = {{name}}; return this; } {{#isListContainer}} public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{^required}} if (this.{{name}} == null) { this.{{name}} = {{{defaultValue}}}; } {{/required}} this.{{name}}.add({{name}}Item); return this; } {{/isListContainer}} {{#isMapContainer}} public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{^required}} if (this.{{name}} == null) { this.{{name}} = {{{defaultValue}}}; } {{/required}} this.{{name}}.put(key, {{name}}Item); return this; } {{/isMapContainer}} {{#vendorExtensions.extraAnnotation}} {{{vendorExtensions.extraAnnotation}}} {{/vendorExtensions.extraAnnotation}} {{#useBeanValidation}} {{>beanValidation}} {{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { this.{{name}} = {{name}}; } {{/vars}} } ================================================ FILE: codegen/src/main/resources/ServiceComb/project/pom.mustache ================================================ 4.0.0 {{groupId}} {{artifactId}} pom {{artifactId}} {{artifactVersion}} UTF-8 1.2.0 UTF-8 1.8 {{#modules}} {{module}} {{/modules}} org.apache.servicecomb java-chassis-dependencies ${java-chassis.version} pom import ================================================ FILE: codegen/src/main/resources/ServiceComb/provider/microservice.mustache ================================================ #Indicates an application name APPLICATION_ID: {{applicationId}} service_description: #Indicates a microservice name #The microservice name should be unique within an application. #The name can contain digits, uppercase and lowercase letters, hyphens(-), underscores(_), and periods(.); and can neither start nor end with punctuations. #The naming rule is as follows: ^[a-zA-Z0-9]+$|^[a-zA-Z0-9][a-zA-Z0-9_-.]*[a-zA-Z0-9]$. name: {{providerServiceId}} #Indicates a service version version: 1.0.0 servicecomb: service: #Specifies the service center IP address. registry: address: http://127.0.0.1:30100 #Specifies the rest transport listening IP address. rest: address: 0.0.0.0:8080 {{#isPOJO}} #Specifies the highway transport listening IP address. highway: address: 0.0.0.0:7070 {{/isPOJO}} ================================================ FILE: codegen/src/main/resources/ServiceComb/returnTypes.mustache ================================================ {{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{returnType}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/Application.mustache ================================================ package {{mainClassPackage}}; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @EnableFeignClients @EnableDiscoveryClient @SpringBootApplication public class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class) .web(WebApplicationType.SERVLET).run(args); } } ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/apiConsumer.mustache ================================================ package {{apiPackage}}; import static org.springframework.http.MediaType.*; import java.util.List; import java.util.Map; import java.util.HashMap; {{#imports}}import {{import}}; {{/imports}} import org.springframework.cloud.openfeign.FeignClient; import org.springframework.util.MultiValueMap; import org.springframework.http.*; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; {{#operations}} @FeignClient(name = "{{providerServiceId}}") {{#showBasePath}} {{#basePath}} @RequestMapping(value = "{{#getRelativeBasePath}}{{basePath}}{{/getRelativeBasePath}}" ) {{/basePath}} {{/showBasePath}} public interface {{classname}} { {{#operation}} @RequestMapping(value = "{{path}}", {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}} {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}} method = RequestMethod.{{httpMethod}}) {{>provider/servlet/returnTypes}} {{operationId}}({{#allParams}}{{>consumer/openfeign/queryParamsConsumer}}{{>consumer/openfeign/headerParamsConsumer}}{{>consumer/openfeign/bodyParamsConsumer}}{{>consumer/openfeign/formParamsConsumer}}{{>consumer/openfeign/pathParamsConsumer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/operation}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/applicationYml.mustache ================================================ spring: application: name: {{consumerServiceId}} server: port: 0 eureka: instance: hostname: localhost client: serviceUrl: defaultZone: http://${eureka.instance.hostname}:8761/eureka/ ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/bodyParamsConsumer.mustache ================================================ {{#isBodyParam}}@RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/formParamsConsumer.mustache ================================================ {{#isFormParam}}{{^isFile}}@RequestPart(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/headerParamsConsumer.mustache ================================================ {{#isHeaderParam}}@RequestHeader(value="{{paramName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/pathParamsConsumer.mustache ================================================ {{#isPathParam}}@PathVariable("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/pom.mustache ================================================ 4.0.0 {{groupId}} {{consumerArtifactId}} jar {{consumerArtifactId}} {{artifactVersion}} UTF-8 Greenwich.SR2 {{#isMultipleModule}} {{groupId}} {{modelArtifactId}} {{artifactVersion}} {{/isMultipleModule}} org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-starter-openfeign org.springframework.cloud spring-cloud-starter-netflix-ribbon org.springframework.cloud spring-cloud-dependencies ${spring-cloud.version} pom import org.springframework.boot spring-boot-starter-parent 2.1.8.RELEASE pom import org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 org.apache.maven.plugins maven-resources-plugin 3.0.0 UTF-8 org.springframework.boot spring-boot-maven-plugin true {{mainClassPackage}}.Application target/bin repackage ================================================ FILE: codegen/src/main/resources/SpringCloud/consumer/openfeign/queryParamsConsumer.mustache ================================================ {{#isQueryParam}}@RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/model/enumClass.mustache ================================================ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { {{#gson}} {{#allowableValues}} {{#enumVars}} @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}} {{/enumVars}} {{/allowableValues}} {{/gson}} {{^gson}} {{#allowableValues}} {{#enumVars}} {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}} {{/enumVars}} {{/allowableValues}} {{/gson}} private {{{datatype}}} value; {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) { this.value = value; } @Override public String toString() { return String.valueOf(value); } public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { if (String.valueOf(b.value).equals(text)) { return b; } } return null; } } ================================================ FILE: codegen/src/main/resources/SpringCloud/model/enumOuterClass.mustache ================================================ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { {{#gson}} {{#allowableValues}}{{#enumVars}} @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} {{/gson}} {{^gson}} {{#allowableValues}}{{#enumVars}} {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} {{/gson}} private {{{dataType}}} value; {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { this.value = value; } @Override public String toString() { return String.valueOf(value); } public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { if (String.valueOf(b.value).equals(text)) { return b; } } return null; } } ================================================ FILE: codegen/src/main/resources/SpringCloud/model/model.mustache ================================================ package {{package}}; {{#imports}}import {{import}}; {{/imports}} {{#withXml}} import javax.xml.bind.annotation.*; {{/withXml}} {{#models}} {{#model}} {{#isEnum}} {{>model/enumOuterClass}} {{/isEnum}} {{^isEnum}} {{>model/pojo}} {{/isEnum}} {{/model}} {{/models}} ================================================ FILE: codegen/src/main/resources/SpringCloud/model/pojo.mustache ================================================ {{#useBeanValidation}}@Validated{{/useBeanValidation}} {{#discriminator}}{{/discriminator}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#serializableModel}} private static final long serialVersionUID = 1L; {{/serializableModel}} {{#vars}} {{#isEnum}} {{^isContainer}} {{>model/enumClass}} {{/isContainer}} {{/isEnum}} {{#items.isEnum}} {{#items}} {{^isContainer}} {{>model/enumClass}} {{/isContainer}} {{/items}} {{/items.isEnum}} {{#gson}} @SerializedName("{{baseName}}") {{/gson}} {{#isContainer}} {{#useBeanValidation}}@Valid{{/useBeanValidation}} private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; {{/isContainer}} {{^isContainer}} private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{defaultValue}}} {{/defaultValue}}{{/required}}; {{/isContainer}} {{/vars}} {{#vars}} public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { this.{{name}} = {{name}}; return this; } {{#isListContainer}} public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{^required}} if (this.{{name}} == null) { this.{{name}} = {{{defaultValue}}}; } {{/required}} this.{{name}}.add({{name}}Item); return this; } {{/isListContainer}} {{#isMapContainer}} public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{^required}} if (this.{{name}} == null) { this.{{name}} = {{{defaultValue}}}; } {{/required}} this.{{name}}.put(key, {{name}}Item); return this; } {{/isMapContainer}} {{#vendorExtensions.extraAnnotation}} {{{vendorExtensions.extraAnnotation}}} {{/vendorExtensions.extraAnnotation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { this.{{name}} = {{name}}; } {{/vars}} } ================================================ FILE: codegen/src/main/resources/SpringCloud/model/pom.mustache ================================================ {{artifactId}} {{groupId}} {{artifactVersion}} 4.0.0 {{modelArtifactId}} jar {{modelArtifactId}} UTF-8 1.2.0 org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 ================================================ FILE: codegen/src/main/resources/SpringCloud/project/pom.mustache ================================================ 4.0.0 {{groupId}} {{artifactId}} pom {{artifactId}} {{artifactVersion}} UTF-8 1.2.0 UTF-8 1.8 {{#modules}} {{module}} {{/modules}} org.apache.servicecomb java-chassis-dependencies ${java-chassis.version} pom import ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/Application.mustache ================================================ package {{mainClassPackage}}; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/api.mustache ================================================ package {{apiPackage}}; import static org.springframework.http.MediaType.*; import java.util.List; import java.util.Map; {{#imports}}import {{import}}; {{/imports}} import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(value = "{{#getRelativeBasePath}}{{basePath}}{{/getRelativeBasePath}}", produces = {APPLICATION_JSON_VALUE}) {{#operations}} public class {{classname}} { {{#operation}} @RequestMapping(value = "{{path}}", {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}} {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}method = RequestMethod.{{httpMethod}}) public {{>provider/servlet/returnTypes}} {{operationId}}({{#allParams}}{{>provider/servlet/queryParams}}{{>provider/servlet/pathParams}}{{>provider/servlet/headerParams}}{{>provider/servlet/bodyParams}}{{>provider/servlet/formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { // do something return null; } {{/operation}} } {{/operations}} ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/applicationYml.mustache ================================================ spring: application: name: {{providerServiceId}} server: port: 0 eureka: instance: hostname: localhost client: serviceUrl: defaultZone: http://${eureka.instance.hostname}:8761/eureka/ ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/bodyParams.mustache ================================================ {{#isBodyParam}}@RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/formParams.mustache ================================================ {{#isFormParam}}{{^isFile}}@RequestPart(value="{{paramName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/headerParams.mustache ================================================ {{#isHeaderParam}}@RequestHeader(value="{{paramName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/pathParams.mustache ================================================ {{#isPathParam}}@PathVariable("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/pom.mustache ================================================ 4.0.0 {{groupId}} {{providerArtifactId}} jar {{providerArtifactId}} {{artifactVersion}} UTF-8 Greenwich.SR2 {{#isMultipleModule}} {{groupId}} {{modelArtifactId}} {{artifactVersion}} {{/isMultipleModule}} org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-dependencies ${spring-cloud.version} pom import org.springframework.boot spring-boot-starter-parent 2.1.8.RELEASE pom import org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 org.apache.maven.plugins maven-resources-plugin 3.0.0 UTF-8 org.springframework.boot spring-boot-maven-plugin true {{mainClassPackage}}.Application target/bin repackage ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/queryParams.mustache ================================================ {{#isQueryParam}}@RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}} ================================================ FILE: codegen/src/main/resources/SpringCloud/provider/servlet/returnTypes.mustache ================================================ {{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{returnType}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} ================================================ FILE: codegen/src/test/java/org/apache/servicecomb/toolkit/codegen/CustomPropertiesTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import org.junit.Assert; import org.junit.Test; public class CustomPropertiesTest { @Test public void customMainClassPackage() { AbstractJavaCodegenExt javaCodegenExt = new AbstractJavaCodegenExt() { }; javaCodegenExt.additionalProperties().put("mainClassPackage", "com.demo"); javaCodegenExt.processOpts(); Assert.assertEquals("com.demo", javaCodegenExt.mainClassPackage); } @Test public void customApiPackage() { AbstractJavaCodegenExt javaCodegenExt = new AbstractJavaCodegenExt() { }; javaCodegenExt.additionalProperties().put("apiPackage", "com.demo.api"); javaCodegenExt.processOpts(); Assert.assertEquals("com.demo", javaCodegenExt.mainClassPackage); } } ================================================ FILE: codegen/src/test/java/org/apache/servicecomb/toolkit/codegen/GeneratorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import static org.junit.Assert.fail; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collections; import org.apache.servicecomb.toolkit.CodeGenerator; import org.apache.servicecomb.toolkit.GeneratorFactory; import org.junit.Assert; import org.junit.Test; import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.config.CodegenConfigurator; public class GeneratorTest { @Test public void testGenerateProgrammingModels() throws IOException, URISyntaxException, NoSuchFieldException, IllegalAccessException { generateServiceCombCode("SpringMVC"); generateServiceCombCode("POJO"); generateServiceCombCode("JAX-RS"); generateServiceCombCode("SpringBoot"); } private void generateServiceCombCode(String programmingModel) throws IOException, URISyntaxException, IllegalAccessException, NoSuchFieldException { Path tempDir = Files.createTempDirectory(null); Path specFilePath = Paths.get(GeneratorTest.class.getClassLoader().getResource("swagger.yaml").toURI()); CodegenConfigurator configurator = new CodegenConfigurator(); configurator.setGeneratorName("ServiceComb"); configurator.setLibrary(programmingModel); configurator.setOutputDir(tempDir.toFile().getCanonicalPath() + "/ServiceComb"); configurator.setInputSpec(specFilePath.toFile().getCanonicalPath()); configurator.addAdditionalProperty(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, "mock-provider"); configurator.addAdditionalProperty(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME, "mock-consumer"); configurator.addAdditionalProperty(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME, "mock-model"); DefaultCodeGenerator codeGenerator = new DefaultCodeGenerator(); codeGenerator.configure(Collections.singletonMap("configurators", Collections.singletonList(configurator))); try { codeGenerator.generate(); } catch (RuntimeException e) { fail("Run 'testGenerateProgrammingModels' failed while input " + programmingModel + " unexpected to catch RuntimeException: " + e.getMessage()); } Object internalGenerator = ReflectUtils.getProperty(codeGenerator, "generator"); Assert.assertEquals(MultiContractGenerator.class, internalGenerator.getClass()); Object swaggerCodegenConfig = ReflectUtils.getProperty(internalGenerator, "config"); Assert.assertEquals(ServiceCombCodegen.class, swaggerCodegenConfig.getClass()); Assert.assertEquals("ServiceComb", ((ServiceCombCodegen) swaggerCodegenConfig).getName()); Assert.assertEquals(CodegenType.SERVER, ((ServiceCombCodegen) swaggerCodegenConfig).getTag()); tempDir.toFile().deleteOnExit(); } @Test public void testGetCodeGeneratorInstanse() { CodeGenerator defaultCodeGenerator = GeneratorFactory.getGenerator(CodeGenerator.class, "default"); Assert.assertNotNull(defaultCodeGenerator); Assert.assertTrue(defaultCodeGenerator.canProcess("default")); CodeGenerator unknownCodeGenerator = GeneratorFactory.getGenerator(CodeGenerator.class, "unknown"); Assert.assertNull(unknownCodeGenerator); } @Test public void generateSpringCloudProject() throws IOException, URISyntaxException, IllegalAccessException, NoSuchFieldException { Path tempDir = Files.createTempDirectory(null); Path specFilePath = Paths.get(GeneratorTest.class.getClassLoader().getResource("swagger.yaml").toURI()); CodegenConfigurator configurator = new CodegenConfigurator(); configurator.setGeneratorName("SpringCloud"); configurator.setOutputDir(tempDir.toFile().getCanonicalPath() + "/SpringCloud"); configurator.setInputSpec(specFilePath.toFile().getCanonicalPath()); configurator.addAdditionalProperty(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, "mock-provider"); configurator.addAdditionalProperty(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME, "mock-consumer"); configurator.addAdditionalProperty(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME, "mock-model"); DefaultCodeGenerator codeGenerator = new DefaultCodeGenerator(); codeGenerator.configure(Collections.singletonMap("configurators", Collections.singletonList(configurator))); try { codeGenerator.generate(); } catch (RuntimeException e) { fail("Run 'testGenerateProgrammingModels' failed. Unexpected to catch RuntimeException: " + e.getMessage()); } Object internalGenerator = ReflectUtils.getProperty(codeGenerator, "generator"); Assert.assertEquals(MultiContractGenerator.class, internalGenerator.getClass()); Object swaggerCodegenConfig = ReflectUtils.getProperty(internalGenerator, "config"); Assert.assertEquals(SpringCloudCodegen.class, swaggerCodegenConfig.getClass()); Assert.assertEquals("SpringCloud", ((SpringCloudCodegen) swaggerCodegenConfig).getName()); Assert.assertEquals(CodegenType.SERVER, ((SpringCloudCodegen) swaggerCodegenConfig).getTag()); Assert .assertEquals("Generates a SpringCloud server library.", ((SpringCloudCodegen) swaggerCodegenConfig).getHelp()); tempDir.toFile().deleteOnExit(); } } ================================================ FILE: codegen/src/test/java/org/apache/servicecomb/toolkit/codegen/ReflectUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.lang.reflect.Field; class ReflectUtils { static Object getProperty(Object obj, String propName) throws IllegalAccessException, NoSuchFieldException { Field propFiled = getFiled(obj.getClass(), propName); if (propFiled == null) { return null; } propFiled.setAccessible(true); return propFiled.get(obj); } private static Field getFiled(Class cls, String propName) throws NoSuchFieldException { try { return cls.getDeclaredField(propName); } catch (NoSuchFieldException e) { if (cls.getSuperclass() != null) { return getFiled(cls.getSuperclass(), propName); } else { throw new NoSuchFieldException("No such field: " + propName); } } } } ================================================ FILE: codegen/src/test/java/org/apache/servicecomb/toolkit/codegen/ServiceCombCodegenTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import org.junit.Assert; import org.junit.Test; import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfigLoader; import org.openapitools.codegen.SupportingFile; public class ServiceCombCodegenTest { @Test public void testLoadImpl() { CodegenConfig codegenConfig = CodegenConfigLoader.forName("ServiceComb"); Assert.assertEquals(ServiceCombCodegen.class, codegenConfig.getClass()); } @Test public void providerDirectoryStrategy() { DirectoryStrategy providerDirectoryStrategy = new ProviderDirectoryStrategy(); Map propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "provider"); propertiesMap.put("mainClassPackage", "provider"); providerDirectoryStrategy.addCustomProperties(propertiesMap); providerDirectoryStrategy.processSupportingFile(new ArrayList()); Assert.assertEquals("provider", providerDirectoryStrategy.providerDirectory()); Assert.assertEquals("provider", providerDirectoryStrategy.modelDirectory()); try { providerDirectoryStrategy.consumerDirectory(); } catch (Exception e) { Assert.assertTrue(e instanceof UnsupportedOperationException); } } @Test public void consumerDirectoryStrategy() { DirectoryStrategy consumerDirectoryStrategy = new ConsumerDirectoryStrategy(); Map propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "consumer"); propertiesMap.put("mainClassPackage", "consumer"); propertiesMap.put("providerServiceId", "provider"); propertiesMap.put("apiTemplateFiles", new HashMap()); consumerDirectoryStrategy.addCustomProperties(propertiesMap); consumerDirectoryStrategy.processSupportingFile(new ArrayList()); Assert.assertEquals("consumer", consumerDirectoryStrategy.consumerDirectory()); Assert.assertEquals("consumer", consumerDirectoryStrategy.modelDirectory()); try { consumerDirectoryStrategy.providerDirectory(); } catch (Exception e) { Assert.assertTrue(e instanceof UnsupportedOperationException); } } @Test public void defaultDirectoryStrategy() { DirectoryStrategy defaultDirectoryStrategy = new DefaultDirectoryStrategy(); Map propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "all"); propertiesMap.put("mainClassPackage", "all"); propertiesMap.put("apiTemplateFiles", new HashMap()); defaultDirectoryStrategy.addCustomProperties(propertiesMap); defaultDirectoryStrategy.processSupportingFile(new ArrayList()); Assert.assertEquals("consumer", defaultDirectoryStrategy.consumerDirectory()); Assert.assertEquals("provider", defaultDirectoryStrategy.providerDirectory()); Assert.assertEquals("model", defaultDirectoryStrategy.modelDirectory()); } @Test public void spirngCloudMultiDirectoryStrategy() { SpringCloudMultiDirectoryStrategy multiDirectoryStrategy = new SpringCloudMultiDirectoryStrategy(); Map propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "all"); propertiesMap.put("mainClassPackage", "all"); propertiesMap.put("apiTemplateFiles", new HashMap()); multiDirectoryStrategy.addCustomProperties(propertiesMap); multiDirectoryStrategy.processSupportingFile(new ArrayList()); Assert.assertEquals("consumer", multiDirectoryStrategy.consumerDirectory()); Assert.assertEquals("provider", multiDirectoryStrategy.providerDirectory()); Assert.assertEquals("model", multiDirectoryStrategy.modelDirectory()); } @Test public void spirngCloudConsumerDirectoryStrategy() { SpringCloudConsumerDirectoryStrategy consumerDirectoryStrategy = new SpringCloudConsumerDirectoryStrategy(); Map propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "consumer"); propertiesMap.put("mainClassPackage", "consumer"); propertiesMap.put("providerServiceId", "provider"); propertiesMap.put("apiTemplateFiles", new HashMap()); consumerDirectoryStrategy.addCustomProperties(propertiesMap); consumerDirectoryStrategy.processSupportingFile(new ArrayList()); Assert.assertEquals("consumer", consumerDirectoryStrategy.consumerDirectory()); Assert.assertEquals("consumer", consumerDirectoryStrategy.modelDirectory()); try { consumerDirectoryStrategy.providerDirectory(); } catch (Exception e) { Assert.assertTrue(e instanceof UnsupportedOperationException); } } @Test public void spirngCloudProviderDirectoryStrategy() { SpringCloudProviderDirectoryStrategy providerDirectoryStrategy = new SpringCloudProviderDirectoryStrategy(); Map propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "provider"); propertiesMap.put("mainClassPackage", "provider"); providerDirectoryStrategy.addCustomProperties(propertiesMap); providerDirectoryStrategy.processSupportingFile(new ArrayList()); Assert.assertEquals("provider", providerDirectoryStrategy.providerDirectory()); Assert.assertEquals("provider", providerDirectoryStrategy.modelDirectory()); try { providerDirectoryStrategy.consumerDirectory(); } catch (Exception e) { Assert.assertTrue(e instanceof UnsupportedOperationException); } } @Test public void defaultValue() { CodegenConfig codegenConfig = CodegenConfigLoader.forName("ServiceComb"); Assert.assertEquals(ServiceCombCodegen.class, codegenConfig.getClass()); ServiceCombCodegen serviceCombCodegen = (ServiceCombCodegen) codegenConfig; serviceCombCodegen.processOpts(); Map additionalProperties = serviceCombCodegen.additionalProperties(); Assert.assertEquals("domain.orgnization.project.sample", additionalProperties.get("mainClassPackage")); Assert.assertEquals("domain.orgnization.project.sample.api", additionalProperties.get("apiPackage")); Assert.assertEquals("domain.orgnization.project.sample.model", additionalProperties.get("modelPackage")); } } ================================================ FILE: codegen/src/test/java/org/apache/servicecomb/toolkit/codegen/SpringCloudCodegenTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import org.junit.Assert; import org.junit.Test; import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfigLoader; public class SpringCloudCodegenTest { @Test public void testLoadImpl() { CodegenConfig codegenConfig = CodegenConfigLoader.forName("SpringCloud"); Assert.assertEquals(SpringCloudCodegen.class, codegenConfig.getClass()); } } ================================================ FILE: codegen/src/test/java/org/apache/servicecomb/toolkit/codegen/TemplateTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.codegen; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.Test; import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.api.TemplatingEngineAdapter; import org.openapitools.codegen.templating.MustacheEngineAdapter; import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Template; import io.swagger.models.Model; import io.swagger.models.Swagger; import io.swagger.parser.OpenAPIParser; import io.swagger.parser.SwaggerParser; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.core.models.SwaggerParseResult; public class TemplateTest { String[] apiTemplateLocations = new String[] { "ServiceComb/libraries/JAX-RS/api.mustache", "ServiceComb/libraries/POJO/api.mustache", "ServiceComb/libraries/SpringBoot/api.mustache", "ServiceComb/libraries/SpringMVC/api.mustache", "ServiceComb/consumer/apiConsumer.mustache", "ServiceComb/consumer/pojo/apiConsumer.mustache" }; @Test public void generateApisWithNoModel() throws IOException { ServiceCombCodegen config = new ServiceCombCodegen(); Map templateData = readSwaggerModelInfo("no-model.yaml", config); assertNotNull(templateData); assertNull(templateData.get("imports")); templateData.putAll(config.additionalProperties()); templateData.put("apiPackage", config.apiPackage()); Arrays.stream(apiTemplateLocations).forEach(apiTemplateLocation -> { try { String renderResult = renderTemplate(templateData, apiTemplateLocation); assertNotNull(renderResult); assertFalse(renderResult.contains(config.modelPackage())); } catch (IOException e) { fail("Run 'generateApisWithNoModel' failed: " + e.getMessage()); } }); } @Test public void generateApisWithModel() throws IOException { ServiceCombCodegen config = new ServiceCombCodegen(); TemplatingEngineAdapter templateEngine = new MustacheEngineAdapter(); Map templateData = readSwaggerModelInfo("with-model.yaml", config); assertNotNull(templateData); assertNotNull(templateData.get("imports")); templateData.putAll(config.additionalProperties()); templateData.put("apiPackage", config.apiPackage()); Arrays.stream(apiTemplateLocations).forEach(apiTemplateLocation -> { try { String renderResult = renderTemplate(templateData, apiTemplateLocation); assertNotNull(renderResult); assertTrue(renderResult.contains(config.modelPackage())); } catch (IOException e) { fail("Run 'generateApisWithModel' failed: " + e.getMessage()); } }); } private Map readSwaggerModelInfo(String swaggerYamlFile, CodegenConfig config) throws IOException { Map templateData = new HashMap<>(); String swaggerString = readResourceInClasspath(swaggerYamlFile); Swagger swagger = new SwaggerParser().parse(swaggerString); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); SwaggerParseResult result = new OpenAPIParser().readContents(swaggerString, null, options); OpenAPI openAPI = result.getOpenAPI(); Components components = openAPI.getComponents(); Map definitions = swagger.getDefinitions(); if (definitions == null) { return templateData; } List> imports = new ArrayList>(); for (String key : components.getSchemas().keySet()) { Schema mm = components.getSchemas().get(key); CodegenModel cm = config.fromModel(key, mm); Map item = new HashMap(); item.put("import", config.toModelImport(cm.classname)); imports.add(item); } templateData.put("imports", imports); return templateData; } private String renderTemplate(Map templateData, String templateLocation) throws IOException { String templateString = readResourceInClasspath(templateLocation); Mustache.Compiler compiler = Mustache.compiler(); Template tmpl = compiler.compile(templateString); return tmpl.execute(templateData); } private String readResourceInClasspath(String resourceName) throws IOException { InputStream resourceStream = TemplateTest.class.getClassLoader().getResourceAsStream(resourceName); if (resourceStream == null) { throw new IOException("resource " + resourceName + " not found"); } StringBuilder stringBuilder = new StringBuilder(); int len = -1; byte[] buffer = new byte[2048]; while ((len = resourceStream.read(buffer)) != -1) { stringBuilder.append(new String(buffer, 0, len)); } return stringBuilder.toString(); } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/api-with-examples.json ================================================ { "swagger": "2.0", "info": { "title": "Simple API overview", "version": "v2" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "produces": [ "application/json" ], "responses": { "200": { "description": "200 300 response", "examples": { "application/json": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}" } }, "300": { "description": "200 300 response", "examples": { "application/json": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}" } } } } }, "/v2": { "get": { "operationId": "getVersionDetailsv2", "summary": "Show API version details", "produces": [ "application/json" ], "responses": { "200": { "description": "200 203 response", "examples": { "application/json": "{\n \"version\": {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"media-types\": [\n {\n \"base\": \"application/xml\",\n \"type\": \"application/vnd.openstack.compute+xml;version=2\"\n },\n {\n \"base\": \"application/json\",\n \"type\": \"application/vnd.openstack.compute+json;version=2\"\n }\n ],\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf\",\n \"type\": \"application/pdf\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n }\n ]\n }\n}" } }, "203": { "description": "200 203 response", "examples": { "application/json": "{\n \"version\": {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"media-types\": [\n {\n \"base\": \"application/xml\",\n \"type\": \"application/vnd.openstack.compute+xml;version=2\"\n },\n {\n \"base\": \"application/json\",\n \"type\": \"application/vnd.openstack.compute+json;version=2\"\n }\n ],\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://23.253.228.211:8774/v2/\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf\",\n \"type\": \"application/pdf\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n }\n ]\n }\n}" } } } } } }, "consumes": [ "application/json" ] } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-expanded.json ================================================ { "swagger": "2.0", "info": { "version": "1.0.0", "title": "Swagger Petstore", "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Swagger API Team", "email": "apiteam@swagger.io", "url": "http://swagger.io" }, "license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" } }, "host": "petstore.swagger.io", "basePath": "/api", "schemes": [ "http" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/pets": { "get": { "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", "operationId": "findPets", "parameters": [ { "name": "tags", "in": "query", "description": "tags to filter by", "required": false, "type": "array", "collectionFormat": "csv", "items": { "type": "string" } }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, "type": "integer", "format": "int32" } ], "responses": { "200": { "description": "pet response", "schema": { "type": "array", "items": { "$ref": "#/definitions/Pet" } } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/Error" } } } }, "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "addPet", "parameters": [ { "name": "pet", "in": "body", "description": "Pet to add to the store", "required": true, "schema": { "$ref": "#/definitions/NewPet" } } ], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } }, "/pets/{id}": { "get": { "description": "Returns a user based on a single ID, if the user does not have access to the pet", "operationId": "find pet by id", "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to fetch", "required": true, "type": "integer", "format": "int64" } ], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/Error" } } } }, "delete": { "description": "deletes a single pet based on the ID supplied", "operationId": "deletePet", "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to delete", "required": true, "type": "integer", "format": "int64" } ], "responses": { "204": { "description": "pet deleted" }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } } }, "definitions": { "Pet": { "type": "object", "allOf": [ { "$ref": "#/definitions/NewPet" }, { "required": [ "id" ], "properties": { "id": { "type": "integer", "format": "int64" } } } ] }, "NewPet": { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" }, "tag": { "type": "string" } } }, "Error": { "type": "object", "required": [ "code", "message" ], "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } } } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-minimal.json ================================================ { "swagger": "2.0", "info": { "version": "1.0.0", "title": "Swagger Petstore", "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Swagger API Team" }, "license": { "name": "MIT" } }, "host": "petstore.swagger.io", "basePath": "/api", "schemes": [ "http" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/pets": { "get": { "description": "Returns all pets from the system that the user has access to", "produces": [ "application/json" ], "responses": { "200": { "description": "A list of pets.", "schema": { "type": "array", "items": { "$ref": "#/definitions/Pet" } } } } } } }, "definitions": { "Pet": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "tag": { "type": "string" } } } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-separate/common/Error.json ================================================ { "type": "object", "required": [ "code", "message" ], "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-separate/spec/NewPet.json ================================================ { "type": "object", "allOf": [ { "$ref": "Pet.json" }, { "required": [ "name" ], "properties": { "description": { "type": "integer", "format": "int64" } } } ] } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-separate/spec/Pet.json ================================================ { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "tag": { "type": "string" } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-separate/spec/parameters.json ================================================ { "tagsParam": { "name": "tags", "in": "query", "description": "tags to filter by", "required": false, "type": "array", "collectionFormat": "csv", "items": { "type": "string" } }, "limitsParam": { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, "type": "integer", "format": "int32" } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-separate/spec/swagger.json ================================================ { "swagger": "2.0", "info": { "version": "1.0.0", "title": "Swagger Petstore", "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Swagger API Team", "email": "apiteam@swagger.io", "url": "http://swagger.io" }, "license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" } }, "host": "petstore.swagger.io", "basePath": "/api", "schemes": [ "http" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/pets": { "get": { "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", "operationId": "findPets", "parameters": [ { "$ref": "parameters.json#/tagsParam" }, { "$ref": "parameters.json#/limitsParam" } ], "responses": { "200": { "description": "pet response", "schema": { "type": "array", "items": { "$ref": "Pet.json" } } }, "default": { "description": "unexpected error", "schema": { "$ref": "../common/Error.json" } } } }, "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "addPet", "parameters": [ { "name": "pet", "in": "body", "description": "Pet to add to the store", "required": true, "schema": { "$ref": "NewPet.json" } } ], "responses": { "200": { "description": "pet response", "schema": { "$ref": "Pet.json" } }, "default": { "description": "unexpected error", "schema": { "$ref": "../common/Error.json" } } } } }, "/pets/{id}": { "get": { "description": "Returns a user based on a single ID, if the user does not have access to the pet", "operationId": "find pet by id", "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to fetch", "required": true, "type": "integer", "format": "int64" } ], "responses": { "200": { "description": "pet response", "schema": { "$ref": "Pet.json" } }, "default": { "description": "unexpected error", "schema": { "$ref": "../common/Error.json" } } } }, "delete": { "description": "deletes a single pet based on the ID supplied", "operationId": "deletePet", "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to delete", "required": true, "type": "integer", "format": "int64" } ], "responses": { "204": { "description": "pet deleted" }, "default": { "description": "unexpected error", "schema": { "$ref": "../common/Error.json" } } } } } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-simple.json ================================================ { "swagger": "2.0", "info": { "version": "1.0.0", "title": "Swagger Petstore", "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Swagger API Team" }, "license": { "name": "MIT" } }, "host": "petstore.swagger.io", "basePath": "/api", "schemes": [ "http" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/pets": { "get": { "description": "Returns all pets from the system that the user has access to", "operationId": "findPets", "produces": [ "application/json", "application/xml", "text/xml", "text/html" ], "parameters": [ { "name": "tags", "in": "query", "description": "tags to filter by", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "csv" }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, "type": "integer", "format": "int32" } ], "responses": { "200": { "description": "pet response", "schema": { "type": "array", "items": { "$ref": "#/definitions/Pet" } } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } }, "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "addPet", "produces": [ "application/json" ], "parameters": [ { "name": "pet", "in": "body", "description": "Pet to add to the store", "required": true, "schema": { "$ref": "#/definitions/NewPet" } } ], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } } }, "/pets/{id}": { "get": { "description": "Returns a user based on a single ID, if the user does not have access to the pet", "operationId": "findPetById", "produces": [ "application/json", "application/xml", "text/xml", "text/html" ], "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to fetch", "required": true, "type": "integer", "format": "int64" } ], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } }, "delete": { "description": "deletes a single pet based on the ID supplied", "operationId": "deletePet", "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to delete", "required": true, "type": "integer", "format": "int64" } ], "responses": { "204": { "description": "pet deleted" }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } } } }, "definitions": { "Pet": { "type": "object", "allOf": [ { "$ref": "#/definitions/NewPet" }, { "required": [ "id" ], "properties": { "id": { "type": "integer", "format": "int64" } } } ] }, "NewPet": { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" }, "tag": { "type": "string" } } }, "ErrorModel": { "type": "object", "required": [ "code", "message" ], "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } } } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore-with-external-docs.json ================================================ { "swagger": "2.0", "info": { "version": "1.0.0", "title": "Swagger Petstore", "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Swagger API Team", "email": "apiteam@swagger.io", "url": "http://swagger.io" }, "license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" } }, "externalDocs": { "description": "find more info here", "url": "https://swagger.io/about" }, "host": "petstore.swagger.io", "basePath": "/api", "schemes": [ "http" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/pets": { "get": { "description": "Returns all pets from the system that the user has access to", "operationId": "findPets", "externalDocs": { "description": "find more info here", "url": "https://swagger.io/about" }, "produces": [ "application/json", "application/xml", "text/xml", "text/html" ], "parameters": [ { "name": "tags", "in": "query", "description": "tags to filter by", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "csv" }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, "type": "integer", "format": "int32" } ], "responses": { "200": { "description": "pet response", "schema": { "type": "array", "items": { "$ref": "#/definitions/Pet" } } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } }, "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "addPet", "produces": [ "application/json" ], "parameters": [ { "name": "pet", "in": "body", "description": "Pet to add to the store", "required": true, "schema": { "$ref": "#/definitions/NewPet" } } ], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } } }, "/pets/{id}": { "get": { "description": "Returns a user based on a single ID, if the user does not have access to the pet", "operationId": "findPetById", "produces": [ "application/json", "application/xml", "text/xml", "text/html" ], "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to fetch", "required": true, "type": "integer", "format": "int64" } ], "responses": { "200": { "description": "pet response", "schema": { "$ref": "#/definitions/Pet" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } }, "delete": { "description": "deletes a single pet based on the ID supplied", "operationId": "deletePet", "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to delete", "required": true, "type": "integer", "format": "int64" } ], "responses": { "204": { "description": "pet deleted" }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/ErrorModel" } } } } } }, "definitions": { "Pet": { "type": "object", "allOf": [ { "$ref": "#/definitions/NewPet" }, { "required": [ "id" ], "properties": { "id": { "type": "integer", "format": "int64" } } } ] }, "NewPet": { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" }, "tag": { "type": "string" } } }, "ErrorModel": { "type": "object", "required": [ "code", "message" ], "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } } } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/petstore.json ================================================ { "swagger": "2.0", "info": { "version": "1.0.0", "title": "Swagger Petstore", "license": { "name": "MIT" } }, "host": "petstore.swagger.io", "basePath": "/v1", "schemes": [ "http" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/pets": { "get": { "summary": "List all pets", "operationId": "listPets", "tags": [ "pets" ], "parameters": [ { "name": "limit", "in": "query", "description": "How many items to return at one time (max 100)", "required": false, "type": "integer", "format": "int32" } ], "responses": { "200": { "description": "An paged array of pets", "headers": { "x-next": { "type": "string", "description": "A link to the next page of responses" } }, "schema": { "$ref": "#/definitions/Pets" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/Error" } } } }, "post": { "summary": "Create a pet", "operationId": "createPets", "tags": [ "pets" ], "responses": { "201": { "description": "Null response" }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } }, "/pets/{petId}": { "get": { "summary": "Info for a specific pet", "operationId": "showPetById", "tags": [ "pets" ], "parameters": [ { "name": "petId", "in": "path", "required": true, "description": "The id of the pet to retrieve", "type": "string" } ], "responses": { "200": { "description": "Expected response to a valid request", "schema": { "$ref": "#/definitions/Pets" } }, "default": { "description": "unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } } }, "definitions": { "Pet": { "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "tag": { "type": "string" } } }, "Pets": { "type": "array", "items": { "$ref": "#/definitions/Pet" } }, "Error": { "required": [ "code", "message" ], "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } } } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/json/uber.json ================================================ { "swagger": "2.0", "info": { "title": "Uber API", "description": "Move your app forward with the Uber API", "version": "1.0.0" }, "host": "api.uber.com", "schemes": [ "https" ], "basePath": "/v1", "produces": [ "application/json" ], "paths": { "/products": { "get": { "summary": "Product Types", "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", "parameters": [ { "name": "latitude", "in": "query", "description": "Latitude component of location.", "required": true, "type": "number", "format": "double" }, { "name": "longitude", "in": "query", "description": "Longitude component of location.", "required": true, "type": "number", "format": "double" } ], "tags": [ "Products" ], "responses": { "200": { "description": "An array of products", "schema": { "type": "array", "items": { "$ref": "#/definitions/Product" } } }, "default": { "description": "Unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } }, "/estimates/price": { "get": { "summary": "Price Estimates", "description": "The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.

The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier.", "parameters": [ { "name": "start_latitude", "in": "query", "description": "Latitude component of start location.", "required": true, "type": "number", "format": "double" }, { "name": "start_longitude", "in": "query", "description": "Longitude component of start location.", "required": true, "type": "number", "format": "double" }, { "name": "end_latitude", "in": "query", "description": "Latitude component of end location.", "required": true, "type": "number", "format": "double" }, { "name": "end_longitude", "in": "query", "description": "Longitude component of end location.", "required": true, "type": "number", "format": "double" } ], "tags": [ "Estimates" ], "responses": { "200": { "description": "An array of price estimates by product", "schema": { "type": "array", "items": { "$ref": "#/definitions/PriceEstimate" } } }, "default": { "description": "Unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } }, "/estimates/time": { "get": { "summary": "Time Estimates", "description": "The Time Estimates endpoint returns ETAs for all products offered at a given location, with the responses expressed as integers in seconds. We recommend that this endpoint be called every minute to provide the most accurate, up-to-date ETAs.", "parameters": [ { "name": "start_latitude", "in": "query", "description": "Latitude component of start location.", "required": true, "type": "number", "format": "double" }, { "name": "start_longitude", "in": "query", "description": "Longitude component of start location.", "required": true, "type": "number", "format": "double" }, { "name": "customer_uuid", "in": "query", "type": "string", "format": "uuid", "description": "Unique customer identifier to be used for experience customization." }, { "name": "product_id", "in": "query", "type": "string", "description": "Unique identifier representing a specific product for a given latitude & longitude." } ], "tags": [ "Estimates" ], "responses": { "200": { "description": "An array of products", "schema": { "type": "array", "items": { "$ref": "#/definitions/Product" } } }, "default": { "description": "Unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } }, "/me": { "get": { "summary": "User Profile", "description": "The User Profile endpoint returns information about the Uber user that has authorized with the application.", "tags": [ "User" ], "responses": { "200": { "description": "Profile information for a user", "schema": { "$ref": "#/definitions/Profile" } }, "default": { "description": "Unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } }, "/history": { "get": { "summary": "User Activity", "description": "The User Activity endpoint returns data about a user's lifetime activity with Uber. The response will include pickup locations and times, dropoff locations and times, the distance of past requests, and information about which products were requested.

The history array in the response will have a maximum length based on the limit parameter. The response value count may exceed limit, therefore subsequent API requests may be necessary.", "parameters": [ { "name": "offset", "in": "query", "type": "integer", "format": "int32", "description": "Offset the list of returned results by this amount. Default is zero." }, { "name": "limit", "in": "query", "type": "integer", "format": "int32", "description": "Number of items to retrieve. Default is 5, maximum is 100." } ], "tags": [ "User" ], "responses": { "200": { "description": "History information for the given user", "schema": { "$ref": "#/definitions/Activities" } }, "default": { "description": "Unexpected error", "schema": { "$ref": "#/definitions/Error" } } } } } }, "definitions": { "Product": { "properties": { "product_id": { "type": "string", "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." }, "description": { "type": "string", "description": "Description of product." }, "display_name": { "type": "string", "description": "Display name of product." }, "capacity": { "type": "string", "description": "Capacity of product. For example, 4 people." }, "image": { "type": "string", "description": "Image URL representing the product." } } }, "PriceEstimate": { "properties": { "product_id": { "type": "string", "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles" }, "currency_code": { "type": "string", "description": "[ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code." }, "display_name": { "type": "string", "description": "Display name of product." }, "estimate": { "type": "string", "description": "Formatted string of estimate in local currency of the start location. Estimate could be a range, a single number (flat rate) or \"Metered\" for TAXI." }, "low_estimate": { "type": "number", "description": "Lower bound of the estimated price." }, "high_estimate": { "type": "number", "description": "Upper bound of the estimated price." }, "surge_multiplier": { "type": "number", "description": "Expected surge multiplier. Surge is active if surge_multiplier is greater than 1. Price estimate already factors in the surge multiplier." } } }, "Profile": { "properties": { "first_name": { "type": "string", "description": "First name of the Uber user." }, "last_name": { "type": "string", "description": "Last name of the Uber user." }, "email": { "type": "string", "description": "Email address of the Uber user" }, "picture": { "type": "string", "description": "Image URL of the Uber user." }, "promo_code": { "type": "string", "description": "Promo code of the Uber user." } } }, "Activity": { "properties": { "uuid": { "type": "string", "description": "Unique identifier for the activity" } } }, "Activities": { "properties": { "offset": { "type": "integer", "format": "int32", "description": "Position in pagination." }, "limit": { "type": "integer", "format": "int32", "description": "Number of items to retrieve (100 max)." }, "count": { "type": "integer", "format": "int32", "description": "Total number of items available." }, "history": { "type": "array", "items": { "$ref": "#/definitions/Activity" } } } }, "Error": { "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "fields": { "type": "string" } } } } } ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/api-with-examples.yaml ================================================ swagger: "2.0" info: title: Simple API overview version: v2 paths: /: get: operationId: listVersionsv2 summary: List API versions produces: - application/json responses: "200": description: |- 200 300 response examples: application/json: |- { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] }, { "status": "EXPERIMENTAL", "updated": "2013-07-23T11:33:21Z", "id": "v3.0", "links": [ { "href": "http://127.0.0.1:8774/v3/", "rel": "self" } ] } ] } "300": description: |- 200 300 response examples: application/json: |- { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] }, { "status": "EXPERIMENTAL", "updated": "2013-07-23T11:33:21Z", "id": "v3.0", "links": [ { "href": "http://127.0.0.1:8774/v3/", "rel": "self" } ] } ] } /v2: get: operationId: getVersionDetailsv2 summary: Show API version details produces: - application/json responses: "200": description: |- 200 203 response examples: application/json: |- { "version": { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "media-types": [ { "base": "application/xml", "type": "application/vnd.openstack.compute+xml;version=2" }, { "base": "application/json", "type": "application/vnd.openstack.compute+json;version=2" } ], "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", "type": "application/pdf", "rel": "describedby" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", "type": "application/vnd.sun.wadl+xml", "rel": "describedby" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", "type": "application/vnd.sun.wadl+xml", "rel": "describedby" } ] } } "203": description: |- 200 203 response examples: application/json: |- { "version": { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "media-types": [ { "base": "application/xml", "type": "application/vnd.openstack.compute+xml;version=2" }, { "base": "application/json", "type": "application/vnd.openstack.compute+json;version=2" } ], "id": "v2.0", "links": [ { "href": "http://23.253.228.211:8774/v2/", "rel": "self" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", "type": "application/pdf", "rel": "describedby" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", "type": "application/vnd.sun.wadl+xml", "rel": "describedby" } ] } } consumes: - application/json ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-expanded.yaml ================================================ swagger: "2.0" info: version: 1.0.0 title: Swagger Petstore description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification termsOfService: http://swagger.io/terms/ contact: name: Swagger API Team email: apiteam@swagger.io url: http://swagger.io license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html host: petstore.swagger.io basePath: /api schemes: - http consumes: - application/json produces: - application/json paths: /pets: get: description: | Returns all pets from the system that the user has access to operationId: findPets parameters: - name: tags in: query description: tags to filter by required: false type: array collectionFormat: csv items: type: string - name: limit in: query description: maximum number of results to return required: false type: integer format: int32 responses: "200": description: pet response schema: type: array items: $ref: '#/definitions/Pet' default: description: unexpected error schema: $ref: '#/definitions/Error' post: description: Creates a new pet in the store. Duplicates are allowed operationId: addPet parameters: - name: pet in: body description: Pet to add to the store required: true schema: $ref: '#/definitions/NewPet' responses: "200": description: pet response schema: $ref: '#/definitions/Pet' default: description: unexpected error schema: $ref: '#/definitions/Error' /pets/{id}: get: description: Returns a user based on a single ID, if the user does not have access to the pet operationId: find pet by id parameters: - name: id in: path description: ID of pet to fetch required: true type: integer format: int64 responses: "200": description: pet response schema: $ref: '#/definitions/Pet' default: description: unexpected error schema: $ref: '#/definitions/Error' delete: description: deletes a single pet based on the ID supplied operationId: deletePet parameters: - name: id in: path description: ID of pet to delete required: true type: integer format: int64 responses: "204": description: pet deleted default: description: unexpected error schema: $ref: '#/definitions/Error' definitions: Pet: allOf: - $ref: '#/definitions/NewPet' - required: - id type: "object" properties: id: type: integer format: int64 NewPet: type: "object" required: - name properties: name: type: string tag: type: string Error: type: "object" required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-minimal.yaml ================================================ --- swagger: "2.0" info: version: "1.0.0" title: "Swagger Petstore" description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" termsOfService: "http://swagger.io/terms/" contact: name: "Swagger API Team" license: name: "MIT" host: "petstore.swagger.io" basePath: "/api" schemes: - "http" consumes: - "application/json" produces: - "application/json" paths: /pets: get: description: "Returns all pets from the system that the user has access to" produces: - "application/json" responses: "200": description: "A list of pets." schema: type: "array" items: $ref: "#/definitions/Pet" definitions: Pet: type: "object" required: - "id" - "name" properties: id: type: "integer" format: "int64" name: type: "string" tag: type: "string" ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-separate/common/Error.yaml ================================================ type: object required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml ================================================ type: object allOf: - $ref: 'Pet.yaml' - required: - name properties: description: type: integer format: int64 ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-separate/spec/Pet.yaml ================================================ type: object required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-separate/spec/parameters.yaml ================================================ tagsParam: name: tags in: query description: tags to filter by required: false type: array collectionFormat: csv items: type: string limitsParam: name: limit in: query description: maximum number of results to return required: false type: integer format: int32 ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-separate/spec/swagger.yaml ================================================ swagger: "2.0" info: version: 1.0.0 title: Swagger Petstore description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification termsOfService: http://swagger.io/terms/ contact: name: Swagger API Team email: apiteam@swagger.io url: http://swagger.io license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html host: petstore.swagger.io basePath: /api schemes: - http consumes: - application/json produces: - application/json paths: /pets: get: description: | Returns all pets from the system that the user has access to Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. operationId: findPets parameters: - $ref: 'parameters.yaml#/tagsParam' - $ref: 'parameters.yaml#/limitsParam' responses: "200": description: pet response schema: type: array items: $ref: 'Pet.yaml' default: description: unexpected error schema: $ref: '../common/Error.yaml' post: description: Creates a new pet in the store. Duplicates are allowed operationId: addPet parameters: - name: pet in: body description: Pet to add to the store required: true schema: $ref: 'NewPet.yaml' responses: "200": description: pet response schema: $ref: 'Pet.yaml' default: description: unexpected error schema: $ref: '../common/Error.yaml' /pets/{id}: get: description: Returns a user based on a single ID, if the user does not have access to the pet operationId: find pet by id parameters: - name: id in: path description: ID of pet to fetch required: true type: integer format: int64 responses: "200": description: pet response schema: $ref: 'Pet.yaml' default: description: unexpected error schema: $ref: '../common/Error.yaml' delete: description: deletes a single pet based on the ID supplied operationId: deletePet parameters: - name: id in: path description: ID of pet to delete required: true type: integer format: int64 responses: "204": description: pet deleted default: description: unexpected error schema: $ref: '../common/Error.yaml' ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-simple.yaml ================================================ --- swagger: "2.0" info: version: "1.0.0" title: "Swagger Petstore" description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" termsOfService: "http://swagger.io/terms/" contact: name: "Swagger API Team" license: name: "MIT" host: "petstore.swagger.io" basePath: "/api" schemes: - "http" consumes: - "application/json" produces: - "application/json" paths: /pets: get: description: "Returns all pets from the system that the user has access to" operationId: "findPets" produces: - "application/json" - "application/xml" - "text/xml" - "text/html" parameters: - name: "tags" in: "query" description: "tags to filter by" required: false type: "array" items: type: "string" collectionFormat: "csv" - name: "limit" in: "query" description: "maximum number of results to return" required: false type: "integer" format: "int32" responses: "200": description: "pet response" schema: type: "array" items: $ref: "#/definitions/Pet" default: description: "unexpected error" schema: $ref: "#/definitions/ErrorModel" post: description: "Creates a new pet in the store. Duplicates are allowed" operationId: "addPet" produces: - "application/json" parameters: - name: "pet" in: "body" description: "Pet to add to the store" required: true schema: $ref: "#/definitions/NewPet" responses: "200": description: "pet response" schema: $ref: "#/definitions/Pet" default: description: "unexpected error" schema: $ref: "#/definitions/ErrorModel" /pets/{id}: get: description: "Returns a user based on a single ID, if the user does not have access to the pet" operationId: "findPetById" produces: - "application/json" - "application/xml" - "text/xml" - "text/html" parameters: - name: "id" in: "path" description: "ID of pet to fetch" required: true type: "integer" format: "int64" responses: "200": description: "pet response" schema: $ref: "#/definitions/Pet" default: description: "unexpected error" schema: $ref: "#/definitions/ErrorModel" delete: description: "deletes a single pet based on the ID supplied" operationId: "deletePet" parameters: - name: "id" in: "path" description: "ID of pet to delete" required: true type: "integer" format: "int64" responses: "204": description: "pet deleted" default: description: "unexpected error" schema: $ref: "#/definitions/ErrorModel" definitions: Pet: type: "object" allOf: - $ref: "#/definitions/NewPet" - required: - "id" properties: id: type: "integer" format: "int64" NewPet: type: "object" required: - "name" properties: name: type: "string" tag: type: "string" ErrorModel: type: "object" required: - "code" - "message" properties: code: type: "integer" format: "int32" message: type: "string" ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore-with-external-docs.yaml ================================================ --- swagger: "2.0" info: version: "1.0.0" title: "Swagger Petstore" description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" termsOfService: "http://swagger.io/terms/" contact: name: "Swagger API Team" email: "apiteam@swagger.io" url: "http://swagger.io" license: name: "Apache 2.0" url: "https://www.apache.org/licenses/LICENSE-2.0.html" externalDocs: description: "find more info here" url: "https://swagger.io/about" host: "petstore.swagger.io" basePath: "/api" schemes: - "http" consumes: - "application/json" produces: - "application/json" paths: /pets: get: description: "Returns all pets from the system that the user has access to" operationId: "findPets" externalDocs: description: "find more info here" url: "https://swagger.io/about" produces: - "application/json" - "application/xml" - "text/xml" - "text/html" parameters: - name: "tags" in: "query" description: "tags to filter by" required: false type: "array" items: type: "string" collectionFormat: "csv" - name: "limit" in: "query" description: "maximum number of results to return" required: false type: "integer" format: "int32" responses: "200": description: "pet response" schema: type: "array" items: $ref: "#/definitions/Pet" default: description: "unexpected error" schema: $ref: "#/definitions/ErrorModel" post: description: "Creates a new pet in the store. Duplicates are allowed" operationId: "addPet" produces: - "application/json" parameters: - name: "pet" in: "body" description: "Pet to add to the store" required: true schema: $ref: "#/definitions/NewPet" responses: "200": description: "pet response" schema: $ref: "#/definitions/Pet" default: description: "unexpected error" schema: $ref: "#/definitions/ErrorModel" /pets/{id}: get: description: "Returns a user based on a single ID, if the user does not have access to the pet" operationId: "findPetById" produces: - "application/json" - "application/xml" - "text/xml" - "text/html" parameters: - name: "id" in: "path" description: "ID of pet to fetch" required: true type: "integer" format: "int64" responses: "200": description: "pet response" schema: $ref: "#/definitions/Pet" default: description: "unexpected error" schema: $ref: "#/definitions/ErrorModel" delete: description: "deletes a single pet based on the ID supplied" operationId: "deletePet" parameters: - name: "id" in: "path" description: "ID of pet to delete" required: true type: "integer" format: "int64" responses: "204": description: "pet deleted" default: description: "unexpected error" schema: $ref: "#/definitions/ErrorModel" definitions: Pet: type: "object" allOf: - $ref: "#/definitions/NewPet" - required: - "id" properties: id: type: "integer" format: "int64" NewPet: type: "object" required: - "name" properties: name: type: "string" tag: type: "string" ErrorModel: type: "object" required: - "code" - "message" properties: code: type: "integer" format: "int32" message: type: "string" ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/petstore.yaml ================================================ swagger: "2.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT host: petstore.swagger.io basePath: /v1 schemes: - http consumes: - application/json produces: - application/json paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false type: integer format: int32 responses: "200": description: A paged array of pets headers: x-next: type: string description: A link to the next page of responses schema: $ref: '#/definitions/Pets' default: description: unexpected error schema: $ref: '#/definitions/Error' post: summary: Create a pet operationId: createPets tags: - pets responses: "201": description: Null response default: description: unexpected error schema: $ref: '#/definitions/Error' /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve type: string responses: "200": description: Expected response to a valid request schema: $ref: '#/definitions/Pets' default: description: unexpected error schema: $ref: '#/definitions/Error' definitions: Pet: type: "object" required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: '#/definitions/Pet' Error: type: "object" required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: codegen/src/test/resources/examples/v2.0/yaml/uber.yaml ================================================ # this is an example of the Uber API # as a demonstration of an API spec in YAML swagger: "2.0" info: title: Uber API description: Move your app forward with the Uber API version: "1.0.0" # the domain of the service host: api.uber.com # array of all schemes that your API supports schemes: - https # will be prefixed to all paths basePath: /v1 securityDefinitions: apikey: type: apiKey name: server_token in: query produces: - application/json paths: /products: get: summary: Product Types description: The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order. parameters: - name: latitude in: query description: Latitude component of location. required: true type: number format: double - name: longitude in: query description: Longitude component of location. required: true type: number format: double security: - apikey: [] tags: - Products responses: "200": description: An array of products schema: type: array items: $ref: '#/definitions/Product' default: description: Unexpected error schema: $ref: '#/definitions/Error' /estimates/price: get: summary: Price Estimates description: The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.

The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier. parameters: - name: start_latitude in: query description: Latitude component of start location. required: true type: number format: double - name: start_longitude in: query description: Longitude component of start location. required: true type: number format: double - name: end_latitude in: query description: Latitude component of end location. required: true type: number format: double - name: end_longitude in: query description: Longitude component of end location. required: true type: number format: double tags: - Estimates responses: "200": description: An array of price estimates by product schema: type: array items: $ref: '#/definitions/PriceEstimate' default: description: Unexpected error schema: $ref: '#/definitions/Error' /estimates/time: get: summary: Time Estimates description: The Time Estimates endpoint returns ETAs for all products offered at a given location, with the responses expressed as integers in seconds. We recommend that this endpoint be called every minute to provide the most accurate, up-to-date ETAs. parameters: - name: start_latitude in: query description: Latitude component of start location. required: true type: number format: double - name: start_longitude in: query description: Longitude component of start location. required: true type: number format: double - name: customer_uuid in: query type: string format: uuid description: Unique customer identifier to be used for experience customization. - name: product_id in: query type: string description: Unique identifier representing a specific product for a given latitude & longitude. tags: - Estimates responses: "200": description: An array of products schema: type: array items: $ref: '#/definitions/Product' default: description: Unexpected error schema: $ref: '#/definitions/Error' /me: get: summary: User Profile description: The User Profile endpoint returns information about the Uber user that has authorized with the application. tags: - User responses: "200": description: Profile information for a user schema: $ref: '#/definitions/Profile' default: description: Unexpected error schema: $ref: '#/definitions/Error' /history: get: summary: User Activity description: The User Activity endpoint returns data about a user's lifetime activity with Uber. The response will include pickup locations and times, dropoff locations and times, the distance of past requests, and information about which products were requested.

The history array in the response will have a maximum length based on the limit parameter. The response value count may exceed limit, therefore subsequent API requests may be necessary. parameters: - name: offset in: query type: integer format: int32 description: Offset the list of returned results by this amount. Default is zero. - name: limit in: query type: integer format: int32 description: Number of items to retrieve. Default is 5, maximum is 100. tags: - User responses: "200": description: History information for the given user schema: $ref: '#/definitions/Activities' default: description: Unexpected error schema: $ref: '#/definitions/Error' definitions: Product: properties: product_id: type: string description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. description: type: string description: Description of product. display_name: type: string description: Display name of product. capacity: type: integer description: Capacity of product. For example, 4 people. image: type: string description: Image URL representing the product. ProductList: properties: products: description: Contains the list of products type: array items: $ref: "#/definitions/Product" PriceEstimate: properties: product_id: type: string description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles currency_code: type: string description: "[ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code." display_name: type: string description: Display name of product. estimate: type: string description: Formatted string of estimate in local currency of the start location. Estimate could be a range, a single number (flat rate) or "Metered" for TAXI. low_estimate: type: number description: Lower bound of the estimated price. high_estimate: type: number description: Upper bound of the estimated price. surge_multiplier: type: number description: Expected surge multiplier. Surge is active if surge_multiplier is greater than 1. Price estimate already factors in the surge multiplier. Profile: properties: first_name: type: string description: First name of the Uber user. last_name: type: string description: Last name of the Uber user. email: type: string description: Email address of the Uber user picture: type: string description: Image URL of the Uber user. promo_code: type: string description: Promo code of the Uber user. Activity: properties: uuid: type: string description: Unique identifier for the activity Activities: properties: offset: type: integer format: int32 description: Position in pagination. limit: type: integer format: int32 description: Number of items to retrieve (100 max). count: type: integer format: int32 description: Total number of items available. history: type: array items: $ref: '#/definitions/Activity' Error: properties: code: type: integer format: int32 message: type: string fields: type: string ================================================ FILE: codegen/src/test/resources/examples/v3.0/api-with-examples.yaml ================================================ openapi: "3.0.0" info: title: Simple API overview version: 2.0.0 paths: /: get: operationId: listVersionsv2 summary: List API versions responses: '200': description: |- 200 response content: application/json: examples: foo: value: { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] }, { "status": "EXPERIMENTAL", "updated": "2013-07-23T11:33:21Z", "id": "v3.0", "links": [ { "href": "http://127.0.0.1:8774/v3/", "rel": "self" } ] } ] } '300': description: |- 300 response content: application/json: examples: foo: value: | { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] }, { "status": "EXPERIMENTAL", "updated": "2013-07-23T11:33:21Z", "id": "v3.0", "links": [ { "href": "http://127.0.0.1:8774/v3/", "rel": "self" } ] } ] } /v2: get: operationId: getVersionDetailsv2 summary: Show API version details responses: '200': description: |- 200 response content: application/json: examples: foo: value: { "version": { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "media-types": [ { "base": "application/xml", "type": "application/vnd.openstack.compute+xml;version=2" }, { "base": "application/json", "type": "application/vnd.openstack.compute+json;version=2" } ], "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", "type": "application/pdf", "rel": "describedby" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", "type": "application/vnd.sun.wadl+xml", "rel": "describedby" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", "type": "application/vnd.sun.wadl+xml", "rel": "describedby" } ] } } '203': description: |- 203 response content: application/json: examples: foo: value: { "version": { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "media-types": [ { "base": "application/xml", "type": "application/vnd.openstack.compute+xml;version=2" }, { "base": "application/json", "type": "application/vnd.openstack.compute+json;version=2" } ], "id": "v2.0", "links": [ { "href": "http://23.253.228.211:8774/v2/", "rel": "self" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", "type": "application/pdf", "rel": "describedby" }, { "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", "type": "application/vnd.sun.wadl+xml", "rel": "describedby" } ] } } ================================================ FILE: codegen/src/test/resources/examples/v3.0/callback-example.yaml ================================================ openapi: 3.0.0 info: title: Callback Example version: 1.0.0 paths: /streams: post: description: subscribes a client to receive out-of-band data parameters: - name: callbackUrl in: query required: true description: | the location where data will be sent. Must be network accessible by the source server schema: type: string format: uri example: https://tonys-server.com responses: '201': description: subscription successfully created content: application/json: schema: description: subscription information required: - subscriptionId properties: subscriptionId: description: this unique identifier allows management of the subscription type: string example: 2531329f-fb09-4ef7-887e-84e648214436 callbacks: # the name `onData` is a convenience locator onData: # when data is sent, it will be sent to the `callbackUrl` provided # when making the subscription PLUS the suffix `/data` '{$request.query.callbackUrl}/data': post: requestBody: description: subscription payload content: application/json: schema: type: object properties: timestamp: type: string format: date-time userData: type: string responses: '202': description: | Your server implementation should return this HTTP status code if the data was received successfully '204': description: | Your server should return this HTTP status code if no longer interested in further updates ================================================ FILE: codegen/src/test/resources/examples/v3.0/link-example.yaml ================================================ openapi: 3.0.0 info: title: Link Example version: 1.0.0 paths: /2.0/users/{username}: get: operationId: getUserByName parameters: - name: username in: path required: true schema: type: string responses: '200': description: The User content: application/json: schema: $ref: '#/components/schemas/user' links: userRepositories: $ref: '#/components/links/UserRepositories' /2.0/repositories/{username}: get: operationId: getRepositoriesByOwner parameters: - name: username in: path required: true schema: type: string responses: '200': description: repositories owned by the supplied user content: application/json: schema: type: array items: $ref: '#/components/schemas/repository' links: userRepository: $ref: '#/components/links/UserRepository' /2.0/repositories/{username}/{slug}: get: operationId: getRepository parameters: - name: username in: path required: true schema: type: string - name: slug in: path required: true schema: type: string responses: '200': description: The repository content: application/json: schema: $ref: '#/components/schemas/repository' links: repositoryPullRequests: $ref: '#/components/links/RepositoryPullRequests' /2.0/repositories/{username}/{slug}/pullrequests: get: operationId: getPullRequestsByRepository parameters: - name: username in: path required: true schema: type: string - name: slug in: path required: true schema: type: string - name: state in: query schema: type: string enum: - open - merged - declined responses: '200': description: an array of pull request objects content: application/json: schema: type: array items: $ref: '#/components/schemas/pullrequest' /2.0/repositories/{username}/{slug}/pullrequests/{pid}: get: operationId: getPullRequestsById parameters: - name: username in: path required: true schema: type: string - name: slug in: path required: true schema: type: string - name: pid in: path required: true schema: type: string responses: '200': description: a pull request object content: application/json: schema: $ref: '#/components/schemas/pullrequest' links: pullRequestMerge: $ref: '#/components/links/PullRequestMerge' /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge: post: operationId: mergePullRequest parameters: - name: username in: path required: true schema: type: string - name: slug in: path required: true schema: type: string - name: pid in: path required: true schema: type: string responses: '204': description: the PR was successfully merged components: links: UserRepositories: # returns array of '#/components/schemas/repository' operationId: getRepositoriesByOwner parameters: username: $response.body#/username UserRepository: # returns '#/components/schemas/repository' operationId: getRepository parameters: username: $response.body#/owner/username slug: $response.body#/slug RepositoryPullRequests: # returns '#/components/schemas/pullrequest' operationId: getPullRequestsByRepository parameters: username: $response.body#/owner/username slug: $response.body#/slug PullRequestMerge: # executes /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge operationId: mergePullRequest parameters: username: $response.body#/author/username slug: $response.body#/repository/slug pid: $response.body#/id schemas: user: type: object properties: username: type: string uuid: type: string repository: type: object properties: slug: type: string owner: $ref: '#/components/schemas/user' pullrequest: type: object properties: id: type: integer title: type: string repository: $ref: '#/components/schemas/repository' author: $ref: '#/components/schemas/user' ================================================ FILE: codegen/src/test/resources/examples/v3.0/petstore-expanded.yaml ================================================ openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore description: A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification termsOfService: http://swagger.io/terms/ contact: name: Swagger API Team email: apiteam@swagger.io url: http://swagger.io license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html servers: - url: http://petstore.swagger.io/api paths: /pets: get: description: | Returns all pets from the system that the user has access to Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. operationId: findPets parameters: - name: tags in: query description: tags to filter by required: false style: form schema: type: array items: type: string - name: limit in: query description: maximum number of results to return required: false schema: type: integer format: int32 responses: '200': description: pet response content: application/json: schema: type: array items: $ref: '#/components/schemas/Pet' default: description: unexpected error content: application/json: schema: $ref: '#/components/schemas/Error' post: description: Creates a new pet in the store. Duplicates are allowed operationId: addPet requestBody: description: Pet to add to the store required: true content: application/json: schema: $ref: '#/components/schemas/NewPet' responses: '200': description: pet response content: application/json: schema: $ref: '#/components/schemas/Pet' default: description: unexpected error content: application/json: schema: $ref: '#/components/schemas/Error' /pets/{id}: get: description: Returns a user based on a single ID, if the user does not have access to the pet operationId: find pet by id parameters: - name: id in: path description: ID of pet to fetch required: true schema: type: integer format: int64 responses: '200': description: pet response content: application/json: schema: $ref: '#/components/schemas/Pet' default: description: unexpected error content: application/json: schema: $ref: '#/components/schemas/Error' delete: description: deletes a single pet based on the ID supplied operationId: deletePet parameters: - name: id in: path description: ID of pet to delete required: true schema: type: integer format: int64 responses: '204': description: pet deleted default: description: unexpected error content: application/json: schema: $ref: '#/components/schemas/Error' components: schemas: Pet: allOf: - $ref: '#/components/schemas/NewPet' - type: object required: - id properties: id: type: integer format: int64 NewPet: type: object required: - name properties: name: type: string tag: type: string Error: type: object required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: codegen/src/test/resources/examples/v3.0/petstore.yaml ================================================ openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pet" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: type: object required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: type: object required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: codegen/src/test/resources/examples/v3.0/uspto.yaml ================================================ openapi: 3.0.1 servers: - url: '{scheme}://developer.uspto.gov/ds-api' variables: scheme: description: 'The Data Set API is accessible via https and http' enum: - 'https' - 'http' default: 'https' info: description: >- The Data Set API (DSAPI) allows the public users to discover and search USPTO exported data sets. This is a generic API that allows USPTO users to make any CSV based data files searchable through API. With the help of GET call, it returns the list of data fields that are searchable. With the help of POST call, data can be fetched based on the filters on the field names. Please note that POST call is used to search the actual data. The reason for the POST call is that it allows users to specify any complex search criteria without worry about the GET size limitations as well as encoding of the input parameters. version: 1.0.0 title: USPTO Data Set API contact: name: Open Data Portal url: 'https://developer.uspto.gov' email: developer@uspto.gov tags: - name: metadata description: Find out about the data sets - name: search description: Search a data set paths: /: get: tags: - metadata operationId: list-data-sets summary: List available data sets responses: '200': description: Returns a list of data sets content: application/json: schema: $ref: '#/components/schemas/dataSetList' example: { "total": 2, "apis": [ { "apiKey": "oa_citations", "apiVersionNumber": "v1", "apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields", "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json" }, { "apiKey": "cancer_moonshot", "apiVersionNumber": "v1", "apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields", "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json" } ] } /{dataset}/{version}/fields: get: tags: - metadata summary: >- Provides the general information about the API and the list of fields that can be used to query the dataset. description: >- This GET API returns the list of all the searchable field names that are in the oa_citations. Please see the 'fields' attribute which returns an array of field names. Each field or a combination of fields can be searched using the syntax options shown below. operationId: list-searchable-fields parameters: - name: dataset in: path description: 'Name of the dataset.' required: true example: "oa_citations" schema: type: string - name: version in: path description: Version of the dataset. required: true example: "v1" schema: type: string responses: '200': description: >- The dataset API for the given version is found and it is accessible to consume. content: application/json: schema: type: string '404': description: >- The combination of dataset name and version is not found in the system or it is not published yet to be consumed by public. content: application/json: schema: type: string /{dataset}/{version}/records: post: tags: - search summary: >- Provides search capability for the data set with the given search criteria. description: >- This API is based on Solr/Lucense Search. The data is indexed using SOLR. This GET API returns the list of all the searchable field names that are in the Solr Index. Please see the 'fields' attribute which returns an array of field names. Each field or a combination of fields can be searched using the Solr/Lucene Syntax. Please refer https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for the query syntax. List of field names that are searchable can be determined using above GET api. operationId: perform-search parameters: - name: version in: path description: Version of the dataset. required: true schema: type: string default: v1 - name: dataset in: path description: 'Name of the dataset. In this case, the default value is oa_citations' required: true schema: type: string default: oa_citations responses: '200': description: successful operation content: application/json: schema: type: array items: type: object additionalProperties: type: object '404': description: No matching record found for the given criteria. requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: criteria: description: >- Uses Lucene Query Syntax in the format of propertyName:value, propertyName:[num1 TO num2] and date range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the response please see the 'docs' element which has the list of record objects. Each record structure would consist of all the fields and their corresponding values. type: string default: '*:*' start: description: Starting record number. Default value is 0. type: integer default: 0 rows: description: >- Specify number of rows to be returned. If you run the search with default values, in the response you will see 'numFound' attribute which will tell the number of records available in the dataset. type: integer default: 100 required: - criteria components: schemas: dataSetList: type: object properties: total: type: integer apis: type: array items: type: object properties: apiKey: type: string description: To be used as a dataset parameter value apiVersionNumber: type: string description: To be used as a version parameter value apiUrl: type: string format: uriref description: "The URL describing the dataset's fields" apiDocumentationUrl: type: string format: uriref description: A URL to the API console for each API ================================================ FILE: codegen/src/test/resources/log4j2-test.xml ================================================ ================================================ FILE: codegen/src/test/resources/no-model.yaml ================================================ --- swagger: "2.0" info: version: "1.0.0" title: "no model" license: name: "Apache 2.0" url: "http://www.apache.org/licenses/LICENSE-2.0.html" basePath: "/" paths: /sayHi: get: operationId: "sayHi" parameters: - in: "query" name: "name" type: "string" responses: 200: description: "success" schema: type: "string" ================================================ FILE: codegen/src/test/resources/swagger.yaml ================================================ --- swagger: "2.0" info: description: "This is a sample server Petstore server. You can find out more about\ \ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\ \ For this sample, you can use the api key `special-key` to test the authorization\ \ filters." version: "1.0.0" title: "Swagger Petstore" termsOfService: "http://swagger.io/terms/" contact: email: "apiteam@swagger.io" license: name: "Apache 2.0" url: "http://www.apache.org/licenses/LICENSE-2.0.html" host: "petstore.swagger.io" basePath: "/v2" tags: - name: "pet" description: "Everything about your Pets" externalDocs: description: "Find out more" url: "http://swagger.io" - name: "store" description: "Access to Petstore orders" - name: "user" description: "Operations about user" externalDocs: description: "Find out more about our store" url: "http://swagger.io" schemes: - "https" - "http" paths: /pet: post: tags: - "pet" summary: "Add a new pet to the store" description: "" operationId: "addPet" consumes: - "application/json" - "application/xml" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" required: true schema: $ref: "#/definitions/Pet" responses: 405: description: "Invalid input" security: - petstore_auth: - "write:pets" - "read:pets" put: tags: - "pet" summary: "Update an existing pet" description: "" operationId: "updatePet" consumes: - "application/json" - "application/xml" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" required: true schema: $ref: "#/definitions/Pet" responses: 400: description: "Invalid ID supplied" 404: description: "Pet not found" 405: description: "Validation exception" security: - petstore_auth: - "write:pets" - "read:pets" /pet/findByStatus: get: tags: - "pet" summary: "Finds Pets by status" description: "Multiple status values can be provided with comma separated strings" operationId: "findPetsByStatus" produces: - "application/xml" - "application/json" parameters: - name: "status" in: "query" description: "Status values that need to be considered for filter" required: true type: "array" items: type: "string" enum: - "available" - "pending" - "sold" default: "available" collectionFormat: "multi" responses: 200: description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" 400: description: "Invalid status value" security: - petstore_auth: - "write:pets" - "read:pets" /pet/findByTags: get: tags: - "pet" summary: "Finds Pets by tags" description: "Multiple tags can be provided with comma separated strings. Use\ \ tag1, tag2, tag3 for testing." operationId: "findPetsByTags" produces: - "application/xml" - "application/json" parameters: - name: "tags" in: "query" description: "Tags to filter by" required: true type: "array" items: type: "string" collectionFormat: "multi" responses: 200: description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" 400: description: "Invalid tag value" security: - petstore_auth: - "write:pets" - "read:pets" deprecated: true /pet/{petId}: get: tags: - "pet" summary: "Find pet by ID" description: "Returns a single pet" operationId: "getPetById" produces: - "application/xml" - "application/json" parameters: - name: "petId" in: "path" description: "ID of pet to return" required: true type: "integer" format: "int64" responses: 200: description: "successful operation" schema: $ref: "#/definitions/Pet" 400: description: "Invalid ID supplied" 404: description: "Pet not found" security: - api_key: [] post: tags: - "pet" summary: "Updates a pet in the store with form data" description: "" operationId: "updatePetWithForm" consumes: - "application/x-www-form-urlencoded" produces: - "application/xml" - "application/json" parameters: - name: "petId" in: "path" description: "ID of pet that needs to be updated" required: true type: "integer" format: "int64" - name: "name" in: "formData" description: "Updated name of the pet" required: false type: "string" - name: "status" in: "formData" description: "Updated status of the pet" required: false type: "string" responses: 405: description: "Invalid input" security: - petstore_auth: - "write:pets" - "read:pets" delete: tags: - "pet" summary: "Deletes a pet" description: "" operationId: "deletePet" produces: - "application/xml" - "application/json" parameters: - name: "api_key" in: "header" required: false type: "string" - name: "petId" in: "path" description: "Pet id to delete" required: true type: "integer" format: "int64" responses: 400: description: "Invalid ID supplied" 404: description: "Pet not found" security: - petstore_auth: - "write:pets" - "read:pets" /pet/{petId}/uploadImage: post: tags: - "pet" summary: "uploads an image" description: "" operationId: "uploadFile" consumes: - "multipart/form-data" produces: - "application/json" parameters: - name: "petId" in: "path" description: "ID of pet to update" required: true type: "integer" format: "int64" - name: "additionalMetadata" in: "formData" description: "Additional data to pass to server" required: false type: "string" - name: "file" in: "formData" description: "file to upload" required: false type: "file" responses: 200: description: "successful operation" schema: $ref: "#/definitions/ApiResponse" security: - petstore_auth: - "write:pets" - "read:pets" /store/inventory: get: tags: - "store" summary: "Returns pet inventories by status" description: "Returns a map of status codes to quantities" operationId: "getInventory" produces: - "application/json" parameters: [] responses: 200: description: "successful operation" schema: type: "object" additionalProperties: type: "integer" format: "int32" security: - api_key: [] /store/order: post: tags: - "store" summary: "Place an order for a pet" description: "" operationId: "placeOrder" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "order placed for purchasing the pet" required: true schema: $ref: "#/definitions/Order" responses: 200: description: "successful operation" schema: $ref: "#/definitions/Order" 400: description: "Invalid Order" /store/order/{orderId}: get: tags: - "store" summary: "Find purchase order by ID" description: "For valid response try integer IDs with value >= 1 and <= 10.\ \ Other values will generated exceptions" operationId: "getOrderById" produces: - "application/xml" - "application/json" parameters: - name: "orderId" in: "path" description: "ID of pet that needs to be fetched" required: true type: "integer" maximum: 10.0 minimum: 1.0 format: "int64" responses: 200: description: "successful operation" schema: $ref: "#/definitions/Order" 400: description: "Invalid ID supplied" 404: description: "Order not found" delete: tags: - "store" summary: "Delete purchase order by ID" description: "For valid response try integer IDs with positive integer value.\ \ Negative or non-integer values will generate API errors" operationId: "deleteOrder" produces: - "application/xml" - "application/json" parameters: - name: "orderId" in: "path" description: "ID of the order that needs to be deleted" required: true type: "integer" minimum: 1.0 format: "int64" responses: 400: description: "Invalid ID supplied" 404: description: "Order not found" /user: post: tags: - "user" summary: "Create user" description: "This can only be done by the logged in user." operationId: "createUser" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "Created user object" required: true schema: $ref: "#/definitions/User" responses: default: description: "successful operation" /user/createWithArray: post: tags: - "user" summary: "Creates list of users with given input array" description: "" operationId: "createUsersWithArrayInput" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "List of user object" required: true schema: type: "array" items: $ref: "#/definitions/User" responses: default: description: "successful operation" /user/createWithList: post: tags: - "user" summary: "Creates list of users with given input array" description: "" operationId: "createUsersWithListInput" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "List of user object" required: true schema: type: "array" items: $ref: "#/definitions/User" responses: default: description: "successful operation" /user/login: get: tags: - "user" summary: "Logs user into the system" description: "" operationId: "loginUser" produces: - "application/xml" - "application/json" parameters: - name: "username" in: "query" description: "The user name for login" required: true type: "string" - name: "password" in: "query" description: "The password for login in clear text" required: true type: "string" responses: 200: description: "successful operation" schema: type: "string" headers: X-Rate-Limit: type: "integer" format: "int32" description: "calls per hour allowed by the user" X-Expires-After: type: "string" format: "date-time" description: "date in UTC when token expires" 400: description: "Invalid username/password supplied" /user/logout: get: tags: - "user" summary: "Logs out current logged in user session" description: "" operationId: "logoutUser" produces: - "application/xml" - "application/json" parameters: [] responses: default: description: "successful operation" /user/{username}: get: tags: - "user" summary: "Get user by user name" description: "" operationId: "getUserByName" produces: - "application/xml" - "application/json" parameters: - name: "username" in: "path" description: "The name that needs to be fetched. Use user1 for testing. " required: true type: "string" responses: 200: description: "successful operation" schema: $ref: "#/definitions/User" 400: description: "Invalid username supplied" 404: description: "User not found" put: tags: - "user" summary: "Updated user" description: "This can only be done by the logged in user." operationId: "updateUser" produces: - "application/xml" - "application/json" parameters: - name: "username" in: "path" description: "name that need to be updated" required: true type: "string" - in: "body" name: "body" description: "Updated user object" required: true schema: $ref: "#/definitions/User" responses: 400: description: "Invalid user supplied" 404: description: "User not found" delete: tags: - "user" summary: "Delete user" description: "This can only be done by the logged in user." operationId: "deleteUser" produces: - "application/xml" - "application/json" parameters: - name: "username" in: "path" description: "The name that needs to be deleted" required: true type: "string" responses: 400: description: "Invalid username supplied" 404: description: "User not found" securityDefinitions: petstore_auth: type: "oauth2" authorizationUrl: "https://petstore.swagger.io/oauth/authorize" flow: "implicit" scopes: write:pets: "modify pets in your account" read:pets: "read your pets" api_key: type: "apiKey" name: "api_key" in: "header" definitions: Order: type: "object" properties: id: type: "integer" format: "int64" petId: type: "integer" format: "int64" quantity: type: "integer" format: "int32" shipDate: type: "string" format: "date-time" status: type: "string" description: "Order Status" enum: - "placed" - "approved" - "delivered" complete: type: "boolean" default: false xml: name: "Order" User: type: "object" properties: id: type: "integer" format: "int64" username: type: "string" firstName: type: "string" lastName: type: "string" email: type: "string" password: type: "string" phone: type: "string" userStatus: type: "integer" format: "int32" description: "User Status" xml: name: "User" Category: type: "object" properties: id: type: "integer" format: "int64" name: type: "string" xml: name: "Category" Tag: type: "object" properties: id: type: "integer" format: "int64" name: type: "string" xml: name: "Tag" Pet: type: "object" required: - "name" - "photoUrls" properties: id: type: "integer" format: "int64" category: $ref: "#/definitions/Category" name: type: "string" example: "doggie" photoUrls: type: "array" xml: name: "photoUrl" wrapped: true items: type: "string" tags: type: "array" xml: name: "tag" wrapped: true items: $ref: "#/definitions/Tag" status: type: "string" description: "pet status in the store" enum: - "available" - "pending" - "sold" xml: name: "Pet" ApiResponse: type: "object" properties: code: type: "integer" format: "int32" type: type: "string" message: type: "string" externalDocs: description: "Find out more about Swagger" url: "http://swagger.io" ================================================ FILE: codegen/src/test/resources/with-model.yaml ================================================ swagger: '2.0' info: version: "1.0.0" title: "no-model" license: name: "Apache 2.0" url: "http://www.apache.org/licenses/LICENSE-2.0.html" basePath: "/" paths: /getUser: get: parameters: - in: "query" name: "id" type: "string" responses: 200: description: "success" schema: $ref: '#/definitions/User' definitions: User: type: object properties: id: type: string name: type: string ================================================ FILE: common/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 common org.apache.servicecomb.toolkit core org.eclipse.jgit org.eclipse.jgit org.bouncycastle bcpkix-jdk15on org.bouncycastle bcpg-jdk15on org.bouncycastle bcprov-jdk15on junit junit test org.mockito mockito-core test org.apache.maven.plugins maven-compiler-plugin ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/ClassMaker.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.concurrent.TimeoutException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ClassMaker { public static void compile(String projectPath) throws IOException, TimeoutException, InterruptedException { Runtime runtime = Runtime.getRuntime(); boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("win") >= 0; String mvnCommand = (isWindows ? "mvn.cmd" : "mvn") + " clean package -f " + projectPath; Process exec = runtime.exec(mvnCommand); Worker worker = new Worker(exec); worker.start(); ProcessStatus ps = worker.getProcessStatus(); try { worker.join(30000); if (ps.exitCode == ProcessStatus.CODE_FAIL) { throw new RuntimeException("Command exec fail,command is: " + mvnCommand); } if (ps.exitCode == ProcessStatus.CODE_STARTED) { // not finished worker.interrupt(); throw new TimeoutException(); } } catch (InterruptedException e) { // canceled by other thread. worker.interrupt(); throw e; } } private static class Worker extends Thread { private final Process process; private ProcessStatus ps; private Worker(Process process) { this.process = process; this.ps = new ProcessStatus(); } @Override public void run() { try { new ExecReader(process.getInputStream(), "Command Exec Result Reader") { @Override public void afterReadLine(String line) { LOGGER.info(line); } }.start(); new ExecReader(process.getErrorStream(), "Command Exec Error Reader") { @Override public void afterReadLine(String line) { LOGGER.error(line); } }.start(); ps.exitCode = process.waitFor(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } ProcessStatus getProcessStatus() { return this.ps; } } public static class ProcessStatus { static final int CODE_STARTED = -257; static final int CODE_FAIL = 1; volatile int exitCode; volatile String output; } private static abstract class ExecReader extends Thread { public final Logger LOGGER; private final InputStream is; private final String readerName; public ExecReader(InputStream is, String readerName) { this.is = is; this.readerName = readerName; LOGGER = LoggerFactory.getLogger(ExecReader.class.getName() + "-" + readerName); } @Override public void run() { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = null; try { while ((line = reader.readLine()) != null) { afterReadLine(line); } } catch (IOException e) { LOGGER.error(readerName, e); } } public abstract void afterReadLine(String line); } } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/CompareAlgorithm.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.util.List; public interface CompareAlgorithm { List compare(String source, String dest); } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/ComparisionType.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; public enum ComparisionType { /** insert new content */ INSERT, /** delete content */ DELETE, /** replace old content */ REPLACE, /** not change */ EQUAL; } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/Comparison.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; public class Comparison { public final ComparisionType type; public final int originalPointBegin; public final int originalPointEnd; public final int destinationPointBegin; public final int destinationPointEnd; public Comparison(ComparisionType type, int originalPointBegin, int originalPointEnd, int destinationPointBegin, int destinationPointEnd) { this.type = type; this.originalPointBegin = originalPointBegin; this.originalPointEnd = originalPointEnd; this.destinationPointBegin = destinationPointBegin; this.destinationPointEnd = destinationPointEnd; } } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/ContractComparator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.io.IOException; import java.io.OutputStream; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ContractComparator { private final static Logger LOGGER = LoggerFactory.getLogger(ContractComparator.class); private CompareAlgorithm algorithm; private String source; private String dest; private List comparisonList; public ContractComparator(String source, String dest) { this(source, dest, new MyersAlgorithm()); } public ContractComparator(String source, String dest, CompareAlgorithm algorithm) { this.source = source; this.dest = dest; this.algorithm = algorithm; this.comparisonList = compare(); } public void setAlgorithm(CompareAlgorithm algorithm) { this.algorithm = algorithm; } public CompareAlgorithm getAlgorithm() { return algorithm; } public List compare() { return algorithm.compare(source, dest); } public boolean equals() { if (comparisonList.size() > 0) { return false; } else { return true; } } public void splitPrintToScreen() { splitPrint(System.out); } public void splitPrint(OutputStream outputStream) { try { new SplitDiffFormatter(outputStream).format(comparisonList, source, dest); } catch (IOException e) { LOGGER.error(e.getMessage()); } } } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/ContractFileType.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.util.Objects; public enum ContractFileType { YAML(".yaml"); private String suffix; ContractFileType(String suffix) { this.suffix = suffix; } public String getFileSuffix() { return this.suffix; } public static ContractFileType getValue(String name) { name = Objects.requireNonNull(name).toUpperCase(); return valueOf(name); } } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/DocumentType.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; public enum DocumentType { HTML } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/FileUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.io.File; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.HashMap; import java.util.Map; import java.util.Objects; public class FileUtils { public static void createDirectory(String pathName) throws IOException { if (pathName == null) { throw new IOException("Path is null"); } File path = new File(pathName); if (path.exists()) { return; } if (!path.mkdirs()) { throw new IOException("Failed to create directory"); } } public static Path createTempDirectory(String pathName) throws IOException { createDirectory((pathName)); return Files.createTempDirectory(Paths.get(new File(pathName).toURI()), ""); } public static Map getFilesGroupByFilename(String pathName) throws IOException { if (pathName == null) { throw new IOException("Path is null"); } if (!new File(pathName).exists()) { throw new IOException("Path " + pathName + " is not exists"); } Map filesGroup = new HashMap<>(); File path = new File(pathName); Files.walkFileTree(Paths.get(path.toURI()), new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { filesGroup.put(file.toFile().getName(), Files.readAllBytes(file)); return super.visitFile(file, attrs); } }); return filesGroup; } public static void deleteDirectory(String pathName) throws IOException { File path = new File(pathName); if (!path.isDirectory()) { if(path.exists()){ Files.delete(Paths.get(pathName)); } return; } File[] files = path.listFiles(); for (File file : Objects.requireNonNull(files)) { deleteDirectory(file.getCanonicalPath()); } Files.delete(Paths.get(pathName)); } } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/ImmediateClassLoader.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.io.File; import java.net.URL; import java.net.URLClassLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ImmediateClassLoader extends URLClassLoader { private final static Logger LOGGER = LoggerFactory.getLogger(ImmediateClassLoader.class); private String classPath; public ImmediateClassLoader(URL[] urls, ClassLoader parent) { super(urls, parent); for (URL url : urls) { if (url != null) { File file = new File(url.getPath()); classPath = file.getAbsolutePath(); scanClassFile(file); } } } private void scanClassFile(File file) { if (file.exists()) { if (file.isFile() && file.getName().endsWith(".class")) { try { String className = file.getAbsolutePath().replace(classPath + File.separator, "") .replace(File.separator, ".") .replace(".class", ""); loadClass(className); } catch (ClassNotFoundException e) { LOGGER.error(e.getMessage()); } } else if (file.isDirectory()) { for (File f : file.listFiles()) { scanClassFile(f); } } } } } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/MyersAlgorithm.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.util.ArrayList; import java.util.List; import org.eclipse.jgit.diff.EditList; import org.eclipse.jgit.diff.MyersDiff; import org.eclipse.jgit.diff.RawText; import org.eclipse.jgit.diff.RawTextComparator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MyersAlgorithm implements CompareAlgorithm { private static final Logger LOGGER = LoggerFactory.getLogger(MyersAlgorithm.class); @Override public List compare(String source, String dest) { if ((source == null) || (dest == null)) { LOGGER.error("Source is {} and dest is {}", source, dest); throw new RuntimeException("Source and dest must not be null"); } EditList diffList = new EditList(); diffList.addAll(MyersDiff.INSTANCE.diff(RawTextComparator.DEFAULT, new RawText(source.getBytes()), new RawText(dest.getBytes()))); List comparisonList = new ArrayList<>(); diffList.stream().forEachOrdered(edit -> { ComparisionType comparisionType; switch (edit.getType()) { case INSERT: comparisionType = ComparisionType.INSERT; break; case DELETE: comparisionType = ComparisionType.DELETE; break; case REPLACE: comparisionType = ComparisionType.REPLACE; break; default: comparisionType = ComparisionType.EQUAL; break; } comparisonList .add(new Comparison(comparisionType, edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB())); }); return comparisonList; } } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/SourceType.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; public enum SourceType { CODE, CONTRACT } ================================================ FILE: common/src/main/java/org/apache/servicecomb/toolkit/common/SplitDiffFormatter.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; import java.util.List; import org.eclipse.jgit.diff.DiffFormatter; public class SplitDiffFormatter extends DiffFormatter { private int radius = 3; private final OutputStream out; private static final String noNewLine = "\nthis is end of compare\n"; private static String outputFormat = "%-20s"; private static String numberFormat = "%-4s"; public SplitDiffFormatter(OutputStream out) { super(out); this.out = out; } public void format(List comparisons, String source, String dest) throws IOException { outputFormat = "%-" + (getMaxLineSize(source) + 10) + "s"; List sourceLines = readStringAsLines(source); List destLines = readStringAsLines(dest); for (int currentIndex = 0; currentIndex < comparisons.size(); ) { Comparison currentComparison = comparisons.get(currentIndex); final int endIndex = findOutputEndIndex(comparisons, currentIndex); final Comparison endComparison = comparisons.get(endIndex); int originalBegin = (int) Math.max(0, (long) currentComparison.originalPointBegin - radius); int destinationBegin = (int) Math.max(0, (long) currentComparison.destinationPointBegin - radius); int originalEnd = (int) Math.min(sourceLines.size(), (long) endComparison.originalPointEnd + radius); int destinationEnd = (int) Math.min(destLines.size(), (long) endComparison.destinationPointEnd + radius); writeHunkHeader(originalBegin, originalEnd, destinationBegin, destinationEnd); while (originalBegin < originalEnd || destinationBegin < destinationEnd) { if (originalBegin < currentComparison.originalPointBegin || endIndex + 1 < currentIndex) { writeContextLine(sourceLines, originalBegin, destLines, destinationBegin); originalBegin++; destinationBegin++; } else if (originalBegin < currentComparison.originalPointEnd) { if (destinationBegin < currentComparison.destinationPointEnd) { writeReplaceLine(sourceLines, originalBegin, destLines, destinationBegin); destinationBegin++; } else { writeRemovedLine(sourceLines, originalBegin, destLines, destinationBegin); } originalBegin++; } else if (destinationBegin < currentComparison.destinationPointEnd) { writeAddedLine(sourceLines, originalBegin, destLines, destinationBegin); destinationBegin++; } if (end(currentComparison, originalBegin, destinationBegin) && ++currentIndex < comparisons.size()) { currentComparison = comparisons.get(currentIndex); } } writeLine(noNewLine); } } public int getMaxLineSize(String text) { final int[] maxLen = {0}; readStringAsLines(text).forEach(line -> { int temp = line.length(); if (temp > maxLen[0]) { maxLen[0] = temp; } }); return maxLen[0]; } private List readStringAsLines(String text) { return Arrays.asList(text.split("\\r?\\n")); } protected void writeReplaceLine(List text, int line, List textB, int bCur) throws IOException { writeLine(buildFormatLineLeft(text, line, " -") + buildFormatLineRight(textB, bCur, " +") + "\n"); } protected void writeContextLine(List text, int line, List textB, int bCur) throws IOException { writeLine(buildFormatLineLeft(text, line, " ") + buildFormatLineRight(textB, bCur, " ") + "\n"); } protected void writeRemovedLine(List text, int line, List textB, int bCur) throws IOException { writeLine(buildFormatLineLeft(text, line, " -") + "\n"); } protected void writeAddedLine(List text, int line, List textB, int bCur) throws IOException { writeLine( String.format(numberFormat, " ") + String.format(outputFormat, " ") + buildFormatLineRight(textB, bCur, " +") + "\n"); } protected void writeLine(final String content) throws IOException { out.write(content.getBytes()); } private String buildFormatLineLeft(List text, int line, String prefix) { return String.format(numberFormat, (line + 1)) + String.format(outputFormat, prefix + text.get(line)); } private String buildFormatLineRight(List text, int line, String prefix) { return String.format(numberFormat, (line + 1)) + String .format(getOutputFormat(text.get(line).length()), prefix + text.get(line)); } private String getOutputFormat(int len) { return "%-" + len + "s"; } private static boolean end(Comparison edit, int a, int b) { return edit.originalPointEnd <= a && edit.destinationPointEnd <= b; } private int findOutputEndIndex(List edits, int i) { int end = i + 1; while (end < edits.size() && (isOriginalEnd(edits, end) || isDestinationEnd(edits, end))) { end++; } return end - 1; } private boolean isOriginalEnd(List e, int i) { return e.get(i).originalPointBegin - e.get(i - 1).originalPointEnd <= 2 * radius; } private boolean isDestinationEnd(List e, int i) { return e.get(i).destinationPointBegin - e.get(i - 1).destinationPointEnd <= 2 * radius; } } ================================================ FILE: common/src/test/java/org/apache/servicecomb/toolkit/common/ClassMakerTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import java.io.File; import java.io.IOException; import java.util.concurrent.TimeoutException; import org.hamcrest.core.StringContains; import org.junit.Assert; import org.junit.Test; public class ClassMakerTest { private static final String testResourceDirectory = "." + File.separator + "src" + File.separator + "test" + File.separator + "resources"; @Test public void runWithCorrectMavenProjectPath() throws InterruptedException, TimeoutException, IOException { String projectPath = testResourceDirectory + File.separator + "projects" + File.separator + "demo-with-correct-pom" + File.separator; ClassMaker.compile(projectPath); Assert.assertTrue(new File(projectPath + "target").exists()); } @Test public void runWithInvalidMavenProjectPath() throws InterruptedException, TimeoutException, IOException { String projectPath = testResourceDirectory + File.separator + "projects" + File.separator + "demo-with-invalid-pom" + File.separator; try { ClassMaker.compile(projectPath); Assert.fail("Run 'runWithInvalidMavenProjectPath' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { Assert.assertThat(e.getMessage(), StringContains.containsString("Command exec fail")); return; } } } ================================================ FILE: common/src/test/java/org/apache/servicecomb/toolkit/common/FileUtilsTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import org.junit.Test; public class FileUtilsTest { @Test public void createDirectoryTest() { Path path; try { path = Files.createTempDirectory(""); FileUtils.createDirectory(path.toFile().getCanonicalPath()); } catch (IOException e) { fail("Run 'createDirectoryTest' failed, unexpected to catch IOException: " + e.getMessage()); } try { FileUtils.createDirectory(null); fail("Run 'createDirectoryTest' failed, expected to occur IOException but not"); } catch (IOException e) { assertEquals("Path is null", e.getMessage()); } } @Test public void getFilesGroupByFilenameTest() { try { FileUtils.getFilesGroupByFilename(null); fail("Run 'getFilesGroupByFilenameTest' failed, expected to occur IOException but not"); } catch (IOException e) { assertEquals("Path is null", e.getMessage()); } try { FileUtils.getFilesGroupByFilename(""); fail("Run 'getFilesGroupByFilenameTest' failed, expected to occur IOException but not"); } catch (IOException e) { assertThat(e.getMessage(), containsString("is not exists")); } } } ================================================ FILE: common/src/test/java/org/apache/servicecomb/toolkit/common/TextCompareTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.common; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collections; import java.util.List; import java.util.regex.Pattern; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; public class TextCompareTest { Path sourcePath = Paths.get("./src/test/resources/compare/HelloEndPoint.yaml"); Path destPath = Paths.get("./src/test/resources/compare/HelloEndPoint2.yaml"); @Test public void testContractCompareText() throws IOException { ContractComparator contractComparator = new ContractComparator(new String(Files.readAllBytes(sourcePath)), new String(Files.readAllBytes(destPath))); assertEquals(MyersAlgorithm.class, contractComparator.getAlgorithm().getClass()); List comparisonList = contractComparator.compare(); assertEquals(3, comparisonList.size()); } @Test public void testContractCompareResultPrint() throws IOException { ContractComparator contractComparator = new ContractComparator(new String(Files.readAllBytes(sourcePath)), new String(Files.readAllBytes(destPath))); assertEquals(MyersAlgorithm.class, contractComparator.getAlgorithm().getClass()); ByteArrayOutputStream bout = new ByteArrayOutputStream(); contractComparator.splitPrint(bout); assertTrue(0 < bout.toByteArray().length); } @Test public void testContractCompareAnotherAlgorithm() throws IOException { CompareAlgorithm oneLineAlgorithm = mock(CompareAlgorithm.class); when(oneLineAlgorithm.compare(anyString(), anyString())).then(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); String source = (String) args[0]; String dest = (String) args[1]; if ((source == null || "".equals(source.trim())) && dest != null) { Comparison comparison = new Comparison(ComparisionType.INSERT, 0, 0, 1, 0); return Collections.singletonList(comparison); } if (source != null && (dest == null || "".equals(dest.trim()))) { Comparison comparison = new Comparison(ComparisionType.DELETE, 0, 0, 0, 0); return Collections.singletonList(comparison); } if (hasNewLine(source) || hasNewLine(dest)) { return null; } if ((dest).equals(source)) { return Collections.singletonList(new Comparison(ComparisionType.EQUAL, 0, 0, 0, 0)); } Comparison comparison = new Comparison(ComparisionType.REPLACE, 0, 1, 0, 1); return Collections.singletonList(comparison); } }); ContractComparator contractComparator = new ContractComparator("source line", "destination line", oneLineAlgorithm); ByteArrayOutputStream bout = new ByteArrayOutputStream(); contractComparator.splitPrint(bout); bout.flush(); assertTrue(0 < bout.toByteArray().length); bout = new ByteArrayOutputStream(); contractComparator = new ContractComparator("source line", "source line", oneLineAlgorithm); contractComparator.splitPrint(bout); assertEquals(ComparisionType.EQUAL, contractComparator.compare().get(0).type); } private boolean hasNewLine(String s) { return Pattern.compile("\\r?\\n").matcher(s).find(); } @Test public void testContractCompareException() throws IOException { try (ByteArrayOutputStream bout = new ByteArrayOutputStream()) { ContractComparator contractComparator = new ContractComparator(null, new String(Files.readAllBytes(destPath))); assertEquals(MyersAlgorithm.class, contractComparator.getAlgorithm().getClass()); contractComparator.splitPrint(bout); } catch (RuntimeException e) { assertEquals("Source and dest must not be null", e.getMessage()); } } } ================================================ FILE: common/src/test/resources/compare/HelloEndPoint.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for HelloEndPoint" x-java-interface: "gen.swagger.HelloEndPointIntf" basePath: "/hello" consumes: - "application/json" produces: - "application/json" paths: /sayHello: get: operationId: "sayHello" parameters: - name: "name" in: "query" required: false type: "string" - name: "result" in: "query" required: false type: "number" format: "double" - name: "instanceId" in: "query" required: false type: "string" - name: "callTime" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" /sayHi: get: operationId: "sayHi" parameters: - name: "name" in: "query" required: false type: "string" - name: "Authorization" in: "header" description: "aa" required: true type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: common/src/test/resources/compare/HelloEndPoint2.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.1" title: "swagger definition for HelloEndPoint" x-java-interface: "gen.swagger.HelloEndPointIntf" basePath: "/hello" consumes: - "application/json" produces: - "application/json" paths: /sayHello: get: operationId: "sayHello" parameters: - name: "name" in: "query" required: false type: "string" - name: "result" in: "query" required: false type: "number" format: "int" - name: "instanceId" in: "query" required: false type: "string" - name: "callTime" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" /sayHi: get: operationId: "sayHi" parameters: - name: "name" in: "query" required: false type: "string" - name: "Authorization" in: "header" description: "abc" required: true type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: common/src/test/resources/projects/demo-with-correct-pom/pom.xml ================================================ 4.0.0 org.apache.servicecomb.toolkit demo-with-correct-pom 1 jar ================================================ FILE: common/src/test/resources/projects/demo-with-invaild-pom/pom.xml ================================================ 4.0.0 org.apache.servicecomb.toolkit demo-with-correct-pom 1 jar invalid content ================================================ FILE: contractgen/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 contractgen org.apache.servicecomb.toolkit common org.apache.servicecomb.toolkit oas-generator-jaxrs org.apache.servicecomb.toolkit oas-generator-spring org.apache.servicecomb.toolkit oas-generator-servicecomb junit junit test org.mockito mockito-core test org.apache.maven maven-core test org.apache.maven.plugin-testing maven-plugin-testing-harness test org.apache.maven.plugins maven-compiler-plugin ================================================ FILE: contractgen/src/main/java/org/apache/servicecomb/toolkit/contractgen/DefaultContractsGenerator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.contractgen; import static org.apache.servicecomb.toolkit.common.ContractFileType.YAML; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; import java.util.Map; import java.util.Vector; import javax.ws.rs.Path; import org.apache.servicecomb.provider.pojo.RpcSchema; import org.apache.servicecomb.provider.rest.common.RestSchema; import org.apache.servicecomb.toolkit.ContractsGenerator; import org.apache.servicecomb.toolkit.common.ContractFileType; import org.apache.servicecomb.toolkit.common.ImmediateClassLoader; import org.apache.servicecomb.toolkit.generator.context.OasGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.core.util.Yaml; import io.swagger.v3.oas.models.OpenAPI; public class DefaultContractsGenerator implements ContractsGenerator { private static Logger LOGGER = LoggerFactory.getLogger(DefaultContractsGenerator.class); private Map config; private List classpathUrls; private String outputDir = "."; private ContractFileType contractfileType = YAML; @Override public boolean canProcess(String type) { return "default".equals(type); } @SuppressWarnings("unchecked") @Override public void configure(Map config) { this.config = config; if (config == null) { return; } Object classpathUrlsObj = config.get("classpathUrls"); if (classpathUrlsObj instanceof List) { classpathUrls = (List) classpathUrlsObj; } Object outputDirObj = config.get("outputDir"); if (outputDirObj instanceof String) { outputDir = (String) outputDirObj; } Object contractFileTypeObj = config.get("contractFileType"); if (contractFileTypeObj instanceof String) { contractfileType = ContractFileType.getValue((String) contractFileTypeObj); } } @SuppressWarnings("ResultOfMethodCallIgnored") @Override public void generate() throws RuntimeException { URL[] runtimeUrls = new URL[classpathUrls.size()]; for (int i = 0; i < classpathUrls.size(); i++) { String element = classpathUrls.get(i); try { runtimeUrls[i] = new File(element).toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException("Wrong element in classpath", e); } } if (!checkConfig()) { throw new IllegalArgumentException("Cannot found configuration"); } ImmediateClassLoader immediateClassLoader = new ImmediateClassLoader(runtimeUrls, Thread.currentThread().getContextClassLoader()); try { Vector allClass = getAllClass(immediateClassLoader); for (int i = 0; i < allClass.size(); i++) { Class loadClass = (Class) allClass.get(i); if (!canProcess(loadClass)) { continue; } OasGenerator oasGenerator = new OasGenerator(); OpenAPI oas = oasGenerator.generate(loadClass); if (oas == null) { continue; } String oasPretty = Yaml.pretty(oas); File outputFile = new File( outputDir + File.separator + loadClass.getSimpleName() + contractfileType .getFileSuffix()); if (!outputFile.exists()) { if (!outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } outputFile.createNewFile(); } Files.write(Paths.get(outputFile.toURI()), oasPretty.getBytes()); } } catch (IOException e) { throw new RuntimeException(e); } } private boolean checkConfig() { return config != null && classpathUrls != null; } private static boolean canProcess(Class loadClass) { if (loadClass == null) { return false; } RestSchema restSchema = loadClass.getAnnotation(RestSchema.class); if (restSchema != null) { return true; } RestController controller = loadClass.getAnnotation(RestController.class); if (controller != null) { return true; } RpcSchema rpcSchema = loadClass.getAnnotation(RpcSchema.class); if (rpcSchema != null) { return true; } RequestMapping requestMapping = loadClass.getAnnotation(RequestMapping.class); if (requestMapping != null) { return true; } Path pathAnnotation = loadClass.getAnnotation(Path.class); if (pathAnnotation != null) { return true; } return false; } private static Vector getAllClass(ClassLoader classLoader) { Field classesField; try { classesField = ClassLoader.class.getDeclaredField("classes"); classesField.setAccessible(true); if (classesField.get(classLoader) instanceof Vector) { return (Vector) classesField.get(classLoader); } } catch (Exception e) { throw new RuntimeException("Cannot get class from ClassLoader " + classLoader.getClass()); } return new Vector<>(); } } ================================================ FILE: contractgen/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.ContractsGenerator ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.apache.servicecomb.toolkit.contractgen.DefaultContractsGenerator ================================================ FILE: contractgen/src/test/java/org/apache/servicecomb/toolkit/contractgen/ContractTestUtil.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.contractgen; import javassist.ClassPool; import javassist.CtClass; import javassist.bytecode.AnnotationsAttribute; import javassist.bytecode.ConstPool; import javassist.bytecode.annotation.Annotation; public class ContractTestUtil { public CtClass createCtClass(String className) throws Exception { ClassPool pool = ClassPool.getDefault(); return pool.makeClass("org.apache.servicecomb.toolkit.contractgen.test." + className); } public Class putAnnotationToClass(String className, Class annotationClass) throws Exception { CtClass ctClass = createCtClass(className); ConstPool constPool = ctClass.getClassFile().getConstPool(); AnnotationsAttribute requestMappingAnnotationAttr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag); Annotation requestMapping = new Annotation(annotationClass.getName(), constPool); requestMappingAnnotationAttr.addAnnotation(requestMapping); ctClass.getClassFile().addAttribute(requestMappingAnnotationAttr); return ctClass.toClass(); } } ================================================ FILE: contractgen/src/test/java/org/apache/servicecomb/toolkit/contractgen/DefaultContractsGeneratorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.contractgen; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeoutException; import javax.ws.rs.Path; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.testing.resources.TestResources; import org.apache.maven.project.MavenProject; import org.apache.servicecomb.provider.pojo.RpcSchema; import org.apache.servicecomb.provider.rest.common.RestSchema; import org.apache.servicecomb.toolkit.ContractsGenerator; import org.apache.servicecomb.toolkit.GeneratorFactory; import org.apache.servicecomb.toolkit.common.ClassMaker; import org.junit.Rule; import org.junit.Test; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javassist.CtClass; public class DefaultContractsGeneratorTest { @Rule public TestResources resources = new TestResources(); private static final String TEST_PROJECT = "demo"; @Test public void testCanProcess() { assertTrue(new DefaultContractsGenerator().canProcess("default")); assertFalse(new DefaultContractsGenerator().canProcess("others")); } @Test public void testConfigure() throws DependencyResolutionRequiredException { Map config = new HashMap<>(); MavenProject project = new MavenProject(); config.put("classpathUrls", project.getRuntimeClasspathElements()); config.put("outputDir", "target"); config.put("contractfileType", "yaml"); } @Test public void testGenerate() throws DependencyResolutionRequiredException, IOException, TimeoutException, InterruptedException { File demoPath = this.resources.getBasedir(TEST_PROJECT); ClassMaker.compile(demoPath.getCanonicalPath()); MavenProject project = mock(MavenProject.class); List runtimeUrlPath = new ArrayList<>(); runtimeUrlPath.add(demoPath + File.separator + "target/classes"); Map config = new HashMap<>(); given(project.getRuntimeClasspathElements()).willReturn(runtimeUrlPath); config.put("classpathUrls", project.getRuntimeClasspathElements()); config.put("outputDir", "target"); config.put("contractfileType", "yaml"); DefaultContractsGenerator defaultContractsGenerator = new DefaultContractsGenerator(); defaultContractsGenerator.configure(config); try { defaultContractsGenerator.generate(); } catch (RuntimeException e) { fail("Run 'testGenerate' failed and unexpected to catch RuntimeException: " + e.getMessage()); } } @Test public void testCheckConfig() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, DependencyResolutionRequiredException { DefaultContractsGenerator defaultContractsGenerator = new DefaultContractsGenerator(); Method method = defaultContractsGenerator.getClass().getDeclaredMethod("checkConfig", new Class[] {}); method.setAccessible(true); defaultContractsGenerator.configure(null); assertThat(method.invoke(defaultContractsGenerator), is(false)); Map config = new HashMap<>(); config.put("classpathUrls", null); defaultContractsGenerator.configure(config); assertThat(method.invoke(defaultContractsGenerator), is(false)); MavenProject project = new MavenProject(); config.put("classpathUrls", project.getRuntimeClasspathElements()); defaultContractsGenerator.configure(config); assertThat(method.invoke(defaultContractsGenerator), is(true)); } @Test public void testPrivateCanProcess() throws Exception { DefaultContractsGenerator defaultContractsGenerator = new DefaultContractsGenerator(); Method method = defaultContractsGenerator.getClass().getDeclaredMethod("canProcess", Class.class); method.setAccessible(true); assertThat(method.invoke(defaultContractsGenerator, new Object[] {null}), is(false)); Class mockClass; ContractTestUtil contractTestUtil = new ContractTestUtil(); CtClass ctClass = contractTestUtil.createCtClass("TestCanProcess"); assertThat(method.invoke("TestCanProcess", ctClass.toClass()), is(false)); mockClass = contractTestUtil.putAnnotationToClass("TestRestSchema", RestSchema.class); assertThat(method.invoke("TestRestSchema", mockClass), is(true)); mockClass = contractTestUtil.putAnnotationToClass("TestRestController", RestController.class); assertThat(method.invoke("TestRestController", mockClass), is(true)); mockClass = contractTestUtil.putAnnotationToClass("TestRpcSchema", RpcSchema.class); assertThat(method.invoke("TestRpcSchema", mockClass), is(true)); mockClass = contractTestUtil.putAnnotationToClass("TestRequestMapping", RequestMapping.class); assertThat(method.invoke("TestRequestMapping", mockClass), is(true)); mockClass = contractTestUtil.putAnnotationToClass("TestPath", Path.class); assertThat(method.invoke("TestPath", mockClass), is(true)); } @Test public void testgetAllClass() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { DefaultContractsGenerator defaultContractsGenerator = new DefaultContractsGenerator(); Method method = defaultContractsGenerator.getClass() .getDeclaredMethod("getAllClass", ClassLoader.class); method.setAccessible(true); try { method.invoke(defaultContractsGenerator, new Object[] {null}); } catch (Exception e) { assertTrue(true); return; } fail("Run 'testgetAllClass' failed, expected to catch Exception but not"); } @Test public void testGetContractsGeneratorInstance() { ContractsGenerator defaultGenerator = GeneratorFactory.getGenerator(ContractsGenerator.class, "default"); assertNotNull(defaultGenerator); ContractsGenerator unknownGenerator = GeneratorFactory.getGenerator(ContractsGenerator.class, "unknown"); assertNull(unknownGenerator); } } ================================================ FILE: contractgen/src/test/projects/demo/pom.xml ================================================ 4.0.0 org.apache.servicecomb.toolkit demo 0.3.0-SNAPSHOT demo-contractgen-test jar org.springframework.boot spring-boot-starter-parent 1.5.12.RELEASE org.springframework.boot spring-boot-starter org.springframework spring-web ================================================ FILE: contractgen/src/test/projects/demo/src/main/java/demo/Application.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public Application() { } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ================================================ FILE: contractgen/src/test/projects/demo/src/main/java/demo/HelloEndPoint.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package demo; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping({"/hello"}) public class HelloEndPoint { public HelloEndPoint() { } @GetMapping({"/sayHello"}) public String sayHello(String name) { return "Hello, " + name; } @GetMapping({"/sayHi"}) public String sayHi(String name) { return "Hi, " + name; } } ================================================ FILE: contractgen/src/test/resources/log4j2-test.xml ================================================ ================================================ FILE: core/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 core org.openapitools openapi-generator org.apache.maven.plugins maven-compiler-plugin ================================================ FILE: core/src/main/java/org/apache/servicecomb/toolkit/CodeGenerator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit; public interface CodeGenerator extends Generator { } ================================================ FILE: core/src/main/java/org/apache/servicecomb/toolkit/ContractsGenerator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit; public interface ContractsGenerator extends Generator { } ================================================ FILE: core/src/main/java/org/apache/servicecomb/toolkit/DocGenerator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit; public interface DocGenerator extends Generator { } ================================================ FILE: core/src/main/java/org/apache/servicecomb/toolkit/Generator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit; import java.util.Map; public interface Generator { boolean canProcess(String type); void configure(Map config); void generate(); } ================================================ FILE: core/src/main/java/org/apache/servicecomb/toolkit/GeneratorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.ServiceLoader; import java.util.concurrent.ConcurrentHashMap; public class GeneratorFactory { private final static Map interfaceMap = new ConcurrentHashMap<>(); static { addGeneratorType(CodeGenerator.class); addGeneratorType(DocGenerator.class); addGeneratorType(ContractsGenerator.class); } public static void addGeneratorType(Class generatorClass) { if (interfaceMap.get(generatorClass.getName()) == null) { interfaceMap.put(generatorClass.getName(), loadInitialCodeGenerators(generatorClass)); } } private static List loadInitialCodeGenerators(Class generatorClass) { List registeredGenerators = new ArrayList<>(); ServiceLoader.load(generatorClass).forEach(registeredGenerators::add); return registeredGenerators; } public static T getGenerator(Class generatorClass, String type) { @SuppressWarnings("unchecked") List registeredList = (List) interfaceMap.get(generatorClass.getName()); for (T generator : registeredList) { if (generator.canProcess(type)) { return generator; } } return null; } } ================================================ FILE: docgen/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 docgen false jcenter-releases jcenter https://jcenter.bintray.com org.apache.servicecomb.toolkit core org.apache.servicecomb swagger-generator-core org.checkerframework checker-compat-qual com.google.guava listenablefuture org.apache.commons commons-lang3 junit junit test org.apache.maven.plugins maven-compiler-plugin ================================================ FILE: docgen/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.docgen; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collections; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.servicecomb.toolkit.DocGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.OpenAPI; public class ContractsSwaggerUIGenerator implements DocGenerator { private final static Logger LOGGER = LoggerFactory.getLogger(ContractsSwaggerUIGenerator.class); private static Pattern variablePattern = Pattern.compile("(?<=\\{\\{)[a-zA-Z0-9_-]*(?=\\}\\})"); private final static String DOC_SUFFIX = ".html"; private OpenAPI contractContent; private String outputPath = "."; @Override public boolean canProcess(String type) { return "default".equals(type) || "swagger-ui".equals(type); } @Override public void configure(Map config) { this.contractContent = (OpenAPI) config.get("contractContent"); this.outputPath = (String) config.get("outputPath"); } private boolean checkConfig() { if (contractContent == null) { return false; } return true; } @Override public void generate() { if (!checkConfig()) { throw new IllegalArgumentException("Cannot found configuration"); } String swaggerUiHtml = null; try { String swaggerJson = Json.mapper().writeValueAsString(contractContent); swaggerUiHtml = renderHtml(getSwaggerUiHtml(), Collections.singletonMap("spec", swaggerJson)); outputPath = correctPath(outputPath); Path outputFile = Paths.get(outputPath); if (!Files.exists(outputFile)) { if (outputFile.getParent() != null) { Files.createDirectories(outputFile.getParent()); } Files.createFile(outputFile); } Files.write(outputFile, swaggerUiHtml.getBytes()); } catch (IOException e) { throw new RuntimeException(e); } } private String correctPath(String filepath) { if (!filepath.endsWith(DOC_SUFFIX)) { return filepath + DOC_SUFFIX; } return filepath; } private String renderHtml(String html, Map args) { Matcher variableMatcher = variablePattern.matcher(html); while (variableMatcher.find()) { String variableStr = variableMatcher.group(); String variableValue = args.get(variableStr); html = html.replace("{{" + variableStr + "}}", variableValue); } return html; } private String getSwaggerUiHtml() throws IOException { int len; ByteArrayOutputStream bout = new ByteArrayOutputStream(); InputStream in = this.getClass().getClassLoader().getResourceAsStream("webroot/swagger-ui.html"); byte[] buf = new byte[1024]; while ((len = in.read(buf)) != -1) { bout.write(buf, 0, len); } bout.close(); in.close(); return new String(bout.toByteArray()); } } ================================================ FILE: docgen/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.DocGenerator ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.apache.servicecomb.toolkit.docgen.ContractsSwaggerUIGenerator ================================================ FILE: docgen/src/main/resources/webroot/swagger-ui.html ================================================ Title
================================================ FILE: docgen/src/test/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGeneratorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.docgen; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Objects; import org.apache.commons.io.FileUtils; import org.apache.servicecomb.toolkit.DocGenerator; import org.apache.servicecomb.toolkit.GeneratorFactory; import org.junit.Assert; import org.junit.Test; import io.swagger.parser.OpenAPIParser; import io.swagger.v3.parser.core.models.SwaggerParseResult; public class ContractsSwaggerUIGeneratorTest { @Test public void testContractTransferToSwaggerUI() throws IOException { InputStream in = ContractsSwaggerUIGeneratorTest.class.getClassLoader().getResourceAsStream("HelloEndPoint.yaml"); StringBuilder sb = new StringBuilder(); byte[] bytes = new byte[1024]; int len = -1; while ((len = in.read(bytes)) != -1) { sb.append(new String(bytes, 0, len)); } OpenAPIParser openAPIParser = new OpenAPIParser(); SwaggerParseResult swaggerParseResult = openAPIParser.readContents(sb.toString(), null, null); Path tempDir = Files.createTempDirectory(null); Path outputPath = Paths.get(tempDir.toFile().getAbsolutePath() + File.separator + "swagger-ui.html"); DocGenerator docGenerator = GeneratorFactory.getGenerator(DocGenerator.class, "default"); Map docGeneratorConfig = new HashMap<>(); docGeneratorConfig.put("contractContent", swaggerParseResult.getOpenAPI()); docGeneratorConfig.put("outputPath", outputPath.toFile().getCanonicalPath()); Objects.requireNonNull(docGenerator).configure(docGeneratorConfig); docGenerator.generate(); Assert.assertTrue(Files.exists(outputPath)); FileUtils.deleteDirectory(tempDir.toFile()); } @Test public void testContractTransferToOther() { DocGenerator docGenerator = GeneratorFactory.getGenerator(DocGenerator.class, "other"); Assert.assertNull(docGenerator); } } ================================================ FILE: docgen/src/test/resources/HelloEndPoint.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for HelloEndPoint" x-java-interface: "gen.swagger.HelloEndPointIntf" basePath: "/hello" consumes: - "application/json" produces: - "application/json" paths: /sayHello: get: operationId: "sayHello" parameters: - name: "name" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" /sayHi: get: operationId: "sayHi" parameters: - name: "name" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: integration-tests/coverage-aggregate/pom.xml ================================================ integration-tests org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 coverage-aggregate org.apache.servicecomb.toolkit cli org.apache.servicecomb.toolkit codegen org.apache.servicecomb.toolkit common org.apache.servicecomb.toolkit core org.apache.servicecomb.toolkit docgen org.apache.servicecomb.toolkit toolkit-maven-plugin org.apache.servicecomb.toolkit oas-validator-core org.apache.servicecomb.toolkit oas-validator-core-spring org.apache.servicecomb.toolkit oas-validator-style org.apache.servicecomb.toolkit oas-validator-compatibility org.apache.servicecomb.toolkit oas-validator-compatibility-spring jacoco org.jacoco jacoco-maven-plugin post-integration-test report-aggregate ================================================ FILE: integration-tests/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 integration-tests pom coverage-aggregate org.apache.maven.plugins maven-deploy-plugin true ================================================ FILE: oas-generator/oas-generator-core/pom.xml ================================================ oas-generator org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 oas-generator-core io.swagger.core.v3 swagger-models io.swagger.core.v3 swagger-annotations io.swagger.core.v3 swagger-core junit junit test org.ow2.asm asm org.powermock powermock-module-junit4 test org.powermock powermock-api-mockito test ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/HttpStatuses.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; public class HttpStatuses { /** * HTTP/1.0 - RFC 1945 */ public final static String OK = "200"; } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/MediaTypes.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; /** * Common media type constants * * @see HTTP/1.1 section 3.7 */ public class MediaTypes { public final static String WILDCARD = "*/*"; public final static String APPLICATION_XML = "application/xml"; public final static String APPLICATION_ATOM_XML = "application/atom+xml"; public final static String APPLICATION_XHTML_XML = "application/xhtml+xml"; public final static String APPLICATION_SVG_XML = "application/svg+xml"; public final static String APPLICATION_JSON = "application/json"; public final static String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded"; public final static String MULTIPART_FORM_DATA = "multipart/form-data"; public final static String APPLICATION_OCTET_STREAM = "application/octet-stream"; public final static String TEXT_PLAIN = "text/plain"; public final static String TEXT_XML = "text/xml"; public final static String TEXT_HTML = "text/html"; public final static String SERVER_SENT_EVENTS = "text/event-stream"; public final static String APPLICATION_JSON_PATCH_JSON = "application/json-patch+json"; } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/AnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; public interface AnnotationProcessor { void process(Annotation annotation, Context context); } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/ApiResponseMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import io.swagger.v3.oas.annotations.headers.Header; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.models.media.MediaType; public class ApiResponseMethodAnnotationProcessor implements MethodAnnotationProcessor { @Override public void process(ApiResponse response, OperationContext context) { io.swagger.v3.oas.models.responses.ApiResponse apiResponse = new io.swagger.v3.oas.models.responses.ApiResponse(); Content[] contentAnnotations = response.content(); Optional.ofNullable(contentAnnotations).ifPresent(contents -> { for (Content contentAnnotation : contents) { io.swagger.v3.oas.models.media.Content content = new io.swagger.v3.oas.models.media.Content(); MediaType mediaType = new MediaType(); content.addMediaType(contentAnnotation.mediaType(), mediaType); apiResponse.setContent(content); } }); if (StringUtils.isNotEmpty(response.description())) { apiResponse.setDescription(response.description()); } else { apiResponse.description("OK"); } Header[] headersAnnotation = response.headers(); Optional.ofNullable(headersAnnotation).ifPresent(headers -> { for (Header headerAnnotation : headers) { io.swagger.v3.oas.models.headers.Header header = new io.swagger.v3.oas.models.headers.Header(); header.description(headerAnnotation.description()); header.deprecated(headerAnnotation.deprecated()); apiResponse.addHeaderObject(headerAnnotation.name(), header); } }); context.addResponse(response.responseCode(), apiResponse); } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/ApiResponsesMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import java.util.Arrays; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; public class ApiResponsesMethodAnnotationProcessor implements MethodAnnotationProcessor { @Override public void process(ApiResponses responses, OperationContext context) { MethodAnnotationProcessor apiResponseAnnotationProcessor = context.getParser() .findMethodAnnotationProcessor(ApiResponse.class); if (apiResponseAnnotationProcessor != null) { Arrays.stream(responses.value()).forEach(response -> apiResponseAnnotationProcessor.process(response, context)); } } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/ClassAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; public interface ClassAnnotationProcessor extends AnnotationProcessor { } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/MethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; public interface MethodAnnotationProcessor extends AnnotationProcessor { } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/ModelInterceptor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import java.lang.reflect.Type; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.media.Schema; public interface ModelInterceptor { int order(); Schema process(Type cls, Components components); } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/OpenApiDefinitionClassAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import java.util.ArrayList; import java.util.List; import org.apache.servicecomb.toolkit.generator.context.OasContext; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.License; import io.swagger.v3.oas.models.servers.Server; import io.swagger.v3.oas.models.tags.Tag; public class OpenApiDefinitionClassAnnotationProcessor implements ClassAnnotationProcessor { @Override public void process(OpenAPIDefinition openAPIDefinition, OasContext context) { Info infoAnnotation = openAPIDefinition.info(); io.swagger.v3.oas.models.info.Info info = new io.swagger.v3.oas.models.info.Info(); License license = new License(); Contact contact = new Contact(); license.url(infoAnnotation.license().url()); license.name(infoAnnotation.license().name()); contact.name(infoAnnotation.contact().name()); contact.url(infoAnnotation.contact().url()); contact.email(infoAnnotation.contact().email()); info .description(infoAnnotation.description()) .title(infoAnnotation.title()) .version(infoAnnotation.version()) .license(license) .contact(contact); context.getOpenAPI().info(info); if (openAPIDefinition.servers() != null) { List serverList = new ArrayList<>(); for (io.swagger.v3.oas.annotations.servers.Server serverAnnotation : openAPIDefinition.servers()) { Server server = new Server(); server.url(serverAnnotation.url()); server.description(serverAnnotation.description()); serverList.add(server); } context.getOpenAPI().servers(serverList); } if (openAPIDefinition.tags() != null) { List tagList = new ArrayList<>(); for (io.swagger.v3.oas.annotations.tags.Tag tagAnnotation : openAPIDefinition.tags()) { Tag tag = new Tag(); tag .name(tagAnnotation.name()) .description(tagAnnotation.description()); tagList.add(tag); } context.getOpenAPI().tags(tagList); } } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/OperationMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import java.util.Arrays; import java.util.Map; import java.util.Optional; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.apache.servicecomb.toolkit.generator.util.SwaggerAnnotationUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; public class OperationMethodAnnotationProcessor implements MethodAnnotationProcessor { @Override public void process(Operation annotation, OperationContext context) { context.setOperationId(annotation.operationId()); context.setDeprecated(annotation.deprecated()); context.setDescription(annotation.description()); Map extensionsFromAnnotation = SwaggerAnnotationUtils .getExtensionsFromAnnotation(annotation.extensions()); Optional.ofNullable(extensionsFromAnnotation) .ifPresent(extensions -> extensions.forEach(context::addExtension)); ApiResponse[] responses = annotation.responses(); MethodAnnotationProcessor apiResponseAnnotationProcessor = context.getParser() .findMethodAnnotationProcessor(ApiResponse.class); for (ApiResponse response : responses) { Optional.ofNullable(apiResponseAnnotationProcessor) .ifPresent(processor -> processor.process(response, context)); } context.setHttpMethod(annotation.method()); context.setSummary(annotation.summary()); Arrays.stream(annotation.tags()).forEach(context::addTag); } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/ParamAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; public interface ParamAnnotationProcessor extends AnnotationProcessor { } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/ParameterAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import java.util.Collections; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.apache.servicecomb.toolkit.generator.util.SwaggerAnnotationUtils; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.Explode; import io.swagger.v3.oas.annotations.media.Schema; public class ParameterAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(Parameter parameterAnnotation, ParameterContext paramCtx) { Schema schema = parameterAnnotation.schema(); io.swagger.v3.oas.models.media.Schema schemaFromAnnotation = SwaggerAnnotationUtils.getSchemaFromAnnotation(schema); if (schemaFromAnnotation != null) { paramCtx.setSchema(schemaFromAnnotation); } paramCtx.setRequired(parameterAnnotation.required()); paramCtx.setAllowEmptyValue(parameterAnnotation.allowEmptyValue()); paramCtx.setAllowReserved(parameterAnnotation.allowReserved()); paramCtx.setDeprecated(parameterAnnotation.deprecated()); paramCtx.setExample(parameterAnnotation.example()); switch (parameterAnnotation.in()) { case HEADER: paramCtx.setIn(InType.HEADER); break; case COOKIE: paramCtx.setIn(InType.COOKIE); break; case PATH: paramCtx.setIn(InType.PATH); break; case QUERY: case DEFAULT: default: paramCtx.setIn(InType.QUERY); } paramCtx.setDescription(parameterAnnotation.description()); paramCtx.setRef(parameterAnnotation.ref()); paramCtx.setName(parameterAnnotation.name()); paramCtx.setExplode(getExplode(parameterAnnotation.explode())); paramCtx.applyAnnotations(Collections.singletonList(parameterAnnotation)); } private Boolean getExplode(Explode explode) { switch (explode) { case TRUE: { return true; } case FALSE: case DEFAULT: default: { return false; } } } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestBodyParamAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import java.util.List; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.apache.servicecomb.toolkit.generator.util.SwaggerAnnotationUtils; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.parameters.RequestBody; public class RequestBodyParamAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(RequestBody requestBodyAnnotation, ParameterContext context) { context.setIn(InType.BODY); io.swagger.v3.oas.models.parameters.RequestBody requestBody = new io.swagger.v3.oas.models.parameters.RequestBody(); requestBody.setRequired(requestBodyAnnotation.required()); requestBody.setDescription(requestBodyAnnotation.description()); if (StringUtils.isNotEmpty(requestBodyAnnotation.ref())) { requestBody.set$ref(requestBodyAnnotation.ref()); } Content[] contentAnnotations = requestBodyAnnotation.content(); List contentsFromAnnotation = SwaggerAnnotationUtils .getContentFromAnnotation(contentAnnotations); Optional.ofNullable(contentsFromAnnotation).ifPresent(contents -> { requestBody.content(contents.get(0)); }); context.setRequestBody(requestBody); } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/context/Context.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.context; import org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser; public interface Context { OpenApiAnnotationParser getParser(); } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/context/IExtensionsContext.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.context; import java.util.Map; public interface IExtensionsContext extends Context { void addExtension(String name, Object value); Map getExtensions(); } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/context/ISchemaContext.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.context; import io.swagger.v3.oas.models.media.Schema; public interface ISchemaContext extends Context, IExtensionsContext { Schema getSchema(); void setSchema(Schema schema); } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/context/OasContext.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.context; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.PathItem.HttpMethod; import io.swagger.v3.oas.models.Paths; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.servers.Server; public class OasContext implements IExtensionsContext { private OpenAPI openAPI; private String basePath; private Class cls; private List operationList = new ArrayList<>(); private OpenApiAnnotationParser parser; private List schemaCtxList = new ArrayList<>(); private String httpMethod; private String[] consumes; private String[] produces; private String[] headers; public OasContext(OpenApiAnnotationParser parser) { this(new OpenAPI(), parser); } public OasContext(OpenAPI openAPI, OpenApiAnnotationParser parser) { this.openAPI = openAPI; this.parser = parser; } public OpenAPI toOpenAPI() { ensurePaths(); for (OperationContext operationCtx : operationList) { if (!operationCtx.hasOperation()) { continue; } if (openAPI.getPaths() == null) { openAPI.setPaths(new Paths()); } PathItem pathItem = openAPI.getPaths().get(operationCtx.getPath()); if (pathItem == null) { pathItem = new PathItem(); openAPI.path(operationCtx.getPath(), pathItem); } pathItem.operation(HttpMethod.valueOf(operationCtx.getHttpMethod()), operationCtx.toOperation()); } // return null if there is no restful resource if (openAPI.getPaths() == null || openAPI.getPaths().size() == 0) { return null; } openAPI.info(new Info().title("gen").version("1.0.0")); correctBasepath(); correctComponents(); openAPI.servers(Collections.singletonList(new Server().url(basePath))); schemaCtxList.forEach(schemaCtx -> openAPI.schema(schemaCtx.getSchema().getName(), schemaCtx.getSchema())); return openAPI; } private void correctComponents() { Components nullComponents = new Components(); if (nullComponents.equals(getComponents())) { openAPI.setComponents(null); } } private void correctBasepath() { if (StringUtils.isEmpty(basePath)) { basePath = "/"; } if (!basePath.startsWith("/")) { basePath = "/" + basePath; } } public Components getComponents() { if (openAPI.getComponents() == null) { openAPI.setComponents(new Components()); } return openAPI.getComponents(); } private void ensurePaths() { if (openAPI.getPaths() == null) { openAPI.setPaths(new Paths()); } } @Override public OpenApiAnnotationParser getParser() { return parser; } public void setParser(OpenApiAnnotationParser parser) { this.parser = parser; } public OpenAPI getOpenAPI() { return openAPI; } public String getBasePath() { return basePath; } public Class getCls() { return cls; } public void setCls(Class cls) { this.cls = cls; } public void setBasePath(String basePath) { this.basePath = basePath; } public void addOperation(OperationContext operation) { operationList.add(operation); } @Override public void addExtension(String name, Object value) { openAPI.addExtension(name, value); } @Override public Map getExtensions() { return openAPI.getExtensions(); } public String getHttpMethod() { return httpMethod; } public void setHttpMethod(String httpMethod) { this.httpMethod = httpMethod; } public String[] getConsumers() { return consumes; } public void setConsumers(String[] consumes) { this.consumes = consumes; } public String[] getProduces() { return produces; } public void setProduces(String[] produces) { this.produces = produces; } public String[] getHeaders() { return headers; } public void setHeaders(String[] headers) { this.headers = headers; } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/context/OasGenerator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.context; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.ServiceLoader; import java.util.Set; import org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser; import io.swagger.v3.oas.models.OpenAPI; public class OasGenerator { private static List parserList = new ArrayList<>(); static { ServiceLoader.load(OpenApiAnnotationParser.class).forEach(parserList::add); parserList.sort(Comparator.comparingInt(OpenApiAnnotationParser::getOrder)); } public OpenAPI generate(Class cls) { Optional parserOptional = parserList.stream().filter(parser -> parser.canProcess(cls)) .findFirst(); if (!parserOptional.isPresent()) { return null; } OasContext context = new OasContext(parserOptional.get()); parserOptional.get().parser(cls, context); return context.toOpenAPI(); } public List generate(Set classes) { List openApiList = new ArrayList<>(); for (Class cls : classes) { OpenAPI openAPI = generate(cls); if (openAPI != null) { openApiList.add(openAPI); } } return openApiList; } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/context/OperationContext.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.context; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.generator.HttpStatuses; import org.apache.servicecomb.toolkit.generator.MediaTypes; import org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser; import org.apache.servicecomb.toolkit.generator.util.ModelConverter; import org.apache.servicecomb.toolkit.generator.util.RequestResponse; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.media.Content; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; import io.swagger.v3.oas.models.parameters.HeaderParameter; import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponses; public class OperationContext implements IExtensionsContext { private static final RequestBody nullRequestBody = new RequestBody(); private OasContext parentContext; private Method method; private Operation operation = new Operation(); private String operationId; private String path; private String httpMethod; private ApiResponses apiResponses = new ApiResponses(); private List parameterContexts = new ArrayList<>(); private OpenApiAnnotationParser parser; private Boolean deprecated = false; private String description = null; private String summary; private List tags; private String[] consumes; private String[] produces; private String[] headers; public OperationContext(Method method, OasContext parentContext) { this.parentContext = parentContext; this.method = method; this.parser = parentContext.getParser(); this.parentContext.addOperation(this); } @Override public OpenApiAnnotationParser getParser() { return parser; } public boolean hasOperation() { return getHttpMethod() != null && method != null; } public Operation toOperation() { if (!hasOperation()) { return null; } if (StringUtils.isEmpty(operationId)) { operationId = method.getName(); } operation.operationId(operationId); processHeaders(); processProduces(); correctResponse(apiResponses); operation.setResponses(apiResponses); RequestBody requestBody = new RequestBody(); Content content = new Content(); MediaType mediaType = new MediaType(); // process parameter List parameterList = parameterContexts.stream() .map(parameterContext -> { // requestBody if (parameterContext.isRequestBody()) { Schema schema = mediaType.getSchema(); if (schema == null) { schema = new ObjectSchema(); mediaType.schema(schema); } schema.addProperties(parameterContext.getName(), parameterContext.getSchema()); if (consumes != null) { for (String consume : getConsumers()) { content.addMediaType(consume, mediaType); } } else { if (parameterContext.getConsumers() != null && parameterContext.getConsumers().size() > 0) { for (String consume : parameterContext.getConsumers()) { content.addMediaType(consume, mediaType); } } else { content.addMediaType(MediaTypes.APPLICATION_JSON, mediaType); } } requestBody.setContent(content); requestBody.setRequired(parameterContext.getRequired()); return null; } // parameter return parameterContext.toParameter(); }) .filter(parameter -> parameter != null) .collect(Collectors.toList()); if (parameterList.size() > 0) { operation.parameters(parameterList); } if (!nullRequestBody.equals(requestBody)) { operation.setRequestBody(requestBody); } return operation; } private void processHeaders() { if (getHeaders() == null) { return; } Arrays.stream(headers).forEach(header -> { String[] headMap = header.split("="); if (headMap.length == 2) { HeaderParameter headerParameter = new HeaderParameter(); headerParameter.setName(headMap[0]); StringSchema value = new StringSchema(); value.setDefault(headMap[1]); headerParameter.setSchema(value); operation.addParametersItem(headerParameter); } }); } private void processProduces() { if (getProduces() == null) { return; } List produceList = Arrays.stream(produces).filter(s -> !StringUtils.isEmpty(s)) .collect(Collectors.toList()); if (!produceList.isEmpty()) { ApiResponse apiResponse = new ApiResponse(); Content content = new Content(); MediaType mediaType = new MediaType(); Schema schema = ModelConverter .getSchema(getMethod().getReturnType(), getComponents(), RequestResponse.RESPONSE); mediaType.schema(schema); for (String produce : produceList) { content.addMediaType(produce, mediaType); } apiResponse.description("OK"); apiResponse.setContent(content); addResponse(HttpStatuses.OK, apiResponse); } } public void setRequestBody(RequestBody requestBody) { operation.requestBody(requestBody); } public void correctResponse(ApiResponses apiResponses) { if (apiResponses == null) { return; } // no annotations are processed // generate a default response based on the method return value if (apiResponses.get(HttpStatuses.OK) == null) { ApiResponse apiResponse = new ApiResponse(); Class returnType = method.getReturnType(); if (returnType == Void.TYPE || returnType == Void.class) { return; } MediaType mediaType = new MediaType(); Schema refSchema = ModelConverter.getSchema(returnType, getComponents(), RequestResponse.RESPONSE); mediaType.schema(refSchema); Content content = new Content(); content.addMediaType(MediaTypes.APPLICATION_JSON, mediaType); apiResponse.description("OK"); apiResponse.setContent(content); apiResponses.addApiResponse(HttpStatuses.OK, apiResponse); } } public Components getComponents() { return parentContext.getComponents(); } public void addResponse(String key, ApiResponse response) { apiResponses.addApiResponse(key, response); } public ApiResponses getApiResponses() { return apiResponses; } public void setApiResponses(ApiResponses apiResponses) { this.apiResponses = apiResponses; } public String getOperationId() { return operationId; } public void setOperationId(String operationId) { this.operationId = operationId; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public Operation getOperation() { return operation; } public OpenAPI getOpenAPI() { return parentContext.getOpenAPI(); } public Method getMethod() { return method; } public OasContext getOpenApiContext() { return parentContext; } public String getHttpMethod() { return Optional.ofNullable(httpMethod).orElse(parentContext.getHttpMethod()); } public void setHttpMethod(String httpMethod) { if (this.httpMethod != null) { throw new IllegalArgumentException(String.format("too many http method in the method %s", method.getName())); } this.httpMethod = httpMethod.toUpperCase(); } public Boolean getDeprecated() { return deprecated; } public void setDeprecated(Boolean deprecated) { this.deprecated = deprecated; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getSummary() { return summary; } public void setSummary(String summary) { this.summary = summary; } public List getTags() { return tags; } public void setTags(List tags) { this.tags = tags; } public void addTag(String tag) { if (tags == null) { tags = new ArrayList<>(); } tags.add(tag); } @Override public void addExtension(String name, Object value) { operation.addExtension(name, value); } @Override public Map getExtensions() { return operation.getExtensions(); } public String[] getConsumers() { return consumes; } public void setConsumers(String[] consumes) { this.consumes = consumes; } public void addParamCtx(ParameterContext ctx) { this.parameterContexts.add(ctx); } public String[] getProduces() { if (produces == null) { produces = parentContext.getProduces(); } return produces; } public void setProduces(String[] produces) { this.produces = produces; } public String[] getHeaders() { if (headers == null) { headers = parentContext.getHeaders(); } return headers; } public void setHeaders(String[] headers) { this.headers = headers; } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/context/ParameterContext.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.context; import java.lang.annotation.Annotation; import java.lang.reflect.Parameter; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser; import org.apache.servicecomb.toolkit.generator.util.ModelConverter; import org.apache.servicecomb.toolkit.generator.util.ParamUtils; import org.apache.servicecomb.toolkit.generator.util.RequestResponse; import io.swagger.v3.core.util.ParameterProcessor; import io.swagger.v3.core.util.ReflectionUtils; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.enums.ParameterStyle; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.examples.Example; import io.swagger.v3.oas.models.media.Content; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.parameters.RequestBody; public class ParameterContext implements ISchemaContext, IExtensionsContext { private final static Schema nullSchema = new Schema(); private OperationContext parentContext; private Parameter parameter; private Object defaultValue; private io.swagger.v3.oas.models.parameters.Parameter oasParameter = new io.swagger.v3.oas.models.parameters.Parameter(); private String name = null; private InType in = null; private String description = null; private Boolean required = null; private Boolean deprecated = null; private Boolean allowEmptyValue = null; private ParameterStyle style; private Boolean explode = null; private Boolean allowReserved = null; private Schema schema; private Object example = null; private Map examples = null; private Content content = null; private String ref = null; private RequestBody requestBody; private List consumes; public ParameterContext(OperationContext parentContext, Parameter parameter) { this.parentContext = parentContext; this.parameter = parameter; parentContext.addParamCtx(this); } public io.swagger.v3.oas.models.parameters.Parameter toParameter() { if (parameter == null) { return null; } ensureName(); if (schema == null || nullSchema.equals(schema)) { schema = ModelConverter.getSchema(parameter.getType(), getComponents(), RequestResponse.REQUEST); oasParameter.schema(schema); } if (in == null) { oasParameter.setIn(ParameterIn.QUERY.toString()); } else { switch (in) { case PATH: { oasParameter.setIn(ParameterIn.PATH.toString()); break; } case QUERY: { oasParameter.setIn(ParameterIn.QUERY.toString()); break; } case COOKIE: { oasParameter.setIn(ParameterIn.COOKIE.toString()); break; } case HEADER: { oasParameter.setIn(ParameterIn.HEADER.toString()); break; } default: oasParameter.setIn(ParameterIn.QUERY.toString()); } } if (defaultValue != null) { required = false; oasParameter.getSchema().setDefault(defaultValue); } oasParameter.setRequired(required); return oasParameter; } public boolean isRequestBody() { if (in != null && (in.equals(InType.BODY) || in.equals(InType.FORM))) { return true; } return false; } public void applyAnnotations(List annotations) { ParameterProcessor .applyAnnotations(oasParameter, getType(), annotations, getComponents(), null, null, null); } private void ensureName() { if (StringUtils.isEmpty(name)) { // try get real type name = ParamUtils.getParameterName(parentContext.getMethod(), parameter); } if (StringUtils.isEmpty(name)) { name = parameter.getName(); } oasParameter.setName(name); } public OperationContext getOperationContext() { return parentContext; } public Object getDefaultValue() { return defaultValue; } public void setDefaultValue(Object defaultValue) { this.defaultValue = defaultValue; } public Components getComponents() { return parentContext.getComponents(); } public io.swagger.v3.oas.models.parameters.Parameter getOasParameter() { return oasParameter; } public Parameter getParameter() { return parameter; } public void setParameter(Parameter parameter) { this.parameter = parameter; } public boolean isRequired() { return required; } public Type getType() { if (getRealType() != null) { return getRealType(); } if (StringUtils.isNotEmpty(oasParameter.getIn())) { return ReflectionUtils.typeFromString(oasParameter.getIn()); } return null; } public void addConsume(String consume) { if (consumes == null) { consumes = new ArrayList<>(); } consumes.add(consume); } public List getConsumers() { return consumes; } public Type getRealType() { return parameter.getParameterizedType(); } public void setRequestBody(RequestBody requestBody) { required = requestBody.getRequired(); description = requestBody.getDescription(); this.requestBody = requestBody; } public RequestBody getRequestBody() { return requestBody; } @Override public Schema getSchema() { Schema refSchema = oasParameter.getSchema(); if (refSchema == null || nullSchema.equals(refSchema)) { refSchema = ModelConverter.getSchema(parameter.getType(), getComponents(), RequestResponse.REQUEST); oasParameter.schema(refSchema); } return refSchema; } @Override public void setSchema(Schema schema) { this.schema = schema; } @Override public void addExtension(String name, Object value) { oasParameter.addExtension(name, value); } @Override public Map getExtensions() { return oasParameter.getExtensions(); } @Override public OpenApiAnnotationParser getParser() { return parentContext.getParser(); } public String getName() { ensureName(); return name; } public void setName(String name) { this.name = name; } public InType getIn() { return in; } public void setIn(InType in) { this.in = in; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Boolean getRequired() { return required; } public void setRequired(Boolean required) { this.required = required; } public Boolean getDeprecated() { return deprecated; } public void setDeprecated(Boolean deprecated) { this.deprecated = deprecated; } public Boolean getAllowEmptyValue() { return allowEmptyValue; } public void setAllowEmptyValue(Boolean allowEmptyValue) { this.allowEmptyValue = allowEmptyValue; } public ParameterStyle getStyle() { return style; } public void setStyle(ParameterStyle style) { this.style = style; } public Boolean getExplode() { return explode; } public void setExplode(Boolean explode) { this.explode = explode; } public Boolean getAllowReserved() { return allowReserved; } public void setAllowReserved(Boolean allowReserved) { this.allowReserved = allowReserved; } public Object getExample() { return example; } public void setExample(Object example) { this.example = example; } public Map getExamples() { return examples; } public void setExamples(Map examples) { this.examples = examples; } public Content getContent() { return content; } public void setContent(Content content) { this.content = content; } public String getRef() { return ref; } public void setRef(String ref) { this.ref = ref; } public enum InType { QUERY, PATH, HEADER, COOKIE, FORM, BODY } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/parser/AbstractAnnotationParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.parser; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.servicecomb.toolkit.generator.annotation.AnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ApiResponseMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ApiResponsesMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ClassAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.MethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.OpenApiDefinitionClassAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.OperationMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ParameterAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestBodyParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; public abstract class AbstractAnnotationParser implements OpenApiAnnotationParser { private Class cls; private OasContext context; protected Map, ClassAnnotationProcessor> classAnnotationMap = new HashMap<>(); protected Map, MethodAnnotationProcessor> methodAnnotationMap = new HashMap<>(); protected Map, ParamAnnotationProcessor> parameterAnnotationMap = new HashMap<>(); public AbstractAnnotationParser() { initMethodAnnotationProcessor(); initClassAnnotationProcessor(); initParameterAnnotationProcessor(); } @Override public void parser(Class cls, OasContext context) { this.cls = cls; this.context = context; if (!canProcess(cls)) { return; } for (Annotation clsAnnotation : cls.getAnnotations()) { AnnotationProcessor annotationProcessor = classAnnotationMap.get(clsAnnotation.annotationType()); if (annotationProcessor == null) { continue; } annotationProcessor.process(clsAnnotation, context); } postParseClassAnnotaion(context); List methods = Arrays.asList(cls.getDeclaredMethods()); methods.sort(Comparator.comparing(Method::getName)); for (Method m : methods) { OperationContext operationContext = new OperationContext(m, context); for (Annotation methodAnnotation : m.getAnnotations()) { MethodAnnotationProcessor annotationProcessor = methodAnnotationMap.get(methodAnnotation.annotationType()); if (annotationProcessor != null) { annotationProcessor.process(methodAnnotation, operationContext); } } postParseMethodAnnotation(operationContext); java.lang.reflect.Parameter[] parameters = m.getParameters(); for (java.lang.reflect.Parameter parameter : parameters) { ParameterContext parameterContext = new ParameterContext(operationContext, parameter); for (Annotation paramAnnotation : parameter.getAnnotations()) { ParamAnnotationProcessor paramAnnotationProcessor = parameterAnnotationMap .get(paramAnnotation.annotationType()); if (paramAnnotationProcessor != null) { paramAnnotationProcessor.process(paramAnnotation, parameterContext); } } postParseParameterAnnotation(parameterContext); } } } @Override public void postParseClassAnnotaion(OasContext context) { } @Override public void postParseMethodAnnotation(OperationContext context) { } @Override public void postParseParameterAnnotation(ParameterContext context) { } public void initMethodAnnotationProcessor() { methodAnnotationMap.put(Operation.class, new OperationMethodAnnotationProcessor()); methodAnnotationMap.put(ApiResponse.class, new ApiResponseMethodAnnotationProcessor()); methodAnnotationMap.put(ApiResponses.class, new ApiResponsesMethodAnnotationProcessor()); } public void initClassAnnotationProcessor() { classAnnotationMap.put(OpenAPIDefinition.class, new OpenApiDefinitionClassAnnotationProcessor()); } public void initParameterAnnotationProcessor() { parameterAnnotationMap.put(Parameter.class, new ParameterAnnotationProcessor()); parameterAnnotationMap.put(RequestBody.class, new RequestBodyParamAnnotationProcessor()); } @Override public ClassAnnotationProcessor findClassAnnotationProcessor(Class annotationType) { return classAnnotationMap.get(annotationType); } @Override public MethodAnnotationProcessor findMethodAnnotationProcessor(Class annotationType) { return methodAnnotationMap.get(annotationType); } @Override public ParamAnnotationProcessor findParameterAnnotationProcessor(Class annotationType) { return parameterAnnotationMap.get(annotationType); } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/parser/api/OpenApiAnnotationParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.parser.api; import java.lang.annotation.Annotation; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.annotation.ClassAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.MethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ParamAnnotationProcessor; public interface OpenApiAnnotationParser { /** * * @param cls * @param context */ void parser(Class cls, OasContext context); /** * Used for sorting * For the same parsing class, only the same programming model can be parsed at the same time. * @return */ int getOrder(); boolean canProcess(Class cls); void postParseClassAnnotaion(OasContext context); void postParseMethodAnnotation(OperationContext context); void postParseParameterAnnotation(ParameterContext context); ClassAnnotationProcessor findClassAnnotationProcessor(Class annotationType); MethodAnnotationProcessor findMethodAnnotationProcessor(Class annotationType); ParamAnnotationProcessor findParameterAnnotationProcessor(Class annotationType); } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/util/ArrayModelConverter.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.util; import java.util.Iterator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.TypeFactory; import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; import io.swagger.v3.core.jackson.AbstractModelConverter; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; public class ArrayModelConverter extends AbstractModelConverter { protected ArrayModelConverter(ObjectMapper mapper) { super(mapper); } @Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { String typeName = _typeName(TypeFactory.defaultInstance().constructType(type.getType())); ArraySchema schema; if ("Array".equals(typeName)) { schema = new ArraySchema(); if (!(type.getType() instanceof Class)) { return null; } Schema itemSchema = context.resolve(new AnnotatedType(((Class) type.getType()).getComponentType())); schema.setItems(itemSchema); return schema; } return super.resolve(type, context, chain); } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/util/LocalVariableVisitor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.util; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Type; public class LocalVariableVisitor extends MethodVisitor { private String[] parameterNames; private final int[] lvtSlotIndex; private final Type[] args; public LocalVariableVisitor(int api, String desc, boolean isStatic, String[] parameterNames) { super(api); this.parameterNames = parameterNames; this.args = Type.getArgumentTypes(desc); this.lvtSlotIndex = computeLvtSlotIndices(isStatic, this.args); } @Override public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index) { for (int i = 0; i < this.lvtSlotIndex.length; i++) { if (this.lvtSlotIndex[i] == index) { this.parameterNames[i] = name; } } super.visitLocalVariable(name, descriptor, signature, start, end, index); } int[] computeLvtSlotIndices(boolean isStatic, Type[] paramTypes) { int[] lvtIndex = new int[paramTypes.length]; int nextIndex = (isStatic ? 0 : 1); for (int i = 0; i < paramTypes.length; i++) { lvtIndex[i] = nextIndex; if (isWideType(paramTypes[i])) { nextIndex += 2; } else { nextIndex++; } } return lvtIndex; } private boolean isWideType(Type aType) { return (aType == Type.LONG_TYPE || aType == Type.DOUBLE_TYPE); } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/util/ModelConverter.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.util; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.ServiceLoader; import org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverterContextImpl; import io.swagger.v3.core.jackson.ModelResolver; import io.swagger.v3.core.util.PrimitiveType; import io.swagger.v3.core.util.RefUtils; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; public class ModelConverter { private static final ModelConverterContextImpl context; private static final List interceptorMgr = new ArrayList<>(); static { ServiceLoader.load(ModelInterceptor.class).forEach(ModelConverter::registerInterceptor); ArrayModelConverter arrayModelConverter = new ArrayModelConverter(mapper()); ModelResolver modelResolver = new ModelResolver(mapper()); context = new ModelConverterContextImpl(Arrays.asList(arrayModelConverter, modelResolver)); } public static void registerInterceptor(ModelInterceptor interceptor) { interceptorMgr.add(interceptor); interceptorMgr.sort(Comparator.comparingInt(ModelInterceptor::order)); } public static void unRegisterInterceptor(ModelInterceptor interceptor) { interceptorMgr.remove(interceptor); } public static Schema getSchema(Type cls) { return getSchema(cls, null, null); } public static Schema getSchema(Type cls, Components components, RequestResponse requestResponse) { for (ModelInterceptor interceptor : interceptorMgr) { Schema schema = interceptor.process(cls, components); if (schema != null) { return schema; } } if (cls instanceof Class && requestResponse != null) { List beanProperties = null; switch (requestResponse) { case REQUEST: beanProperties = getRequestBeanTypes((Class) cls); break; case RESPONSE: beanProperties = getResponseBeanTypes((Class) cls); break; default: } Optional.ofNullable(beanProperties) .ifPresent(properties -> properties.forEach(type -> { if (type instanceof ParameterizedType) { Type[] actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments(); Arrays.stream(actualTypeArguments).forEach(arg -> getSchema(arg, components, requestResponse)); } if (type instanceof Class) { getSchema(type, components, requestResponse); } }) ); } Schema schema = PrimitiveType.createProperty(cls); if (schema == null) { schema = context .resolve(new AnnotatedType(cls)); } if (schema == null) { if (cls == List.class) { schema = new ArraySchema(); ((ArraySchema) schema).setItems(new ObjectSchema()); } } if (components == null) { return schema; } // correct reference Schema refSchema = schema; if (shouldExtractRef(schema)) { ensureSchemaNameExist(schema); schema.$ref(null); components.addSchemas(schema.getName(), schema); refSchema = new Schema(); refSchema.set$ref(RefUtils.constructRef(schema.getName())); } if (schema instanceof ArraySchema) { ArraySchema arraySchema = (ArraySchema) schema; Schema itemSchema = arraySchema.getItems(); if (shouldExtractRef(itemSchema)) { ensureSchemaNameExist(itemSchema); itemSchema.$ref(null); components.addSchemas(itemSchema.getName(), itemSchema); Schema itemRefSchema = new Schema(); itemRefSchema.set$ref(RefUtils.constructRef(itemSchema.getName())); arraySchema.setItems(itemRefSchema); } refSchema = arraySchema; } return refSchema; } private static void ensureSchemaNameExist(Schema schema) { if (schema.getName() != null) { return; } if (schema.get$ref() != null) { schema.setName((String) RefUtils.extractSimpleName(schema.get$ref()).getKey()); return; } } public static boolean shouldExtractRef(Schema schema) { if (schema.getName() != null || schema.get$ref() != null) { return true; } return false; } public static ObjectMapper mapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper; } public static List getRequestBeanTypes(Class cls) { if (cls.isPrimitive()) { return null; } Method[] declaredMethods = cls.getDeclaredMethods(); List beanProperties = new ArrayList<>(); for (Method method : declaredMethods) { /** * Meet the following requirements, can be considered a request bean property * 1. method modifiers is public and non-static * 2. method name should be setAbc or setABC, setabc is not a setter method * 3. return value of method is void * 4. method has only one parameter */ if (Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers()) && method.getName() .startsWith("set") && method.getName().length() > 3 && Character.isUpperCase(method.getName().charAt(3)) && method.getReturnType() .equals(Void.TYPE) && method.getParameterCount() == 1) { beanProperties.add(method.getGenericParameterTypes()[0]); } } return beanProperties; } public static List getResponseBeanTypes(Class cls) { if (cls.isPrimitive()) { return null; } Method[] declaredMethods = cls.getDeclaredMethods(); List beanPropertyTypes = new ArrayList<>(); for (Method method : declaredMethods) { /** * Meet the following requirements, can be considered a response bean property * 1. method modifiers is public and non-static * 2. method name should be getAbc or getABC, getabc is not a getter method * 3. return value of method is not void * 4. method has no parameters */ if (Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers()) && method.getName() .startsWith("get") && method.getName().length() > 3 && Character.isUpperCase(method.getName().charAt(3)) && !method.getReturnType() .equals(Void.TYPE) && method.getParameterCount() == 0) { beanPropertyTypes.add(method.getGenericReturnType()); } } return beanPropertyTypes; } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/util/ParamUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.util; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Parameter; import java.util.HashMap; import java.util.Map; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; public class ParamUtils { private static final String STATIC_CLASS_INIT = ""; public static final Map parameterCache = new HashMap(); public static String getParameterName(Method method, Parameter parameter) { String[] parameterNames = parameterCache.get(method); if (parameterNames == null) { parameterNames = initParameterNames(method); if (parameterNames == null) { return null; } } int paramIndex = getParamIndex(method, parameter); if (paramIndex >= 0) { return parameterNames[paramIndex]; } return null; } private static int getParamIndex(Method method, Parameter parameter) { Parameter[] parameters = method.getParameters(); for (int i = 0; i < parameters.length; i++) { if (parameters[i].equals(parameter)) { return i; } } return -1; } private static String[] initParameterNames(Method m) { boolean isStatic = Modifier.isStatic(m.getModifiers()); String[] parameterNames = new String[m.getParameterCount()]; try { String className = m.getDeclaringClass().getName(); String classRawName = className.replace('.', '/') + ".class"; InputStream is = null; ClassLoader classLoader = m.getDeclaringClass().getClassLoader(); if (classLoader != null) { is = classLoader.getResourceAsStream(classRawName); } else { is = m.getDeclaringClass().getResourceAsStream(classRawName); } if (is == null) { return null; } ClassReader clsReader = new ClassReader(is); ClassWriter clsWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS); clsReader.accept(new ClassVisitor(Opcodes.ASM7, clsWriter) { @Override public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { MethodVisitor methodVisitor = super.visitMethod(access, name, descriptor, signature, exceptions); if (!m.getName().equals(name) || !descriptor.equals(Type.getMethodDescriptor(m))) { return methodVisitor; } if (!isSyntheticOrBridged(access) && !STATIC_CLASS_INIT.equals(name)) { return new LocalVariableVisitor(this.api, descriptor, isStatic, parameterNames); } return methodVisitor; } }, 0); } catch (IOException e) { e.printStackTrace(); } parameterCache.put(m, parameterNames); return parameterNames; } private static boolean isSyntheticOrBridged(int access) { return (((access & Opcodes.ACC_SYNTHETIC) | (access & Opcodes.ACC_BRIDGE)) > 0); } } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/util/RequestResponse.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.util; public enum RequestResponse { /** * Mark a request */ REQUEST, /** * Mark a response */ RESPONSE } ================================================ FILE: oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/util/SwaggerAnnotationUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.util; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import io.swagger.v3.oas.annotations.extensions.Extension; import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Encoding; import io.swagger.v3.oas.models.media.Content; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.media.Schema; public class SwaggerAnnotationUtils { public static List getContentFromAnnotation( io.swagger.v3.oas.annotations.media.Content... contentAnnotations) { if (contentAnnotations == null || contentAnnotations.length < 1) { return null; } List contents = new ArrayList<>(); for (io.swagger.v3.oas.annotations.media.Content contentAnnotation : contentAnnotations) { io.swagger.v3.oas.models.media.Content content = new io.swagger.v3.oas.models.media.Content(); MediaType mediaType = new MediaType(); Encoding[] encodingAnnotations = contentAnnotation.encoding(); Optional.ofNullable(encodingAnnotations).ifPresent(encodings -> { for (Encoding encodingAnnotation : encodings) { io.swagger.v3.oas.models.media.Encoding encoding = new io.swagger.v3.oas.models.media.Encoding(); encoding.contentType(encodingAnnotation.contentType()); encoding.allowReserved(encodingAnnotation.allowReserved()); encoding.explode(encodingAnnotation.explode()); mediaType.addEncoding(encodingAnnotation.name(), encoding); } }); content.addMediaType(contentAnnotation.mediaType(), mediaType); contents.add(content); } return contents; } public static Schema getSchemaFromAnnotation(io.swagger.v3.oas.annotations.media.Schema schema) { if (schema == null) { return null; } Schema schemaObj = new Schema(); schemaObj.setName(schema.name()); schemaObj.setDescription(schema.description()); schemaObj.setType(schema.type()); schemaObj.setTitle(schema.title()); schemaObj.setNullable(schema.nullable()); schemaObj.setDefault(schema.defaultValue()); schemaObj.setFormat(schema.format()); schemaObj.setDeprecated(schema.deprecated()); Map extensionsFromAnnotation = getExtensionsFromAnnotation(schema.extensions()); schemaObj.extensions(extensionsFromAnnotation); return schemaObj; } public static Map getExtensionsFromAnnotation(Extension... extensions) { if (extensions == null || extensions.length < 1) { return null; } Map extensionMap = new HashMap<>(); for (Extension extension : extensions) { ExtensionProperty[] properties = extension.properties(); Optional.ofNullable(properties).ifPresent(props -> { for (ExtensionProperty prop : props) { extensionMap.put(prop.name(), prop.value()); } }); } return extensionMap; } } ================================================ FILE: oas-generator/oas-generator-core/src/test/java/org/apache/servicecomb/toolkit/generator/AnnotationProcessorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import java.lang.reflect.Method; import org.apache.servicecomb.toolkit.generator.annotation.ApiResponseMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ApiResponsesMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.OpenApiDefinitionClassAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.OperationMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ParameterAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestBodyParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.parser.AbstractAnnotationParser; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import io.swagger.v3.oas.annotations.ExternalDocumentation; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.Explode; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.enums.ParameterStyle; import io.swagger.v3.oas.annotations.extensions.Extension; import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.headers.Header; import io.swagger.v3.oas.annotations.info.Contact; import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.info.License; import io.swagger.v3.oas.annotations.links.Link; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.servers.Server; import io.swagger.v3.oas.annotations.servers.ServerVariable; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.models.media.StringSchema; public class AnnotationProcessorTest { @Test public void processApiResponseAnnotation() { OasContext oasContext = new OasContext(null); OperationContext context = new OperationContext(null, oasContext); ApiResponseMethodAnnotationProcessor apiResProcessor = new ApiResponseMethodAnnotationProcessor(); ApiResponse apiResponse = Mockito.mock(ApiResponse.class); Content[] contents = new Content[1]; contents[0] = Mockito.mock(Content.class); Mockito.when(contents[0].mediaType()).thenReturn(MediaTypes.APPLICATION_JSON); Mockito.when(apiResponse.content()).thenReturn(contents); Mockito.when(apiResponse.responseCode()).thenReturn("200"); apiResProcessor.process(apiResponse, context); Assert.assertNotNull(context.getApiResponses().get("200")); Assert.assertNull(context.getApiResponses().get("500")); } @Test public void processApiResponsesAnnotation() { OasContext oasContext = new OasContext(new AbstractAnnotationParser() { @Override public int getOrder() { return 0; } @Override public boolean canProcess(Class cls) { return true; } }); OperationContext context = new OperationContext(null, oasContext); ApiResponsesMethodAnnotationProcessor apiRessProcessor = new ApiResponsesMethodAnnotationProcessor(); ApiResponses apiResponses = Mockito.mock(ApiResponses.class); Content[] contents = new Content[1]; contents[0] = Mockito.mock(Content.class); Mockito.when(contents[0].mediaType()).thenReturn(MediaTypes.APPLICATION_JSON); ApiResponse apiResponse = Mockito.mock(ApiResponse.class); Mockito.when(apiResponse.content()).thenReturn(contents); Mockito.when(apiResponse.responseCode()).thenReturn("200"); Mockito.when(apiResponses.value()).thenReturn(new ApiResponse[] {apiResponse}); apiRessProcessor.process(apiResponses, context); Assert.assertNotNull(context.getApiResponses().get("200")); Assert.assertNull(context.getApiResponses().get("500")); } @Test public void processOperationAnnotation() throws NoSuchMethodException { OasContext oasContext = null; OperationMethodAnnotationProcessor operationMethodAnnotationProcessor = new OperationMethodAnnotationProcessor(); Method helloMethod = OpenapiDef.class.getDeclaredMethod("hello", String.class, Object.class); Operation operation = helloMethod.getAnnotation(Operation.class); oasContext = new OasContext(new AbstractAnnotationParser() { @Override public int getOrder() { return 0; } @Override public boolean canProcess(Class cls) { return true; } }); OperationContext context = new OperationContext(helloMethod, oasContext); operationMethodAnnotationProcessor.process(operation, context); Assert.assertEquals("hello-operation", context.getOperationId()); } @Test public void processOpenApiDefinitionClassAnnotation() throws NoSuchMethodException { OasContext oasContext = null; OpenApiDefinitionClassAnnotationProcessor openApiDefinitionClassAnnotationProcessor = new OpenApiDefinitionClassAnnotationProcessor(); OpenAPIDefinition openAPIDefinition = OpenapiDef.class.getAnnotation(OpenAPIDefinition.class); oasContext = new OasContext(new AbstractAnnotationParser() { @Override public int getOrder() { return 0; } @Override public boolean canProcess(Class cls) { return true; } }); openApiDefinitionClassAnnotationProcessor.process(openAPIDefinition, oasContext); // Assert.assertEquals("hello-operation", context.getOperationId()); } @Test public void processRequestBodyAnnotation() throws NoSuchMethodException { OasContext oasContext = new OasContext(null); RequestBodyParamAnnotationProcessor operationMethodAnnotationProcessor = new RequestBodyParamAnnotationProcessor(); RequestBody requestBody = Mockito.mock(RequestBody.class); Mockito.when(requestBody.content()).thenReturn(new Content[] {Mockito.mock(Content.class)}); Mockito.when(requestBody.ref()).thenReturn("#components/string"); Method helloMethod = OpenapiDef.class.getDeclaredMethod("hello", String.class, Object.class); OperationContext operationContext = new OperationContext(helloMethod, oasContext); ParameterContext parameterContext = new ParameterContext(operationContext, null); operationMethodAnnotationProcessor.process(requestBody, parameterContext); Assert.assertTrue(parameterContext.isRequestBody()); } @Test public void processParameterAnnotation() throws NoSuchMethodException, IllegalAccessException, InstantiationException { OasContext oasContext = new OasContext(null); Method parameterMethod = ParameterClass.class.getMethod("parameter", String.class); OperationContext operationContext = new OperationContext(parameterMethod, oasContext); java.lang.reflect.Parameter[] parameters = parameterMethod.getParameters(); Assert.assertEquals(parameters.length, 1); java.lang.reflect.Parameter parameter = parameters[0]; Parameter parameterDeclaredAnnotation = parameter.getDeclaredAnnotation(Parameter.class); ParameterContext parameterContext = new ParameterContext(operationContext, parameter); ParameterAnnotationProcessor parameterAnnotationProcessor = new ParameterAnnotationProcessor(); parameterAnnotationProcessor.process(parameterDeclaredAnnotation, parameterContext); io.swagger.v3.oas.models.parameters.Parameter oasParameter = parameterContext.toParameter(); Assert.assertEquals("param", oasParameter.getName()); Assert.assertEquals(StringSchema.class, oasParameter.getSchema().getClass()); Assert.assertTrue(parameterContext.isRequired()); Assert.assertEquals(operationContext, parameterContext.getOperationContext()); Assert.assertNull(parameterContext.getDefaultValue()); } class ParameterClass { public void parameter(@Parameter(required = true) String param) { } } @OpenAPIDefinition( info = @Info( title = "openapi definition", description = "test openapi definition", termsOfService = "", contact = @Contact( name = "developer", url = "developer.com", email = "developer@developer.com", extensions = { @Extension( name = "ext1", properties = { @ExtensionProperty( name = "k1", value = "v1", parseValue = true ) }) } ), license = @License( name = "Apache License v2.0", url = "", extensions = { @Extension( name = "ext2", properties = { @ExtensionProperty( name = "k1", value = "v1", parseValue = true ) } ) } ), version = "0.2.0", extensions = { @Extension( name = "ext3", properties = { @ExtensionProperty( name = "k1", value = "v2" ) } ) } ), tags = { @Tag( name = "", description = "", externalDocs = @ExternalDocumentation( description = "", url = "", extensions = { @Extension( name = "ext4", properties = { @ExtensionProperty( name = "k1", value = "v2" ) } ) } ) ) }, servers = { @Server( url = "http://localhost", description = "", variables = { @ServerVariable( name = "", description = "", defaultValue = "", allowableValues = {}, extensions = { @Extension( name = "", properties = @ExtensionProperty( name = "", value = "", parseValue = true ) ) } ) } ) }, security = {}, externalDocs = @ExternalDocumentation( description = "", url = "", extensions = { @Extension( name = "", properties = @ExtensionProperty( name = "", value = "", parseValue = true ) ) } ), extensions = { @Extension( name = "", properties = @ExtensionProperty( name = "", value = "", parseValue = true ) ) } ) class OpenapiDef { @Operation( operationId = "hello-operation", method = "GET", tags = { "OpenapiDef" }, summary = "", requestBody = @RequestBody( ), externalDocs = @ExternalDocumentation(), parameters = { @Parameter( name = "name123", in = ParameterIn.QUERY, description = "user name", required = true, deprecated = false, allowEmptyValue = true, style = ParameterStyle.SIMPLE, explode = Explode.DEFAULT, allowReserved = true, // Ignored if the properties content or array are specified schema = @Schema( type = "string" ), hidden = false, example = "", examples = { @ExampleObject }, extensions = {}, ref = "" ) }, responses = { @ApiResponse( description = "success", responseCode = "200", headers = { @Header(name = "Content-Type", description = "content type", schema = @Schema( implementation = String.class ), required = true, deprecated = false ) }, links = { @Link() }, content = { @Content() }, extensions = { @Extension( name = "", properties = {} ) } ) }, deprecated = false, security = { @SecurityRequirement( name = "oauth2", scopes = { "app1" } ) }, servers = { @Server( url = "http://localhost:8080/hello" ) }, extensions = { @Extension( name = "", properties = {} ) }, hidden = false, ignoreJsonView = false ) public String hello(String name, Object notParameter) { return "hello"; } } } ================================================ FILE: oas-generator/oas-generator-core/src/test/java/org/apache/servicecomb/toolkit/generator/ContextTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.util.Collections; import org.apache.servicecomb.toolkit.generator.AnnotationProcessorTest.OpenapiDef; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.junit.Test; import io.swagger.v3.oas.annotations.enums.ParameterStyle; import io.swagger.v3.oas.models.PathItem.HttpMethod; import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.responses.ApiResponses; public class ContextTest { @Test public void realParameterContext() throws NoSuchMethodException { Method method = OpenapiDef.class.getDeclaredMethod("hello", String.class, Object.class); OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(method, oasContext); Parameter parameter = method.getParameters()[0]; ParameterContext context = new ParameterContext(operationContext, parameter); context.setRequired(true); context.setSchema(null); assertTrue(context.isRequired()); context.setDefaultValue("default"); context.setIn(InType.QUERY); context.setName("param1"); context.setDescription("desc"); context.setStyle(ParameterStyle.SIMPLE); context.addExtension("extension-key", "extension-value"); assertFalse(context.isRequestBody()); context.toParameter(); context.applyAnnotations(Collections.emptyList()); assertEquals("param1", context.getName()); assertEquals(InType.QUERY, context.getIn()); assertEquals(String.class, context.getRealType()); assertEquals(String.class, context.getType()); assertEquals(operationContext.getComponents(), context.getComponents()); assertEquals(operationContext, context.getOperationContext()); assertNull(context.getExtensions()); assertNotNull(context.getOasParameter()); assertNull(context.getParser()); assertEquals(parameter, context.getParameter()); assertNotNull(context.getSchema()); assertEquals("default", context.getDefaultValue()); assertEquals("desc", context.getDescription()); assertEquals(ParameterStyle.SIMPLE, context.getStyle()); assertFalse(context.isRequired()); assertNull(context.getDeprecated()); context.setIn(InType.COOKIE); assertFalse(context.isRequestBody()); context.toParameter(); context.setIn(InType.HEADER); assertFalse(context.isRequestBody()); context.toParameter(); context.setIn(InType.PATH); assertFalse(context.isRequestBody()); context.toParameter(); context.setIn(InType.FORM); assertTrue(context.isRequestBody()); context.toParameter(); context.setIn(InType.BODY); context.toParameter(); assertTrue(context.isRequestBody()); context.addConsume(MediaTypes.APPLICATION_JSON); assertEquals(MediaTypes.APPLICATION_JSON, context.getConsumers().get(0)); context.setRequestBody(new RequestBody()); assertNotNull(context.getRequestBody()); } @Test public void operationContext() throws NoSuchMethodException { Method method = OpenapiDef.class.getDeclaredMethod("hello", String.class, Object.class); OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(method, oasContext); Parameter parameter = method.getParameters()[0]; ParameterContext context = new ParameterContext(operationContext, parameter); context.setIn(InType.FORM); oasContext.toOpenAPI(); operationContext.setHttpMethod(HttpMethod.GET.name()); operationContext.setTags(null); operationContext.setApiResponses(new ApiResponses()); operationContext.setDescription("desc"); operationContext.setConsumers(new String[] {MediaTypes.APPLICATION_JSON}); operationContext.addExtension("x-extension", "value"); operationContext.toOperation(); oasContext.toOpenAPI(); oasContext.addExtension("x-extension", "value"); assertEquals("value", oasContext.getExtensions().get("x-extension")); assertEquals("value", operationContext.getExtensions().get("x-extension")); assertEquals(HttpMethod.GET.name(), operationContext.getHttpMethod()); assertNotNull(operationContext.getOperation()); assertNotNull(operationContext.getApiResponses()); assertEquals(oasContext, operationContext.getOpenApiContext()); assertNull(operationContext.getSummary()); assertNull(operationContext.getTags()); assertEquals(MediaTypes.APPLICATION_JSON, operationContext.getConsumers()[0]); assertEquals("desc", operationContext.getDescription()); } } ================================================ FILE: oas-generator/oas-generator-core/src/test/java/org/apache/servicecomb/toolkit/generator/OasGeneratorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.util.HashSet; import java.util.Set; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.context.OasGenerator; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.junit.Assert; import org.junit.Test; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.PathItem.HttpMethod; public class OasGeneratorTest { @Test public void generatorOas() { Set classSet = new HashSet<>(); classSet.add(NoResource.class); classSet.add(OneResource.class); OasGenerator generator = new OasGenerator(); generator.generate(classSet); } @Test public void constructOasContext() throws NoSuchMethodException { OasContext oasContext = new OasContext(null); Method method = OneResource.class.getMethod("name", String.class); OperationContext operationContext = new OperationContext(method, oasContext); operationContext.setHttpMethod(HttpMethod.GET.name()); operationContext.setOperationId(method.getName()); operationContext.setPath("/operation"); oasContext.addOperation(operationContext); oasContext.setCls(method.getDeclaringClass()); oasContext.setBasePath("/oas"); oasContext.setParser(null); Assert.assertEquals("/oas", oasContext.getBasePath()); Assert.assertEquals(method.getDeclaringClass(), oasContext.getCls()); Assert.assertNull(oasContext.getParser()); Assert.assertEquals("/operation", operationContext.getPath()); Assert.assertEquals(HttpMethod.GET.name(), operationContext.getHttpMethod()); Assert.assertEquals(oasContext.getComponents(), operationContext.getComponents()); Assert.assertEquals(null, operationContext.getApiResponses().getDefault()); Assert.assertEquals(oasContext.getOpenAPI(), operationContext.getOpenAPI()); Parameter parameter = method.getParameters()[0]; ParameterContext parameterContext = new ParameterContext(operationContext, parameter); parameterContext.setName(parameter.getName()); parameterContext.setRequired(true); parameterContext.setIn(InType.QUERY); Assert.assertEquals(parameter.getName(), parameterContext.getName()); OpenAPI openAPI = oasContext.toOpenAPI(); Assert.assertNotNull(openAPI); } class NoResource { } class OneResource { public String name(String name) { return name; } } } ================================================ FILE: oas-generator/oas-generator-core/src/test/java/org/apache/servicecomb/toolkit/generator/ParserTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.parser.AbstractAnnotationParser; import org.junit.Test; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.responses.ApiResponse; public class ParserTest { @Test public void parse() { AbstractAnnotationParser parser = new TestParser(); parser.parser(UnParser.class, new OasContext(parser)); } class TestParser extends AbstractAnnotationParser { @Override public int getOrder() { return 0; } @Override public boolean canProcess(Class cls) { return true; } } @OpenAPIDefinition class UnParser { @ApiResponse public String name(String name) { return name; } } } ================================================ FILE: oas-generator/oas-generator-core/src/test/java/org/apache/servicecomb/toolkit/generator/UtilsTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import static org.mockito.Mockito.when; import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.lang.reflect.Type; import java.util.List; import org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor; import org.apache.servicecomb.toolkit.generator.util.ModelConverter; import org.apache.servicecomb.toolkit.generator.util.ParamUtils; import org.apache.servicecomb.toolkit.generator.util.RequestResponse; import org.apache.servicecomb.toolkit.generator.util.SwaggerAnnotationUtils; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Encoding; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; public class UtilsTest { @Test public void getParameterName() throws NoSuchMethodException { Method method = ParameterClass.class.getMethod("method", String.class); Parameter parameter = method.getParameters()[0]; String parameterName = ParamUtils.getParameterName(method, parameter); Assert.assertEquals("param", parameterName); } @Test public void getSchema() { Schema schema = ModelConverter.getSchema(String.class); Assert.assertEquals(StringSchema.class, schema.getClass()); schema = ModelConverter.getSchema(ParameterClass.class); Assert.assertEquals(Schema.class, schema.getClass()); schema = ModelConverter.getSchema(String[].class); Assert.assertEquals(ArraySchema.class, schema.getClass()); Components components = new Components(); schema = ModelConverter.getSchema(ParameterClass[].class, components, null); Assert.assertEquals(ArraySchema.class, schema.getClass()); schema = ModelConverter.getSchema(ParameterClass.class, components, null); Assert.assertNotNull(schema.get$ref()); ModelInterceptor mockModelInterceptor = new ModelInterceptor() { @Override public int order() { return 0; } @Override public Schema process(Type cls, Components components) { return new Schema().name("unknown"); } }; ModelConverter.registerInterceptor(mockModelInterceptor); schema = ModelConverter.getSchema(ParameterClass.class); Assert.assertEquals("unknown", schema.getName()); ModelConverter.unRegisterInterceptor(mockModelInterceptor); Components component = new Components(); ModelConverter.getSchema(BeanClass.class, component, RequestResponse.REQUEST); Assert.assertNotNull(component.getSchemas().get("Value")); Schema beanClass = component.getSchemas().get("BeanClass"); Assert.assertNotNull(beanClass); Schema valueRef = (Schema) beanClass.getProperties().get("value"); Assert.assertEquals("#/components/schemas/Value", valueRef.get$ref()); Schema intVal = (Schema) beanClass.getProperties().get("intVal"); Assert.assertEquals("int32", intVal.getFormat()); Assert.assertEquals("integer", intVal.getType()); Schema intObj = (Schema) beanClass.getProperties().get("intObj"); Assert.assertEquals("int32", intObj.getFormat()); Assert.assertEquals("integer", intObj.getType()); Schema longVal = (Schema) beanClass.getProperties().get("longVal"); Assert.assertEquals("int64", longVal.getFormat()); Assert.assertEquals("integer", longVal.getType()); Schema longObj = (Schema) beanClass.getProperties().get("longObj"); Assert.assertEquals("int64", longObj.getFormat()); Assert.assertEquals("integer", longObj.getType()); Schema doubleVal = (Schema) beanClass.getProperties().get("doubleVal"); Assert.assertEquals("double", doubleVal.getFormat()); Assert.assertEquals("number", doubleVal.getType()); Schema doubleObj = (Schema) beanClass.getProperties().get("doubleObj"); Assert.assertEquals("double", doubleObj.getFormat()); Assert.assertEquals("number", doubleObj.getType()); Schema props = (Schema) beanClass.getProperties().get("props"); Assert.assertEquals(ArraySchema.class, props.getClass()); Assert.assertEquals("array", props.getType()); Assert.assertEquals("string", ((ArraySchema) props).getItems().getType()); Schema numbers = (Schema) beanClass.getProperties().get("numbers"); Assert.assertEquals(ArraySchema.class, numbers.getClass()); Assert.assertEquals("array", numbers.getType()); Assert.assertEquals("integer", ((ArraySchema) numbers).getItems().getType()); Assert.assertEquals("int32", ((ArraySchema) numbers).getItems().getFormat()); Schema values = (Schema) beanClass.getProperties().get("values"); Assert.assertEquals(ArraySchema.class, values.getClass()); Assert.assertEquals("array", values.getType()); Assert.assertEquals("#/components/schemas/Value", ((ArraySchema) values).getItems().get$ref()); } @Test public void getRequestOrResponseBean() { List requestBeanTypes = ModelConverter.getRequestBeanTypes(RequestBeanClass.class); List responseBeanTypes = ModelConverter.getResponseBeanTypes(ResponseBeanClass.class); Assert.assertNotNull(requestBeanTypes); Assert.assertNotNull(responseBeanTypes); Assert.assertEquals(1, requestBeanTypes.size()); Assert.assertEquals("Value", ((Class) requestBeanTypes.get(0)).getSimpleName()); Assert.assertEquals(1, responseBeanTypes.size()); Assert.assertEquals("Value", ((Class) responseBeanTypes.get(0)).getSimpleName()); } @Test public void getContentFromAnnotation() { Content contents = Mockito.mock(Content.class); when(contents.encoding()).thenReturn(new Encoding[] {Mockito.mock(Encoding.class)}); List contentFromAnnotation = SwaggerAnnotationUtils .getContentFromAnnotation(contents); Assert.assertEquals(1, contentFromAnnotation.size()); } class RequestBeanClass { public void setValue(Value value) { } public void setName(String name, String alias) { } public Integer getSomething() { return 0; } } class ResponseBeanClass { public Value getValue() { return new Value(); } public String getName(String name) { return name; } public void setSomething(Integer something) { } } class ParameterClass { public void method(String param) { } } class BeanClass { private String name; private int intVal; private long longVal; private double doubleVal; private Integer intObj; private Long longObj; private Double doubleObj; private Value value; List props; List numbers; List values; List list; public List getList() { return list; } public void setList(List list) { this.list = list; } public int getIntVal() { return intVal; } public void setIntVal(int intVal) { this.intVal = intVal; } public long getLongVal() { return longVal; } public void setLongVal(long longVal) { this.longVal = longVal; } public double getDoubleVal() { return doubleVal; } public void setDoubleVal(double doubleVal) { this.doubleVal = doubleVal; } public Integer getIntObj() { return intObj; } public void setIntObj(Integer intObj) { this.intObj = intObj; } public Long getLongObj() { return longObj; } public void setLongObj(Long longObj) { this.longObj = longObj; } public Double getDoubleObj() { return doubleObj; } public void setDoubleObj(Double doubleObj) { this.doubleObj = doubleObj; } public List getValues() { return values; } public void setValues(List values) { this.values = values; } public List getNumbers() { return numbers; } public void setNumbers(List numbers) { this.numbers = numbers; } public List getProps() { return props; } public void setProps(List props) { this.props = props; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Value getValue() { return value; } public void setValue(Value value) { this.value = value; } } class Value { private String prop1; private String prop2; public String getProp1() { return prop1; } public void setProp1(String prop1) { this.prop1 = prop1; } public String getProp2() { return prop2; } public void setProp2(String prop2) { this.prop2 = prop2; } } } ================================================ FILE: oas-generator/oas-generator-jaxrs/pom.xml ================================================ oas-generator org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 oas-generator-jaxrs org.apache.servicecomb.toolkit oas-generator-core javax.ws.rs javax.ws.rs-api junit junit test org.powermock powermock-module-junit4 test org.powermock powermock-api-mockito test ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/ConsumesAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import javax.ws.rs.Consumes; import org.apache.servicecomb.toolkit.generator.context.OperationContext; public class ConsumesAnnotationProcessor implements MethodAnnotationProcessor { @Override public void process(Consumes consumes, OperationContext operationContext) { operationContext.setConsumers(consumes.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/CookieParamAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import javax.ws.rs.CookieParam; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; public class CookieParamAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(CookieParam cookieParam, ParameterContext parameterContext) { parameterContext.setIn(InType.COOKIE); parameterContext.setName(cookieParam.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/FormParamAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import javax.ws.rs.FormParam; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; public class FormParamAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(FormParam formParam, ParameterContext parameterContext) { parameterContext.setIn(InType.FORM); parameterContext.setName(formParam.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/HeaderParamAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import javax.ws.rs.HeaderParam; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; public class HeaderParamAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(HeaderParam headerParam, ParameterContext parameterContext) { parameterContext.setIn(InType.HEADER); parameterContext.setName(headerParam.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/HttpMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import java.lang.annotation.Annotation; import javax.ws.rs.HttpMethod; import org.apache.servicecomb.toolkit.generator.context.OperationContext; public class HttpMethodAnnotationProcessor implements MethodAnnotationProcessor { @Override public void process(Annotation annotation, OperationContext operationContext) { HttpMethod httpMethod = annotation.annotationType().getAnnotation(HttpMethod.class); operationContext.setHttpMethod(httpMethod.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PathClassAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import javax.ws.rs.Path; import org.apache.servicecomb.toolkit.generator.context.OasContext; public class PathClassAnnotationProcessor implements ClassAnnotationProcessor { @Override public void process(Path path, OasContext context) { context.setBasePath(path.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PathMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import javax.ws.rs.Path; import org.apache.servicecomb.toolkit.generator.context.OperationContext; public class PathMethodAnnotationProcessor implements MethodAnnotationProcessor { @Override public void process(Path path, OperationContext context) { context.setPath(path.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PathParamAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import javax.ws.rs.PathParam; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; public class PathParamAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(PathParam pathParam, ParameterContext context) { context.setIn(InType.PATH); context.setName(pathParam.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/QueryParamAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import javax.ws.rs.QueryParam; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; public class QueryParamAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(QueryParam queryParam, ParameterContext parameterContext) { parameterContext.setIn(InType.QUERY); parameterContext.setName(queryParam.value()); } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/java/org/apache/servicecomb/toolkit/generator/parser/JaxRsAnnotationParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.parser; import javax.ws.rs.Consumes; import javax.ws.rs.CookieParam; import javax.ws.rs.DELETE; import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.HEAD; import javax.ws.rs.OPTIONS; import javax.ws.rs.PATCH; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.apache.servicecomb.toolkit.generator.annotation.ConsumesAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.CookieParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.FormParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.HeaderParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.HttpMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PathClassAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PathMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PathParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.QueryParamAnnotationProcessor; import io.swagger.v3.oas.annotations.headers.Header; public class JaxRsAnnotationParser extends AbstractAnnotationParser { @Override public void initClassAnnotationProcessor() { super.initClassAnnotationProcessor(); classAnnotationMap.put(Path.class, new PathClassAnnotationProcessor()); } @Override public void initMethodAnnotationProcessor() { super.initMethodAnnotationProcessor(); methodAnnotationMap.put(Path.class, new PathMethodAnnotationProcessor()); HttpMethodAnnotationProcessor httpMethodAnnotationProcessor = new HttpMethodAnnotationProcessor(); methodAnnotationMap.put(GET.class, httpMethodAnnotationProcessor); methodAnnotationMap.put(POST.class, httpMethodAnnotationProcessor); methodAnnotationMap.put(DELETE.class, httpMethodAnnotationProcessor); methodAnnotationMap.put(PATCH.class, httpMethodAnnotationProcessor); methodAnnotationMap.put(PUT.class, httpMethodAnnotationProcessor); methodAnnotationMap.put(OPTIONS.class, httpMethodAnnotationProcessor); methodAnnotationMap.put(HEAD.class, httpMethodAnnotationProcessor); methodAnnotationMap.put(Consumes.class, new ConsumesAnnotationProcessor()); } @Override public void initParameterAnnotationProcessor() { super.initParameterAnnotationProcessor(); parameterAnnotationMap.put(QueryParam.class, new QueryParamAnnotationProcessor()); parameterAnnotationMap.put(CookieParam.class, new CookieParamAnnotationProcessor()); parameterAnnotationMap.put(FormParam.class, new FormParamAnnotationProcessor()); parameterAnnotationMap.put(PathParam.class, new PathParamAnnotationProcessor()); parameterAnnotationMap.put(Header.class, new HeaderParamAnnotationProcessor()); } @Override public int getOrder() { return 100; } @Override public boolean canProcess(Class cls) { if (cls.getAnnotation(Path.class) != null) { return true; } return false; } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.apache.servicecomb.toolkit.generator.parser.JaxRsAnnotationParser ================================================ FILE: oas-generator/oas-generator-jaxrs/src/test/java/org/apache/servicecomb/toolkit/generator/JaxrsAnnotationProcessorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import javax.ws.rs.Consumes; import javax.ws.rs.CookieParam; import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; import javax.ws.rs.HttpMethod; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.apache.servicecomb.toolkit.generator.annotation.AnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.ConsumesAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.CookieParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.FormParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.HeaderParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.HttpMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PathClassAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PathMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PathParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.QueryParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; public class JaxrsAnnotationProcessorTest { @Test public void processApiResponseAnnotation() throws NoSuchMethodException { OasContext oasContext = new OasContext(null); OperationContext context = new OperationContext(null, oasContext); HttpMethodAnnotationProcessor httpMethodAnnotationProcessor = new HttpMethodAnnotationProcessor(); GET get = GetClass.class.getMethod("get").getAnnotation(GET.class); httpMethodAnnotationProcessor.process(get, context); Assert.assertEquals(HttpMethod.GET, context.getHttpMethod()); } @Test public void processPathClassAnnotation() { OasContext oasContext = new OasContext(null); PathClassAnnotationProcessor httpMethodAnnotationProcessor = new PathClassAnnotationProcessor(); Path path = Mockito.mock(Path.class); Mockito.when(path.value()).thenReturn("/path"); httpMethodAnnotationProcessor.process(path, oasContext); Assert.assertEquals("/path", oasContext.getBasePath()); } @Test public void processPathMethodAnnotation() { OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(null, oasContext); PathMethodAnnotationProcessor pathMethodAnnotationProcessor = new PathMethodAnnotationProcessor(); Path path = Mockito.mock(Path.class); Mockito.when(path.value()).thenReturn("/path"); pathMethodAnnotationProcessor.process(path, operationContext); Assert.assertEquals("/path", operationContext.getPath()); } @Test public void processConsumersAnnotation() { OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(null, oasContext); AnnotationProcessor annotationProcessor = new ConsumesAnnotationProcessor(); Consumes consumes = Mockito.mock(Consumes.class); Mockito.when(consumes.value()).thenReturn(new String[] {MediaTypes.APPLICATION_JSON}); annotationProcessor.process(consumes, operationContext); Assert.assertEquals(MediaTypes.APPLICATION_JSON, operationContext.getConsumers()[0]); } @Test public void processCookieParamAnnotation() { OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(null, oasContext); ParameterContext parameterContext = new ParameterContext(operationContext, null); AnnotationProcessor annotationProcessor = new CookieParamAnnotationProcessor(); CookieParam cookieParam = Mockito.mock(CookieParam.class); Mockito.when(cookieParam.value()).thenReturn("param"); annotationProcessor.process(cookieParam, parameterContext); Assert.assertEquals("param", parameterContext.getName()); } @Test public void processFormParamAnnotation() { OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(null, oasContext); ParameterContext parameterContext = new ParameterContext(operationContext, null); AnnotationProcessor annotationProcessor = new FormParamAnnotationProcessor(); FormParam formParam = Mockito.mock(FormParam.class); Mockito.when(formParam.value()).thenReturn("param"); annotationProcessor.process(formParam, parameterContext); Assert.assertEquals("param", parameterContext.getName()); Assert.assertTrue(parameterContext.isRequestBody()); } @Test public void processHeaderParamAnnotation() { OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(null, oasContext); ParameterContext parameterContext = new ParameterContext(operationContext, null); AnnotationProcessor annotationProcessor = new HeaderParamAnnotationProcessor(); HeaderParam headerParam = Mockito.mock(HeaderParam.class); Mockito.when(headerParam.value()).thenReturn("param"); annotationProcessor.process(headerParam, parameterContext); Assert.assertEquals("param", parameterContext.getName()); Assert.assertFalse(parameterContext.isRequestBody()); } @Test public void processPathParamAnnotation() { OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(null, oasContext); ParameterContext parameterContext = new ParameterContext(operationContext, null); AnnotationProcessor annotationProcessor = new PathParamAnnotationProcessor(); PathParam pathParam = Mockito.mock(PathParam.class); Mockito.when(pathParam.value()).thenReturn("param"); annotationProcessor.process(pathParam, parameterContext); Assert.assertEquals("param", parameterContext.getName()); Assert.assertFalse(parameterContext.isRequestBody()); } @Test public void processQueryParamAnnotation() { OasContext oasContext = new OasContext(null); OperationContext operationContext = new OperationContext(null, oasContext); ParameterContext parameterContext = new ParameterContext(operationContext, null); AnnotationProcessor annotationProcessor = new QueryParamAnnotationProcessor(); QueryParam queryParam = Mockito.mock(QueryParam.class); Mockito.when(queryParam.value()).thenReturn("param"); annotationProcessor.process(queryParam, parameterContext); Assert.assertEquals("param", parameterContext.getName()); Assert.assertFalse(parameterContext.isRequestBody()); } class GetClass { @GET public String get() { return "get"; } } } ================================================ FILE: oas-generator/oas-generator-jaxrs/src/test/java/org/apache/servicecomb/toolkit/generator/JaxrsParserTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import javax.ws.rs.Path; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.parser.JaxRsAnnotationParser; import org.junit.Assert; import org.junit.Test; import io.swagger.v3.oas.models.Components; public class JaxrsParserTest { @Test public void parseJaxrs() { JaxRsAnnotationParser parser = new JaxRsAnnotationParser(); boolean canProcess = parser.canProcess(NoResource.class); Assert.assertEquals(false, canProcess); canProcess = parser.canProcess(OneResource.class); Assert.assertEquals(true, canProcess); OasContext context = new OasContext(parser); parser.parser(OneResource.class, context); } class NoResource { public String name() { return "no resource"; } } @Path("/path") class OneResource { @Path("/name") public String name() { return "no resource"; } } } ================================================ FILE: oas-generator/oas-generator-servicecomb/pom.xml ================================================ oas-generator org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 oas-generator-servicecomb org.apache.servicecomb.toolkit oas-generator-jaxrs org.apache.servicecomb.toolkit oas-generator-spring org.apache.servicecomb provider-rest-common org.apache.servicecomb provider-pojo commons-lang commons-lang io.netty * io.zipkin.brave * io.vertx * org.apache.servicecomb foundation-vertx org.apache.servicecomb foundation-ssl org.apache.servicecomb foundation-config org.apache.servicecomb deployment junit junit test ================================================ FILE: oas-generator/oas-generator-servicecomb/src/main/java/org/apache/servicecomb/toolkit/generator/parser/ServicecombJaxrsParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.parser; import javax.ws.rs.Path; import org.apache.servicecomb.provider.rest.common.RestSchema; public class ServicecombJaxrsParser extends JaxRsAnnotationParser { @Override public boolean canProcess(Class cls) { if (cls.getAnnotation(RestSchema.class) != null && cls.getAnnotation(Path.class) != null) { return true; } return false; } } ================================================ FILE: oas-generator/oas-generator-servicecomb/src/main/java/org/apache/servicecomb/toolkit/generator/parser/ServicecombPojoParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.parser; import java.lang.reflect.Method; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.provider.pojo.RpcSchema; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import io.swagger.v3.oas.models.PathItem.HttpMethod; public class ServicecombPojoParser extends AbstractAnnotationParser { @Override public int getOrder() { return 100; } @Override public boolean canProcess(Class cls) { if (cls.getAnnotation(RpcSchema.class) != null) { return true; } return false; } @Override public void postParseMethodAnnotation(OperationContext context) { super.postParseMethodAnnotation(context); Method currentMethod = context.getMethod(); if (StringUtils.isEmpty(context.getHttpMethod())) { context.setHttpMethod(HttpMethod.POST.toString()); } if (StringUtils.isEmpty(context.getOperationId())) { context.setOperationId(currentMethod.getName()); } if (StringUtils.isEmpty(context.getPath())) { context.setPath(correctPath(currentMethod.getName())); } if (context.getApiResponses() == null || context.getApiResponses().size() == 0) { context.correctResponse(context.getApiResponses()); } } private String correctPath(String path) { if (path == null || path.startsWith("/")) { return path; } return "/" + path; } } ================================================ FILE: oas-generator/oas-generator-servicecomb/src/main/java/org/apache/servicecomb/toolkit/generator/parser/ServicecombSpringmvcParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.parser; import org.apache.servicecomb.provider.rest.common.RestSchema; import org.springframework.web.bind.annotation.RequestMapping; public class ServicecombSpringmvcParser extends SpringmvcAnnotationParser { @Override public boolean canProcess(Class cls) { if (cls.getAnnotation(RestSchema.class) != null && cls.getAnnotation(RequestMapping.class) != null) { return true; } return false; } } ================================================ FILE: oas-generator/oas-generator-servicecomb/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.apache.servicecomb.toolkit.generator.parser.ServicecombJaxrsParser org.apache.servicecomb.toolkit.generator.parser.ServicecombSpringmvcParser org.apache.servicecomb.toolkit.generator.parser.ServicecombPojoParser ================================================ FILE: oas-generator/oas-generator-servicecomb/src/test/java/org/apache/servicecomb/toolkit/generator/ServiceCombParserTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import javax.ws.rs.Path; import org.apache.servicecomb.provider.pojo.RpcSchema; import org.apache.servicecomb.provider.rest.common.RestSchema; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.parser.ServicecombJaxrsParser; import org.apache.servicecomb.toolkit.generator.parser.ServicecombPojoParser; import org.apache.servicecomb.toolkit.generator.parser.ServicecombSpringmvcParser; import org.junit.Assert; import org.junit.Test; import org.springframework.web.bind.annotation.RequestMapping; public class ServiceCombParserTest { @Test public void parse() { ServicecombJaxrsParser servicecombJaxrsParser = new ServicecombJaxrsParser(); ServicecombPojoParser servicecombPojoParser = new ServicecombPojoParser(); ServicecombSpringmvcParser servicecombSpringmvcParser = new ServicecombSpringmvcParser(); boolean canProcess = servicecombJaxrsParser.canProcess(ServicecombJaxrs.class); Assert.assertTrue(canProcess); canProcess = servicecombJaxrsParser.canProcess(ServicecombPojo.class); Assert.assertFalse(canProcess); canProcess = servicecombSpringmvcParser.canProcess(ServicecombSpringmvc.class); Assert.assertTrue(canProcess); canProcess = servicecombSpringmvcParser.canProcess(ServicecombPojo.class); Assert.assertFalse(canProcess); canProcess = servicecombPojoParser.canProcess(ServicecombPojo.class); Assert.assertTrue(canProcess); canProcess = servicecombPojoParser.canProcess(ServicecombSpringmvc.class); Assert.assertFalse(canProcess); Assert.assertEquals(100, servicecombPojoParser.getOrder()); OasContext pojoOasContext = new OasContext(servicecombPojoParser); servicecombPojoParser.parser(ServicecombPojo.class, pojoOasContext); Assert.assertNull(pojoOasContext.getBasePath()); } @RestSchema(schemaId = "servicecombJaxrs") @Path("/") class ServicecombJaxrs { @Path("/path") public Object path() { return null; } } @RestSchema(schemaId = "servicecombSpringmvc") @RequestMapping class ServicecombSpringmvc { } @RpcSchema class ServicecombPojo { public Object path() { return null; } } } ================================================ FILE: oas-generator/oas-generator-spring/pom.xml ================================================ oas-generator org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 oas-generator-spring org.apache.servicecomb.toolkit oas-generator-core org.springframework spring-web junit junit test ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/MultipartFileInterceptor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import java.lang.reflect.Type; import org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor; import org.apache.servicecomb.toolkit.generator.util.ModelConverter; import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.media.FileSchema; import io.swagger.v3.oas.models.media.Schema; public class MultipartFileInterceptor implements ModelInterceptor { @Override public int order() { return 100; } @Override public Schema process(Type cls, Components components) { if (!MultipartFile.class.equals(cls)) { return null; } return new FileSchema(); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/AbstractHttpMethodMappingAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.springframework.web.bind.annotation.RequestMethod; public abstract class AbstractHttpMethodMappingAnnotationProcessor implements MethodAnnotationProcessor { protected void processPath(String[] paths, OperationContext operationContext) { if (null == paths || paths.length == 0) { return; } if (paths.length > 1) { throw new Error(String.format("not allowed multi path for %s:%s", operationContext.getMethod().getDeclaringClass().getName(), operationContext.getMethod().getName())); } operationContext.setPath(paths[0]); } protected void processMethod(RequestMethod requestMethod, OperationContext operationContext) { operationContext.setHttpMethod(requestMethod.name()); } protected void processConsumes(String[] consumes, OperationContext operationContext) { if (null == consumes || consumes.length == 0) { return; } operationContext.setConsumers(consumes); } protected void processProduces(String[] produces, OperationContext operationContext) { if (null == produces || produces.length == 0) { return; } operationContext.setProduces(produces); } protected void processHeaders(String[] headers, OperationContext operationContext) { if (null == headers || headers.length == 0) { return; } operationContext.setHeaders(headers); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/DeleteMappingMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RequestMethod; public class DeleteMappingMethodAnnotationProcessor extends AbstractHttpMethodMappingAnnotationProcessor { @Override public void process(DeleteMapping deleteMapping, OperationContext operationContext) { processPath(deleteMapping.path(), operationContext); processPath(deleteMapping.value(), operationContext); processMethod(RequestMethod.DELETE, operationContext); processConsumes(deleteMapping.consumes(), operationContext); processProduces(deleteMapping.produces(), operationContext); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/GetMappingMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMethod; public class GetMappingMethodAnnotationProcessor extends AbstractHttpMethodMappingAnnotationProcessor { @Override public void process(GetMapping getMapping, OperationContext operationContext) { processPath(getMapping.path(), operationContext); this.processPath(getMapping.path(), operationContext); this.processPath(getMapping.value(), operationContext); this.processMethod(RequestMethod.GET, operationContext); this.processConsumes(getMapping.consumes(), operationContext); this.processProduces(getMapping.produces(), operationContext); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PathVariableAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.apache.servicecomb.toolkit.generator.util.ParamUtils; import org.springframework.web.bind.annotation.PathVariable; public class PathVariableAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(PathVariable pathVariable, ParameterContext parameterContext) { String paramName = pathVariable.name(); if (StringUtils.isEmpty(paramName)) { paramName = ParamUtils .getParameterName(parameterContext.getOperationContext().getMethod(), parameterContext.getParameter()); } parameterContext.setIn(InType.PATH); parameterContext.setName(paramName); parameterContext.setRequired(pathVariable.required()); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PostMappingMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMethod; public class PostMappingMethodAnnotationProcessor extends AbstractHttpMethodMappingAnnotationProcessor { @Override public void process(PostMapping postMapping, OperationContext operationContext) { this.processPath(postMapping.path(), operationContext); this.processPath(postMapping.value(), operationContext); this.processMethod(RequestMethod.POST, operationContext); this.processConsumes(postMapping.consumes(), operationContext); this.processProduces(postMapping.produces(), operationContext); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PutMappingMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMethod; public class PutMappingMethodAnnotationProcessor extends AbstractHttpMethodMappingAnnotationProcessor { @Override public void process(PutMapping putMapping, OperationContext operationContext) { this.processPath(putMapping.path(), operationContext); this.processPath(putMapping.value(), operationContext); this.processMethod(RequestMethod.PUT, operationContext); this.processConsumes(putMapping.consumes(), operationContext); this.processProduces(putMapping.produces(), operationContext); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestBodyAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.springframework.web.bind.annotation.RequestBody; public class RequestBodyAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(RequestBody requestBody, ParameterContext parameterContext) { parameterContext.setIn(InType.BODY); parameterContext.setRequired(requestBody.required()); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestHeaderAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.ValueConstants; public class RequestHeaderAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(RequestHeader requestHeader, ParameterContext parameterContext) { parameterContext.setIn(InType.HEADER); parameterContext.setRequired(requestHeader.required()); if (!ObjectUtils.isEmpty(requestHeader.defaultValue()) && !ValueConstants.DEFAULT_NONE .equals(requestHeader.defaultValue())) { parameterContext.setDefaultValue(requestHeader.defaultValue()); } String name = requestHeader.name(); if (StringUtils.isEmpty(name)) { name = requestHeader.value(); } parameterContext.setName(name); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestMappingClassAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; public class RequestMappingClassAnnotationProcessor implements ClassAnnotationProcessor { @Override public void process(RequestMapping requestMapping, OasContext oasContext) { String[] paths = requestMapping.value(); if (null == paths || paths.length == 0) { return; } // swagger only support one basePath if (paths.length > 1) { throw new Error("not support multi path for " + oasContext.getCls().getName()); } oasContext.setBasePath(paths[0]); processMethod(requestMapping.method(), oasContext); processConsumes(requestMapping.consumes(), oasContext); processProduces(requestMapping.produces(), oasContext); processHeaders(requestMapping.headers(), oasContext); } protected void processMethod(RequestMethod[] requestMethods, OasContext oasContext) { if (null == requestMethods || requestMethods.length == 0) { return; } if (requestMethods.length > 1) { throw new Error( "not allowed multi http method for " + oasContext.getCls().getName()); } oasContext.setHttpMethod(requestMethods[0].name()); } protected void processConsumes(String[] consumes, OasContext oasContext) { if (null == consumes || consumes.length == 0) { return; } oasContext.setConsumers(consumes); } protected void processProduces(String[] produces, OasContext oasContext) { if (null == produces || produces.length == 0) { return; } oasContext.setProduces(produces); } protected void processHeaders(String[] headers, OasContext oasContext) { if (null == headers || headers.length == 0) { return; } oasContext.setHeaders(headers); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestMappingMethodAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; public class RequestMappingMethodAnnotationProcessor extends AbstractHttpMethodMappingAnnotationProcessor { @Override public void process(RequestMapping requestMapping, OperationContext operationContext) { this.processPath(requestMapping.path(), operationContext); this.processPath(requestMapping.value(), operationContext); this.processMethod(requestMapping.method(), operationContext); this.processConsumes(requestMapping.consumes(), operationContext); this.processProduces(requestMapping.produces(), operationContext); this.processHeaders(requestMapping.headers(), operationContext); } protected void processMethod(RequestMethod[] requestMethods, OperationContext operationContext) { if (null == requestMethods || requestMethods.length == 0) { return; } if (requestMethods.length > 1) { throw new Error( "not allowed multi http method for " + operationContext.getMethod().getName()); } this.processMethod(requestMethods[0], operationContext); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestParamAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ValueConstants; public class RequestParamAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(RequestParam requestParam, ParameterContext parameterContext) { parameterContext.setIn(InType.QUERY); String name = requestParam.value(); if (StringUtils.isEmpty(name)) { name = requestParam.name(); } parameterContext.setName(name); parameterContext.setRequired(requestParam.required()); if (!ObjectUtils.isEmpty(requestParam.defaultValue()) && !ValueConstants.DEFAULT_NONE .equals(requestParam.defaultValue())) { parameterContext.setDefaultValue(requestParam.defaultValue()); parameterContext.setRequired(false); } } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestPartAnnotationProcessor.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.annotation; import org.apache.servicecomb.toolkit.generator.MediaTypes; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext.InType; import org.springframework.web.bind.annotation.RequestPart; public class RequestPartAnnotationProcessor implements ParamAnnotationProcessor { @Override public void process(RequestPart requestPart, ParameterContext parameterContext) { parameterContext.setIn(InType.BODY); parameterContext.addConsume(MediaTypes.MULTIPART_FORM_DATA); parameterContext.setRequired(requestPart.required()); parameterContext.setName(requestPart.name()); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/parser/SpringmvcAnnotationParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator.parser; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import org.apache.servicecomb.toolkit.generator.annotation.GetMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PathVariableAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PostMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PutMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestBodyAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestHeaderAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestMappingClassAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestPartAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; public class SpringmvcAnnotationParser extends AbstractAnnotationParser { @Override public int getOrder() { return 200; } @Override public void parser(Class cls, OasContext context) { super.parser(cls, context); } @Override public boolean canProcess(Class cls) { if (cls.getAnnotation(RestController.class) != null) { return true; } return false; } @Override public void initClassAnnotationProcessor() { super.initClassAnnotationProcessor(); classAnnotationMap.put(RequestMapping.class, new RequestMappingClassAnnotationProcessor()); } @Override public void initMethodAnnotationProcessor() { super.initMethodAnnotationProcessor(); methodAnnotationMap.put(RequestMapping.class, new RequestMappingMethodAnnotationProcessor()); methodAnnotationMap.put(GetMapping.class, new GetMappingMethodAnnotationProcessor()); methodAnnotationMap.put(PutMapping.class, new PutMappingMethodAnnotationProcessor()); methodAnnotationMap.put(PostMapping.class, new PostMappingMethodAnnotationProcessor()); } @Override public void initParameterAnnotationProcessor() { super.initParameterAnnotationProcessor(); parameterAnnotationMap.put(PathVariable.class, new PathVariableAnnotationProcessor()); parameterAnnotationMap.put(RequestBody.class, new RequestBodyAnnotationProcessor()); parameterAnnotationMap.put(RequestPart.class, new RequestPartAnnotationProcessor()); parameterAnnotationMap.put(RequestParam.class, new RequestParamAnnotationProcessor()); parameterAnnotationMap.put(RequestHeader.class, new RequestHeaderAnnotationProcessor()); } } ================================================ FILE: oas-generator/oas-generator-spring/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.apache.servicecomb.toolkit.generator.MultipartFileInterceptor ================================================ FILE: oas-generator/oas-generator-spring/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.apache.servicecomb.toolkit.generator.parser.SpringmvcAnnotationParser ================================================ FILE: oas-generator/oas-generator-spring/src/test/java/org/apache/servicecomb/toolkit/generator/SpringAnnotationProcessorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import java.lang.reflect.Method; import java.lang.reflect.Parameter; import org.apache.servicecomb.toolkit.generator.annotation.DeleteMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.GetMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PathVariableAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PostMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.PutMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestBodyAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestHeaderAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestMappingClassAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestMappingMethodAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestParamAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.annotation.RequestPartAnnotationProcessor; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.context.OperationContext; import org.apache.servicecomb.toolkit.generator.context.ParameterContext; import org.apache.servicecomb.toolkit.generator.parser.SpringmvcAnnotationParser; import org.junit.Assert; import org.junit.Test; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.models.media.FileSchema; public class SpringAnnotationProcessorTest { @Test public void methodOfRequestMapping() throws NoSuchMethodException { // class level SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; RequestMapping requestMappingClassAnnotation = httpMethodResourceClass.getAnnotation(RequestMapping.class); RequestMappingClassAnnotationProcessor requestMappingClassAnnotationProcessor = new RequestMappingClassAnnotationProcessor(); requestMappingClassAnnotationProcessor.process(requestMappingClassAnnotation, oasContext); Assert.assertEquals(RequestMethod.GET.name(), oasContext.getHttpMethod()); // method level RequestMappingMethodAnnotationProcessor requestMappingMethodAnnotationProcessor = new RequestMappingMethodAnnotationProcessor(); Method requestMethod = httpMethodResourceClass.getMethod("request"); RequestMapping requestMappingMethodAnnotation = requestMethod.getAnnotation(RequestMapping.class); OperationContext requestOperationContext = new OperationContext(requestMethod, oasContext); requestMappingMethodAnnotationProcessor.process(requestMappingMethodAnnotation, requestOperationContext); Assert.assertEquals(RequestMethod.POST.name(), requestOperationContext.getHttpMethod()); // default Method getRequestMethod = httpMethodResourceClass.getMethod("getRequest"); RequestMapping getRequestMappingMethodAnnotation = getRequestMethod.getAnnotation(RequestMapping.class); OperationContext getRequestOperationContext = new OperationContext(getRequestMethod, oasContext); requestMappingMethodAnnotationProcessor.process(getRequestMappingMethodAnnotation, getRequestOperationContext); Assert.assertEquals(RequestMethod.GET.name(), getRequestOperationContext.getHttpMethod()); } @Test public void pathOfRequestMapping() { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; RequestMapping requestMappingClassAnnotation = httpMethodResourceClass.getAnnotation(RequestMapping.class); RequestMappingClassAnnotationProcessor requestMappingClassAnnotationProcessor = new RequestMappingClassAnnotationProcessor(); requestMappingClassAnnotationProcessor.process(requestMappingClassAnnotation, oasContext); Assert.assertEquals(requestMappingClassAnnotation.value()[0], oasContext.getBasePath()); } @Test public void headersOfRequestMapping() throws NoSuchMethodException { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; RequestMappingMethodAnnotationProcessor requestMappingMethodAnnotationProcessor = new RequestMappingMethodAnnotationProcessor(); Method requestMethod = httpMethodResourceClass.getMethod("request"); RequestMapping requestMappingMethodAnnotation = requestMethod.getAnnotation(RequestMapping.class); OperationContext requestOperationContext = new OperationContext(requestMethod, oasContext); requestMappingMethodAnnotationProcessor.process(requestMappingMethodAnnotation, requestOperationContext); Assert.assertArrayEquals(requestMappingMethodAnnotation.headers(), requestOperationContext.getHeaders()); } @Test public void consumesOfRequestMapping() throws NoSuchMethodException { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; RequestMappingMethodAnnotationProcessor requestMappingMethodAnnotationProcessor = new RequestMappingMethodAnnotationProcessor(); Method requestMethod = httpMethodResourceClass.getMethod("request"); RequestMapping requestMappingMethodAnnotation = requestMethod.getAnnotation(RequestMapping.class); OperationContext requestOperationContext = new OperationContext(requestMethod, oasContext); requestMappingMethodAnnotationProcessor.process(requestMappingMethodAnnotation, requestOperationContext); Assert.assertArrayEquals(requestMappingMethodAnnotation.consumes(), requestOperationContext.getConsumers()); } @Test public void producesOfRequestMapping() throws NoSuchMethodException { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; RequestMappingMethodAnnotationProcessor requestMappingMethodAnnotationProcessor = new RequestMappingMethodAnnotationProcessor(); Method requestMethod = httpMethodResourceClass.getMethod("request"); RequestMapping requestMappingMethodAnnotation = requestMethod.getAnnotation(RequestMapping.class); OperationContext requestOperationContext = new OperationContext(requestMethod, oasContext); requestMappingMethodAnnotationProcessor.process(requestMappingMethodAnnotation, requestOperationContext); Assert.assertArrayEquals(requestMappingMethodAnnotation.produces(), requestOperationContext.getProduces()); } @Test public void methodOfGetMapping() throws NoSuchMethodException { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; GetMappingMethodAnnotationProcessor getMappingMethodAnnotationProcessor = new GetMappingMethodAnnotationProcessor(); Method getMethod = httpMethodResourceClass.getMethod("get"); GetMapping getMappingAnnotation = getMethod.getAnnotation(GetMapping.class); OperationContext getOperationContext = new OperationContext(getMethod, oasContext); getMappingMethodAnnotationProcessor.process(getMappingAnnotation, getOperationContext); Assert .assertEquals(getMappingAnnotation.value()[0], getOperationContext.getPath()); } @Test public void methodOfPostMapping() throws NoSuchMethodException { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; PostMappingMethodAnnotationProcessor postMappingMethodAnnotationProcessor = new PostMappingMethodAnnotationProcessor(); Method postMethod = httpMethodResourceClass.getMethod("post"); PostMapping postMappingAnnotation = postMethod.getAnnotation(PostMapping.class); OperationContext postOperationContext = new OperationContext(postMethod, oasContext); postMappingMethodAnnotationProcessor.process(postMappingAnnotation, postOperationContext); Assert .assertEquals(postMappingAnnotation.value()[0], postOperationContext.getPath()); } @Test public void methodOfPutMapping() throws NoSuchMethodException { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; PutMappingMethodAnnotationProcessor putMappingMethodAnnotationProcessor = new PutMappingMethodAnnotationProcessor(); Method putMethod = httpMethodResourceClass.getMethod("put"); PutMapping putMappingAnnotation = putMethod.getAnnotation(PutMapping.class); OperationContext putOperationContext = new OperationContext(putMethod, oasContext); putMappingMethodAnnotationProcessor.process(putMappingAnnotation, putOperationContext); Assert .assertEquals(putMappingAnnotation.value()[0], putOperationContext.getPath()); } @Test public void methodOfDeleteMapping() throws NoSuchMethodException { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); OasContext oasContext = new OasContext(parser); Class httpMethodResourceClass = HttpMethodResource.class; DeleteMappingMethodAnnotationProcessor deleteMappingMethodAnnotationProcessor = new DeleteMappingMethodAnnotationProcessor(); Method deleteMethod = httpMethodResourceClass.getMethod("delete"); DeleteMapping delelteMappingAnnotation = deleteMethod.getAnnotation(DeleteMapping.class); OperationContext deleteOperationContext = new OperationContext(deleteMethod, oasContext); deleteMappingMethodAnnotationProcessor.process(delelteMappingAnnotation, deleteOperationContext); Assert .assertEquals(delelteMappingAnnotation.value()[0], deleteOperationContext.getPath()); } @Test public void parseParameter() throws NoSuchMethodException { Class paramAnnotationResourceClass = ParamAnnotationResource.class; OasContext oasContext = new OasContext(null); OperationContext operationContext; ParameterContext parameterContext; RequestParamAnnotationProcessor requestParamAnnotationProcessor = new RequestParamAnnotationProcessor(); Method requestParamMethod = paramAnnotationResourceClass.getMethod("requestParam", String.class); Parameter requestParamMethodParam = requestParamMethod.getParameters()[0]; RequestParam requestParamAnnotation = requestParamMethodParam .getAnnotation(RequestParam.class); operationContext = new OperationContext(requestParamMethod, oasContext); parameterContext = new ParameterContext(operationContext, requestParamMethodParam); requestParamAnnotationProcessor.process(requestParamAnnotation, parameterContext); io.swagger.v3.oas.models.parameters.Parameter oasParameter = parameterContext.toParameter(); Assert.assertNull(parameterContext.getDefaultValue()); Assert.assertNull(oasParameter.getSchema().getDefault()); PathVariableAnnotationProcessor pathVariableAnnotationProcessor = new PathVariableAnnotationProcessor(); Method pathVariableMethod = paramAnnotationResourceClass.getMethod("pathVariable", String.class); Parameter pathVariableMethodParam = pathVariableMethod.getParameters()[0]; PathVariable pathVariableAnnotation = pathVariableMethodParam .getAnnotation(PathVariable.class); operationContext = new OperationContext(pathVariableMethod, oasContext); parameterContext = new ParameterContext(operationContext, pathVariableMethodParam); pathVariableAnnotationProcessor.process(pathVariableAnnotation, parameterContext); parameterContext.toParameter(); Assert.assertTrue(parameterContext.isRequired()); RequestPartAnnotationProcessor requestPartAnnotationProcessor = new RequestPartAnnotationProcessor(); Method requestPartMethod = paramAnnotationResourceClass.getMethod("requestPart", MultipartFile.class); Parameter requestPartMethodParam = requestPartMethod.getParameters()[0]; RequestPart requestPartParamAnnotation = requestPartMethodParam .getAnnotation(RequestPart.class); operationContext = new OperationContext(requestPartMethod, oasContext); parameterContext = new ParameterContext(operationContext, requestPartMethodParam); requestPartAnnotationProcessor.process(requestPartParamAnnotation, parameterContext); oasParameter = parameterContext.toParameter(); Assert.assertNull(parameterContext.getDefaultValue()); Assert.assertEquals(FileSchema.class, oasParameter.getSchema().getClass()); RequestHeaderAnnotationProcessor requestHeaderAnnotationProcessor = new RequestHeaderAnnotationProcessor(); Method requestHeaderMethod = paramAnnotationResourceClass.getMethod("requestHeader", String.class); Parameter requestHeaderMethodParam = requestHeaderMethod.getParameters()[0]; RequestHeader requestHeaderParamAnnotation = requestHeaderMethodParam .getAnnotation(RequestHeader.class); operationContext = new OperationContext(requestPartMethod, oasContext); parameterContext = new ParameterContext(operationContext, requestHeaderMethodParam); requestHeaderAnnotationProcessor.process(requestHeaderParamAnnotation, parameterContext); oasParameter = parameterContext.toParameter(); Assert.assertNull(parameterContext.getDefaultValue()); Assert.assertNull(oasParameter.getSchema().getDefault()); RequestBodyAnnotationProcessor requestBodyAnnotationProcessor = new RequestBodyAnnotationProcessor(); Method requestBodyMethod = paramAnnotationResourceClass.getMethod("requestBody", String.class); Parameter requestBodyMethodParam = requestBodyMethod.getParameters()[0]; RequestBody requestBodyParamAnnotation = requestBodyMethodParam .getAnnotation(RequestBody.class); operationContext = new OperationContext(requestBodyMethod, oasContext); parameterContext = new ParameterContext(operationContext, requestBodyMethodParam); requestBodyAnnotationProcessor.process(requestBodyParamAnnotation, parameterContext); parameterContext.toParameter(); Assert.assertTrue(parameterContext.isRequired()); } @Test public void interceptorModel() { MultipartFileInterceptor interceptor = new MultipartFileInterceptor(); Assert.assertEquals(100, interceptor.order()); } @RestController @RequestMapping(value = "/path", method = RequestMethod.GET) class HttpMethodResource { @RequestMapping(value = "/request", method = RequestMethod.POST, headers = "cookie=1", consumes = "application/json", produces = "application/json") public String request() { return "request"; } @RequestMapping(value = "/getRequest") public String getRequest() { return "getRequest"; } @GetMapping(value = "/get", consumes = {"application/json"}, produces = {"application/json"}) public String get() { return "get"; } @PostMapping("/post") public String post() { return "post"; } @PutMapping("/put") public String put() { return "put"; } @DeleteMapping("/delete") public String delete() { return "delete"; } } class ParamAnnotationResource { public void requestParam(@RequestParam("param") String param) { } public void requestBody(@RequestBody String param) { } public void requestHeader(@RequestHeader String headerParam) { } public void requestPart(@RequestPart MultipartFile file) { } public void pathVariable(@PathVariable String path) { } } } ================================================ FILE: oas-generator/oas-generator-spring/src/test/java/org/apache/servicecomb/toolkit/generator/SpringParserTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.generator; import org.apache.servicecomb.toolkit.generator.context.OasContext; import org.apache.servicecomb.toolkit.generator.parser.SpringmvcAnnotationParser; import org.junit.Assert; import org.junit.Test; import org.springframework.web.bind.annotation.RestController; public class SpringParserTest { @Test public void parse() { SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser(); Assert.assertEquals(200, parser.getOrder()); boolean canProcess = parser.canProcess(String.class); Assert.assertFalse(canProcess); canProcess = parser.canProcess(SpringmvcController.class); Assert.assertTrue(canProcess); OasContext oasContext = new OasContext(parser); parser.parser(SpringmvcController.class, oasContext); } @RestController class SpringmvcController { } } ================================================ FILE: oas-generator/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 pom oas-generator-core oas-generator-jaxrs oas-generator-spring oas-generator-servicecomb oas-generator ================================================ FILE: oas-validator/.gitignore ================================================ HELP.md /target/ !.mvn/wrapper/maven-wrapper.jar ### STS ### .apt_generated .classpath .factorypath .project .settings .springBeans .sts4-cache ### IntelliJ IDEA ### .idea *.iws *.iml *.ipr ### NetBeans ### /nbproject/private/ /nbbuild/ /dist/ /nbdist/ /.nb-gradle/ /build/ ### VS Code ### .vscode/ */target *.class ================================================ FILE: oas-validator/README-ZH.md ================================================ # OAS Validator | [English](./README.md) OpenAPI V3 Spec校验工具。 ## 项目结构 * oas-validator-core,核心API及骨架实现 * oas-validator-core-spring,骨架的Spring Boot Starter * oas-validator-test,核心API的测试帮助类 * oas-validator-style,风格校验实现 * oas-validator-compatibility,兼容性校验实现 * oas-validator-compatibility-spring,兼容性校验实现的Spring Boot Starter * oas-validator-web,校验工具的操作UI ## 风格校验 OAS必须符合[OAS 3.0.2规范][openapi-3.0.2](比如属性的名称、REQUIED要求)。除此之外则是我们自己的定义的风格检查。 ### 一些字符串匹配规则 * lower-camel-case:首字母小写的驼峰,对应的正则`^[a-z]+((\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?$` * upper-camel-case:首字母大写的驼峰,对应的正则`^[A-Z]([a-z0-9]+[A-Z]?)*$` * upper-hyphen-case:单词首字母大写,多个单词用`-`连接,比如`Content-Type`、`Accept`、`X-Rate-Limit-Limit`。对应的正则:`^([A-Z][a-z0-9]*-)*([A-Z][a-z0-9]*)$` ### 配置校验规则 下面是配置文件的例子`style-check-rule.properties`: ```properties ####################### # OpenAPI Object ####################### # openapi property must be 3.0.x and >= 3.0.2 openAPI.openapi.gte=3.0.2 # tags property size should >= 1 openAPI.tags.size.gte=1 # security property size must == 0 openAPI.security.size.eq=0 ####################### # Info Object ####################### # description property is required info.description.required=true ####################### # Tag Object ####################### # name property, must be upper-camel-case tag.name.case=upper-camel-case # tag should be referenced by at least one Operation Object tag.name.must_be_referenced=true # description property, required tag.description.required=true ####################### # Paths Object ####################### # path must be lower-camel-case, including Path Templating variable paths.key.case=lower-camel-case ####################### # Operation Object ####################### # summary property, required operation.summary.required=true # operationId property, must be lower-camel-case operation.operationId.case=lower-camel-case # tags property, size must == 1 operation.tags.size.eq=1 # all tags should references which are defined in $.tags operation.tags.element.must_reference_root_tags=true # servers property, size must == 0 operations.servers.size.eq=0 ####################### # Parameter Object ####################### # description property, required parameter.description.required=true # name property, for header parameter, must be upper-hyphen-case parameter.name.header.case=upper-hyphen-case # name property, for cookie parameter, must be lower-camel-case parameter.name.cookie.case=lower-camel-case # name property, for path parameter, must be lower-camel-case parameter.name.path.case=lower-camel-case # name property, for query parameter, must be lower-camel-case parameter.name.query.case=lower-camel-case ####################### # RequestBody Object ####################### # description property, required requestBody.description.required=true ####################### # Response Object ####################### # headers property's key must be upper-hyphen-case response.headers.key.case=upper-hyphen-case ####################### # Schema Object ####################### # title property, required if parent is Schema Object or Components Object schema.title.required=true # properties property, name(properties key) must be lower-camel-case schema.properties.key.case=lower-camel-case ####################### # Encoding Object ####################### # headers property's key must be upper-hyphen-case encoding.headers.key.case=upper-hyphen-case ####################### # Header Object ####################### # description property, required header.description.required=true ####################### # Components Object ####################### # schemas property's key must be upper-camel-case components.schemas.key.case=upper-camel-case # responses property's key must be upper-camel-case components.responses.key.case=upper-camel-case # parameters property's key must be upper-camel-case components.parameters.key.case=upper-camel-case # examples property's key must be upper-camel-case components.examples.key.case=upper-camel-case # requestBodies property's key must be upper-camel-case components.requestBodies.key.case=upper-camel-case # headers property's key must be upper-hyphen-case components.headers.key.case=upper-hyphen-case # links property's key must be upper-camel-case components.links.key.case=upper-hyphen-case # callbacks property's key must be upper-camel-case components.callbacks.key.case=upper-camel-case # headers property's key must be upper-camel-case components.headers.key.case=upper-camel-case ``` ## 兼容性检查 对新旧两个版本的OAS做兼容性检查。 OAS可以使用[Reference Object][spec-reference]来描述Spec,两个不同的OAS会出现描述不同但语义相同的情况。比如下面的旧OAS没有使用[Reference Object][spec-reference],而新OAS则使用了的情况: 旧OAS ```yaml openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listPets requestBody: content: application/json: schema: type: array items: type: object properties: Foo: type: string responses: '200': description: A paged array of pets ``` 新OAS ```yaml paths: /pets: post: operationId: listPets requestBody: content: application/json: schema: $ref: '#/components/schemas/Foo' responses: '200': description: A paged array of pets components: schemas: Foo: type: array items: type: object properties: Foo: type: string ``` 因此在检查兼容性的时候会将新旧OAS的[Reference Object][spec-reference]做解析,然后再检查,下面是一段[swagger-parser][swagger-parser]的例子: ```java OpenAPIV3Parser parser = new OpenAPIV3Parser(); ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(true); parseOptions.setResolveCombinators(true); parseOptions.setResolveFully(true); parseOptions.setFlatten(false); SwaggerParseResult parseResult = parser.readContents(content, null, parseOptions); ``` 因此,检查下来如果发现不兼容,那么所报告的位置会和原文档有所不同。 ### Paths Object [doc][spec-paths] * 新OAS必须包含旧OAS的所有的`path`,如果`path`使用了[Path Templating][spec-path-templating],只要变量名发生了变化,那么即使语义上相同也会被认为不同,比如`/pets/{foo}`和`/pets/{bar}`会被认定为不同。 * 见[Path Item Object兼容性检查](#path-item-compatibility) ### Path Item Object [doc][spec-path-item] * 新OAS必须包含旧OAS的所有的get/put/post/delete/...[Operation Object][spec-operation] ### Operation Object [doc][spec-operation] * `operationId`属性,新旧OAS必须完全一致。 * `parameters`属性,对它检查须在考虑到[Path Item Object parameters属性][spec-path-item-parameters]的情况下进行: * 新OAS可以新增[Parameter Object][spec-parameter],但是新增的[Parameter Object][spec-parameter]的`required`属性必须为`false` * 新OAS可以删除[Parameter Object][spec-parameter] * 针对单个[Parameter Object][spec-parameter]的修改的检查见[Parameter Object兼容性检查](#parameter-compatibility)(在同一个[Operation Object][spec-operation]下[Parameter Object][spec-parameter]依靠`name`和`in`两个属性作为ID)。 * `requestBody`属性,见[Request Body Object兼容性检查](#request-body-compatibility) * `responses`属性,见[Responses Object兼容性检查](#responses-compatibility) ### Parameter Object [doc][spec-parameter] * `required`属性,只允许`true(旧) -> false(新)` * `allowEmptyValue`属性,只允许`false(旧) -> true(新)`的变化 * `style`属性,新旧OAS必须保持一致 * `explode`属性,新旧OAS必须保持一致 * `allowReserved`属性,只允许`false(旧) -> true(新)`的变化 * `schema`属性,见[Schema Object兼容性检查](#schema-compatibility) * `content`属性,新OAS必须包含旧OAS的所有media type(`content`的key),且不能新增media type * 见[Media Type Object兼容性检查](#media-type-compatibility) ### Request Body Object [doc][spec-request-body] * `content`属性,新OAS必须包含旧OAS的所有media type(`content`的key) * 见[Media Type Object兼容性检查](#media-type-compatibility) * `required`属性,只允许`true(旧) -> false(新)`的变化 ### Media Type Object [doc][spec-media-type] * `schema`属性,见[Schema Object兼容性检查](#schema-compatibility) * `encoding`属性,该属性仅适用于`requestBody`,因此新旧OAS的property name(`encoding`的key)必须完全一致 * 见[Encoding Object兼容性检查](#encoding-compatibility) ### Responses Object [doc][spec-responses] * `default`属性,如果旧OAS没有定义`default`,那么新OAS也不能定义`default`。 * `{Http Status Code}`属性,新OAS不允许新增。 * 见[Response Object兼容性检查](#response-compatibility) ### Response Object [doc][spec-response] * `headers`属性,新OAS必须包含旧OAS的所有header name(`headers`的key),可以新增header name * [Header Object][spec-header]见[Header Object兼容性检查](#header-compatibility) * `content`属性,新OAS必须包含旧OAS的所有media type(`content`的key),可以新增media type - [Media Type Object][spec-media-type]见[Media Type Object兼容性检查](#media-type-compatibility) ### Schema Object [doc][spec-schema] OAS中定义,Schema Object可以直接或间接用在: * 请求类:[Parameter Object][spec-parameter]、[Request Body Object][spec-request-body]、[Header Object][spec-header] * 响应类:[Header Object][spec-header]、[Response Object][spec-response] 不同用途的兼容性检查规则有所不同。 ### 用做请求时 原则上,当Schema Object用在请求时,只允许从紧到松的变化。 * `type, format`组合所允许的变化范围 | 旧(type,format) | 新(type,format) | | ---------------- | ------------------------------------------------------------ | | integer, null | integer, int64
number, double
number, null | | integer, int32 | integer, int64
integer, null
number, float
number, double
number, null | | integer, int64 | integer, null
number, double
number, null | | number, null | number, double | | number, float | number, null
number, double | | number, double | number, null | | string, null | string, password | | string, password | string, null | * `allOf`、`oneOf`、`anyOf`属性,在combine之后再做检查 * `multipleOf`属性,如果旧OAS为null。新OAS必须==旧OAS或者新OAS是旧OAS的因子,比如6(旧)->3(新) * `maximum`、`maxLength`、`maxItems`、`maxProperties`,如果旧OAS为null,那么新OAS也必须是null。其他情况,新OAS必须>=旧OAS。 * `minimum`、`minLenght`、`minItems`、`minProperties`,如果旧OAS为null,那么新OAS也必须是null。其他情况,新OAS必须<=旧OAS。 * `exclusiveMaximum`、`exclusiveMinimum`属性,仅允许`true(旧)->false(新)`的变化 * `uniqueItems`属性,只允许`true(旧)->false(新)`的变化。 * `required`属性,新OAS必须==旧OAS,或者新OAS是旧OAS的子集。 * `enum`属性,新OAS必须==旧OAS,或者新OAS是旧OAS的超集。 * `properties`属性,新OAS可以新增property name(`properties`的key)或者减少property name。 * `nullable`属性,只允许`false(旧)->true(新)`的变化。 * `discriminator`属性,新旧OAS必须完全一致。 * `xml`属性,新旧OAS必须完全一致。 * `readOnly`、`writeOnly`,新旧OAS必须完全一致。 ### 用做响应时 原则上,当Schema Object用在响应时,只允许从松到紧的变化。 * `type, format`组合所允许的变化范围 | 旧(type,format) | 新(type,format) | | ---------------- | ---------------------------------- | | integer, null | integer, int64
integer, int32 | | integer, int64 | integer, null
interger, int32 | | number, null | number, double
number, float | | number, double | number, null
number, float | | string, null | string, password | | string, password | string, null | * `allOf`、`oneOf`、`anyOf`属性,在combine之后再做检查 * `multipleOf`属性,如果旧OAS为null。新OAS必须==旧OAS或者新OAS是旧OAS的倍数,比如3(旧)->6(新) * `maximum`、`maxLength`、`maxItems`、`maxProperties`,如果旧OAS为null,那么新OAS也必须是null。其他情况,新OAS必须<=旧OAS。 * `minimum`、`minLenght`、`minItems`、`minProperties`,如果旧OAS为null,那么新OAS也必须是null。其他情况,新OAS必须>=旧OAS。 * `exclusiveMaximum`、`exclusiveMinimum`属性,仅允许`false(旧)->true(新)`的变化 * `uniqueItems`属性,只允许`false(旧)->true(新)`的变化。 * `required`属性,新OAS必须==旧OAS或者,新OAS是旧OAS的超集。 * `enum`属性,新OAS必须==旧OAS,或者新OAS是旧OAS的子集。 * `properties`属性,新OAS可以新增property name(`properties`的key)或者减少property name。 * `nullable`属性,只允许`true(旧)->false(新)`的变化。 * `discriminator`属性,新旧OAS必须完全一致。 * `xml`属性,新旧OAS必须完全一致。 * `readOnly`、`writeOnly`,新旧OAS必须完全一致。 ### Encoding Object [doc][spec-encoding] PS. Encoding Object仅针对Request Body Object有用 * `contentType`属性,新旧OAS必须保持一致 * `headers`属性,新OAS不能新增旧OAS的header name(`headers`的key),但是可以删除header name * [Header Object][spec-header]见[Header Object兼容性检查](#header-compatibility) * `style`属性,新旧OAS必须保持一致 * `explode`属性,新旧OAS必须保持一致 * `allowReserved`属性,只允许`false(旧) -> true(新)`的变化 ### Header Object [doc][spec-header] - `schema`属性,见[Schema Object兼容性检查](#schema-compatibility) ### Components Object [doc][spec-components] [Components Object][spec-components]定义的都是可复用OAS Object,而在检查兼容性的时候所有`$ref`都已被解析了,因此不需要对[Components Object][spec-components]的属性做兼容性检查。 [spec-operation]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#operationObject [openapi-3.0.2]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md [spec-openapi]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#openapi-object [spec-server]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#serverObject [spec-info]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#infoObject [spec-paths]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#paths-object [spec-path-item]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#pathItemObject [spec-parameter]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject [spec-request-body]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#requestBodyObject [spec-security-scheme]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#securitySchemeObject [spec-components]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#components-object [spec-tag]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#tagObject [spec-schema]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject [spec-media-type]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#media-type-object [spec-response]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#response-object [spec-path-templating]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#path-templating [spec-parameterIn]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterIn [spec-encoding]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#encodingObject [spec-header]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#header-object [spec-info]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#infoObject [spec-reference]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#reference-object [swagger-parser]: https://github.com/swagger-api/swagger-parser [spec-path-item-parameters]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-pathitemparameters [spec-responses]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responsesObject ================================================ FILE: oas-validator/README.md ================================================ # OAS Validator | [中文](./README-ZH.md) OpenAPI V3 Spec validation tools. ## Project structure * oas-validator-core: core apis and skeletons implementations * oas-validator-core-spring: Spring Boot Starter for core skeletons * oas-validator-test: test helpers for core api * oas-validator-style: check style validators * oas-validator-compatibility: compatibility validators * oas-validator-compatibility-spring: Spring Boot Starter for compatibility validators * oas-validator-web: web ui ## Style checking OAS must compatible with [OAS 3.0.2][openapi-3.0.2], besides must obey the following rules. ### String patterns * lower-camel-case: initial letter lowercase camel case, regex is `^[a-z]+((\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?$` * upper-camel-case: initial letter uppercase camel case, regex is `^[A-Z]([a-z0-9]+[A-Z]?)*$` * upper-hyphen-case: initial letter uppercase, multiple words concat with `-`, such as `Content-Type`, `Accept`, `X-Rate-Limit-Limit`, regex is `^([A-Z][a-z0-9]*-)*([A-Z][a-z0-9]*)$` ### Rules properties file Below is a `style-check-rule.properties` example: ```properties ####################### # OpenAPI Object ####################### # openapi property must be 3.0.x and >= 3.0.2 openAPI.openapi.gte=3.0.2 # tags property size should >= 1 openAPI.tags.size.gte=1 # security property size must == 0 openAPI.security.size.eq=0 ####################### # Info Object ####################### # description property is required info.description.required=true ####################### # Tag Object ####################### # name property, must be upper-camel-case tag.name.case=upper-camel-case # tag should be referenced by at least one Operation Object tag.name.must_be_referenced=true # description property, required tag.description.required=true ####################### # Paths Object ####################### # path must be lower-camel-case, including Path Templating variable paths.key.case=lower-camel-case ####################### # Operation Object ####################### # summary property, required operation.summary.required=true # operationId property, must be lower-camel-case operation.operationId.case=lower-camel-case # tags property, size must == 1 operation.tags.size.eq=1 # all tags should references which are defined in $.tags operation.tags.element.must_reference_root_tags=true # servers property, size must == 0 operations.servers.size.eq=0 ####################### # Parameter Object ####################### # description property, required parameter.description.required=true # name property, for header parameter, must be upper-hyphen-case parameter.name.header.case=upper-hyphen-case # name property, for cookie parameter, must be lower-camel-case parameter.name.cookie.case=lower-camel-case # name property, for path parameter, must be lower-camel-case parameter.name.path.case=lower-camel-case # name property, for query parameter, must be lower-camel-case parameter.name.query.case=lower-camel-case ####################### # RequestBody Object ####################### # description property, required requestBody.description.required=true ####################### # Response Object ####################### # headers property's key must be upper-hyphen-case response.headers.key.case=upper-hyphen-case ####################### # Schema Object ####################### # title property, required if parent is Schema Object or Components Object schema.title.required=true # properties property, name(properties key) must be lower-camel-case schema.properties.key.case=lower-camel-case ####################### # Encoding Object ####################### # headers property's key must be upper-hyphen-case encoding.headers.key.case=upper-hyphen-case ####################### # Header Object ####################### # description property, required header.description.required=true ####################### # Components Object ####################### # schemas property's key must be upper-camel-case components.schemas.key.case=upper-camel-case # responses property's key must be upper-camel-case components.responses.key.case=upper-camel-case # parameters property's key must be upper-camel-case components.parameters.key.case=upper-camel-case # examples property's key must be upper-camel-case components.examples.key.case=upper-camel-case # requestBodies property's key must be upper-camel-case components.requestBodies.key.case=upper-camel-case # headers property's key must be upper-hyphen-case components.headers.key.case=upper-hyphen-case # links property's key must be upper-camel-case components.links.key.case=upper-hyphen-case # callbacks property's key must be upper-camel-case components.callbacks.key.case=upper-camel-case # headers property's key must be upper-camel-case components.headers.key.case=upper-camel-case ``` ## Compatibility checking Check whether new OAS spec compatibile with old spec. Notice: OAS could use [Reference Object][spec-reference], two OAS which are different in text maybe semantically same. For example, below old OAS doesn't use [Reference Object][spec-reference] while the new one uses: Old OAS ```yaml openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listPets requestBody: content: application/json: schema: type: array items: type: object properties: Foo: type: string responses: '200': description: A paged array of pets ``` New OAS ```yaml paths: /pets: post: operationId: listPets requestBody: content: application/json: schema: $ref: '#/components/schemas/Foo' responses: '200': description: A paged array of pets components: schemas: Foo: type: array items: type: object properties: Foo: type: string ``` So, when do compatibility check we resolve [Reference Object][spec-reference] in old and new OAS first, then do the check, below is the code snippet using [swagger-parser][swagger-parser]: ```java OpenAPIV3Parser parser = new OpenAPIV3Parser(); ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(true); parseOptions.setResolveCombinators(true); parseOptions.setResolveFully(true); parseOptions.setFlatten(false); SwaggerParseResult parseResult = parser.readContents(content, null, parseOptions); ``` So if compatibility violations be found, the reported location will be different from the location in origin OAS spec. ### Paths Object [doc][spec-paths] * New OAS must include all the `path` appears in 旧OAS. If `path` uses [Path Templating][spec-path-templating], even the variable name changed, will be considered semantically different. For example `/pets/{foo}` and `/pets/{bar}` are different. * See [Path Item Object compatibility check rules](#path-item-compatibility) ### Path Item Object [doc][spec-path-item] * New OAS must inclued all old OAS get/put/post/delete/...[Operation Object][spec-operation] ### Operation Object [doc][spec-operation] * `operationId` property, new and old must be identical * `parameters` property, check work must also consider [Path Item Object parameters property][spec-path-item-parameters]: * New OAS could add new [Parameter Object][spec-parameter], but the new [Parameter Object][spec-parameter] `required` property must be `false` * New OAS could delete[Parameter Object][spec-parameter] * The check on [Parameter Object][spec-parameter] see [Parameter Object compatibility check rules](#parameter-compatibility)(Under the same [Operation Object][spec-operation] [Parameter Object][spec-parameter] is identified by `name` and `in` property)。 * `requestBody` property, see [Request Body Object compatibility check rules](#request-body-compatibility) * `responses` property, see[Responses Object compatibility check rules](#responses-compatibility) ### Parameter Object [doc][spec-parameter] * `required` property, only allow `true(old) -> false(new)` change * `allowEmptyValue` property, only allow `false(old) -> true(new)` change * `style` property, new and old must be identical * `explode` property, new and old must be identical * `allowReserved` property, only allow `false(old) -> true(new)` change * `schema` property, see [Schema Object compatibility check rules](#schema-compatibility) * `content`property, new OAS must include all old OAS media type (`content` keys), and add new media type is not allowed * see [Media Type Object compatibility check rules](#media-type-compatibility) ### Request Body Object [doc][spec-request-body] * `content`property, new OAS must include all old OAS media type (`content` keys) * See [Media Type Object compatibility check rules](#media-type-compatibility) * `required` property, only allow `true(old) -> false(new)` change ### Media Type Object [doc][spec-media-type] * `schema` property, see [Schema Object compatibility check rules](#schema-compatibility) * `encoding` property, this property only apply to `requestBody`, so new OAS and old OAS property name(`encoding` key) must be identical * See [Encoding Object compatibility check rules](#encoding-compatibility) ### Responses Object [doc][spec-responses] * `default` property, if old OAS doesn't define `default`, then new OAS should not define `default` too. * `{Http Status Code}` property, new OAS is not allowed to add one. * See [Response Object compatibility check rules](#response-compatibility) ### Response Object [doc][spec-response] * `headers` property, new OAS must include all old OAS header name(`headers` keys), and add new header name is allowed * [Header Object][spec-header] see [Header Object compatibility check rules](#header-compatibility) * `content` property, new OAS must include all old OAS media type(`content` keys), and add new media type is allowed - [Media Type Object][spec-media-type] see [Media Type Object compatibility check rules](#media-type-compatibility) ### Schema Object [doc][spec-schema] OAS allows Schema Object be directly or indirectly in: * Request: [Parameter Object][spec-parameter], [Request Body Object][spec-request-body], [Header Object][spec-header] * Response: [Header Object][spec-header], [Response Object][spec-response] In different context compatibility check rules are different. ### In request context When Schema Object is in response context, only allow change from more specific form to less specific form. * `type, format` combination allowed change: | Old (type,format) | New (type,format) | | ---------------- | ------------------------------------------------------------ | | integer, null | integer, int64
number, double
number, null | | integer, int32 | integer, int64
integer, null
number, float
number, double
number, null | | integer, int64 | integer, null
number, double
number, null | | number, null | number, double | | number, float | number, null
number, double | | number, double | number, null | | string, null | string, password | | string, password | string, null | * `allOf`, `oneOf`, `anyOf` property, combine them first then do check * `multipleOf` property, if old OAS is null, then new OAS must == old OAS or new OAS is a factor of old OAS, eg, 6(old)->3(new) * `maximum`, `maxLength`, `maxItems`, `maxProperties`, if old OAS is null, then new OAS must be null too. Otherwise, new OAS must be >= old OAS * `minimum`, `minLenght`, `minItems`, `minProperties`, if old OAS is null, then new OAS must be null too. Otherwise, new OAS must be <= old OAS. * `exclusiveMaximum`, `exclusiveMinimum` property, only allow change `true(old)->false(new)` * `uniqueItems` property, only allow change `true(old)->false(new)` * `required` property, new OAS must == old OAS or new OAS is old OAS subset * `enum` property, new OAS must == old OAS or new OAS is old OAS superset * `properties` property, new OAS could add or delete property name(`properties` key) * `nullable` property, only allow change `false(old)->true(new)` * `discriminator` property, new and old must be identical * `xml` property, new and old must be identical * `readOnly`, `writeOnly` property, new and old must be identical ### In response context When Schema Object is in response context, only allow change from less specific form to more specific form. * `type, format` combination allowed change: | Old (type,format) | New (type,format) | | ---------------- | ---------------------------------- | | integer, null | integer, int64
integer, int32 | | integer, int64 | integer, null
interger, int32 | | number, null | number, double
number, float | | number, double | number, null
number, float | | string, null | string, password | | string, password | string, null | * `allOf`, `oneOf`, `anyOf` property, combine them first then do check * `multipleOf` property if old OAS is null. new OAS must == old OAS or new OAS must be a multiple of old OAS, eg, 3(old)->6(new) * `maximum`, `maxLength`, `maxItems`, `maxProperties`, if old OAS is null, then new OAS must be null too. Otherwise, new OAS must <= old OAS * `minimum`, `minLenght`, `minItems`, `minProperties`, if old OAS is null, then new OAS must be null too. Otherwise, new OAS must >= old OAS * `exclusiveMaximum`, `exclusiveMinimum` property, only allow change `false(old)->true(new)` * `uniqueItems` property, only allow change `false(old)->true(new)` * `required` new OAS must == old OAS or new OAS is old OAS superset * `enum` property, new OAS must == old OAS or new OAS is old OAS subset * `properties` property, new OAS could add or delete property name(`properties` key) * `nullable` property , only allow change `true(old)->false(new)` * `discriminator` property, new and old must be identical * `xml` property, new and old must be identical * `readOnly`, `writeOnly` property, new and old must be identical ### Encoding Object [doc][spec-encoding] Notice: Encoding Object only apply to Request Body Object * `contentType` property, new and old must be identical * `headers` property, new OAS can not add new he header name (`headers` key), but and delete header name * [Header Object][spec-header] see [Header Object compatibility check rules](#header-compatibility) * `style` property, new and old must be identical * `explode` property, new and old must be identical * `allowReserved` property, only allow change `false(old) -> true(new)` ### Header Object [doc][spec-header] - `schema` property, see [Schema Object compatibility check rules](#schema-compatibility) ### Components Object [doc][spec-components] [Components Object][spec-components] defines reusable OAS Object, but when doing compatibility check all `$ref` are resolved, so no need to check [Components Object][spec-components] compatibility. [spec-operation]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#operationObject [openapi-3.0.2]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md [spec-openapi]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#openapi-object [spec-server]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#serverObject [spec-info]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#infoObject [spec-paths]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#paths-object [spec-path-item]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#pathItemObject [spec-parameter]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject [spec-request-body]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#requestBodyObject [spec-security-scheme]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#securitySchemeObject [spec-components]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#components-object [spec-tag]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#tagObject [spec-schema]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject [spec-media-type]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#media-type-object [spec-response]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#response-object [spec-path-templating]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#path-templating [spec-parameterIn]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterIn [spec-encoding]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#encodingObject [spec-header]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#header-object [spec-info]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#infoObject [spec-reference]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#reference-object [swagger-parser]: https://github.com/swagger-api/swagger-parser [spec-path-item-parameters]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-pathitemparameters [spec-responses]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responsesObject ================================================ FILE: oas-validator/doc/INSTALLATION.MD ================================================ # INSTALLATION.MD ## Prerequisites * Java 8 * Maven ## Building ### Jar ``` mvn clean package ``` ``` ./mvnw clean package ``` ## Run ### Maven ``` mvn clean package spring-boot:run ``` ### Java ```bash java -jar ./oas-validator-web/target/oas-validator-web-exec.jar ``` ================================================ FILE: oas-validator/doc/USAGE.MD ================================================ # 使用手册 ## 访问 访问地址:[http://localhost:8080/](http://localhost:8080/) ## 工具 ### 查看器 敬请期待…… ### 编辑器 敬请期待…… ### 验证器 分为 **风格校验** 和 **兼容性检查** #### 风格校验 对 OpenAPI Spec 文档进行规范验证,对违反规范的错误作出提示。 ##### 操作示例 1. Step 1 ![](./compliance-1.png) 2. Step 2 ![](./compliance-2.png) #### 兼容性检查 对新旧两个 OpenAPI Spec 文档进行兼容性比较,检查出文档更新过程中出现的无法向下兼容的错误 ##### 操作示例 1. Step 1 ![](./compatibility-1.png) 2. Step 2 ![](./compatibility-2.png) ================================================ FILE: oas-validator/oas-validator-compatibility/pom.xml ================================================ org.apache.servicecomb.toolkit oas-validator-parent 0.3.0-SNAPSHOT ../pom.xml 4.0.0 oas-validator-compatibility org.apache.servicecomb.toolkit oas-validator-core org.springframework spring-context org.slf4j slf4j-api provided org.apache.servicecomb.toolkit oas-validator-test test org.apache.servicecomb.toolkit oas-validator-core-spring test org.springframework.boot spring-boot-starter-test test org.apache.maven.plugins maven-surefire-plugin org.apache.maven.plugins maven-surefire-report-plugin ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/CompatibilityCheckParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility; import io.swagger.v3.parser.OpenAPIV3Parser; import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.core.models.SwaggerParseResult; public abstract class CompatibilityCheckParser { private CompatibilityCheckParser() { // singleton } public static SwaggerParseResult parseYaml(String yaml) { OpenAPIV3Parser parser = new OpenAPIV3Parser(); return parser.readContents(yaml, null, createParseOptions()); } private static ParseOptions createParseOptions() { ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(true); parseOptions.setResolveCombinators(true); parseOptions.setResolveFully(true); parseOptions.setFlatten(false); return parseOptions; } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultCallbackDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.CallbackDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.CallbackDiffValidatorFactory; import org.springframework.stereotype.Component; @Component public class DefaultCallbackDiffValidatorFactory implements CallbackDiffValidatorFactory { @Override public List create() { return Collections.emptyList(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultComponentsDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.CallbackDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ComponentsDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.HeaderDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.LinkDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ParameterDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.RequestBodyDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ResponseDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsCallbacksDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsHeadersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsLinksDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsParametersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsRequestBodiesDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsResponsesDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultComponentsDiffValidatorFactory implements ComponentsDiffValidatorFactory { private final CallbackDiffValidatorFactory callbackDiffValidatorFactory; private final HeaderDiffValidatorFactory headerDiffValidatorFactory; private final LinkDiffValidatorFactory linkDiffValidatorFactory; private final ParameterDiffValidatorFactory parameterDiffValidatorFactory; private final RequestBodyDiffValidatorFactory requestBodyDiffValidatorFactory; private final ResponseDiffValidatorFactory responseDiffValidatorFactory; public DefaultComponentsDiffValidatorFactory( CallbackDiffValidatorFactory callbackDiffValidatorFactory, HeaderDiffValidatorFactory headerDiffValidatorFactory, LinkDiffValidatorFactory linkDiffValidatorFactory, ParameterDiffValidatorFactory parameterDiffValidatorFactory, RequestBodyDiffValidatorFactory requestBodyDiffValidatorFactory, ResponseDiffValidatorFactory responseDiffValidatorFactory) { this.callbackDiffValidatorFactory = callbackDiffValidatorFactory; this.headerDiffValidatorFactory = headerDiffValidatorFactory; this.linkDiffValidatorFactory = linkDiffValidatorFactory; this.parameterDiffValidatorFactory = parameterDiffValidatorFactory; this.requestBodyDiffValidatorFactory = requestBodyDiffValidatorFactory; this.responseDiffValidatorFactory = responseDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new ComponentsCallbacksDiffValidator(callbackDiffValidatorFactory.create())); validators.add(new ComponentsHeadersDiffValidator(headerDiffValidatorFactory.create())); validators.add(new ComponentsLinksDiffValidator(linkDiffValidatorFactory.create())); validators.add(new ComponentsParametersDiffValidator(parameterDiffValidatorFactory.create())); validators.add(new ComponentsRequestBodiesDiffValidator(requestBodyDiffValidatorFactory.create())); validators.add(new ComponentsResponsesDiffValidator(responseDiffValidatorFactory.create())); // concretes return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultEncodingDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding.EncodingAddNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding.EncodingAllowedReservedChangeDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding.EncodingContentTypeNotSameDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding.EncodingDelNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding.EncodingExplodeNotSameDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding.EncodingStyleNotSameDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.EncodingDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.HeaderDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.encoding.EncodingHeadersDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultEncodingDiffValidatorFactory implements EncodingDiffValidatorFactory { private final HeaderDiffValidatorFactory headerDiffValidatorFactory; public DefaultEncodingDiffValidatorFactory( HeaderDiffValidatorFactory headerDiffValidatorFactory) { this.headerDiffValidatorFactory = headerDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new EncodingHeadersDiffValidator(headerDiffValidatorFactory.create())); // concretes validators.add(new EncodingAddNotAllowedDiffValidator()); validators.add(new EncodingDelNotAllowedDiffValidator()); validators.add(new EncodingAllowedReservedChangeDiffValidator()); validators.add(new EncodingContentTypeNotSameDiffValidator()); validators.add(new EncodingExplodeNotSameDiffValidator()); validators.add(new EncodingStyleNotSameDiffValidator()); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultHeaderDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.header.HeaderAddInRequestBodyNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.header.HeaderDelInResponseNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.HeaderDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.SchemaDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.header.HeaderSchemaDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultHeaderDiffValidatorFactory implements HeaderDiffValidatorFactory { private final SchemaDiffValidatorFactory schemaDiffValidatorFactory; public DefaultHeaderDiffValidatorFactory( SchemaDiffValidatorFactory schemaDiffValidatorFactory) { this.schemaDiffValidatorFactory = schemaDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new HeaderSchemaDiffValidator(schemaDiffValidatorFactory.create())); // concretes validators.add(new HeaderAddInRequestBodyNotAllowedDiffValidator()); validators.add(new HeaderDelInResponseNotAllowedDiffValidator()); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultInfoDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.InfoDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.InfoDiffValidatorFactory; import org.springframework.stereotype.Component; @Component public class DefaultInfoDiffValidatorFactory implements InfoDiffValidatorFactory { @Override public List create() { return Collections.emptyList(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultLinkDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.LinkDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.LinkDiffValidatorFactory; import org.springframework.stereotype.Component; @Component public class DefaultLinkDiffValidatorFactory implements LinkDiffValidatorFactory { @Override public List create() { return Collections.emptyList(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultMediaTypeDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype.MediaTypeAddInParameterNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype.MediaTypeDelInParameterNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype.MediaTypeDelInRequestBodyNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype.MediaTypeDelInResponseNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.EncodingDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.MediaTypeDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.SchemaDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.mediatype.MediaTypeEncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.mediatype.MediaTypeSchemaDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultMediaTypeDiffValidatorFactory implements MediaTypeDiffValidatorFactory { private final EncodingDiffValidatorFactory encodingDiffValidatorFactory; private final SchemaDiffValidatorFactory schemaDiffValidatorFactory; public DefaultMediaTypeDiffValidatorFactory( EncodingDiffValidatorFactory encodingDiffValidatorFactory, SchemaDiffValidatorFactory schemaDiffValidatorFactory) { this.encodingDiffValidatorFactory = encodingDiffValidatorFactory; this.schemaDiffValidatorFactory = schemaDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new MediaTypeEncodingDiffValidator(encodingDiffValidatorFactory.create())); validators.add(new MediaTypeSchemaDiffValidator(schemaDiffValidatorFactory.create())); // concretes validators.add(new MediaTypeAddInParameterNotAllowedDiffValidator()); validators.add(new MediaTypeDelInParameterNotAllowedDiffValidator()); validators.add(new MediaTypeDelInRequestBodyNotAllowedDiffValidator()); validators.add(new MediaTypeDelInResponseNotAllowedDiffValidator()); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultOasSpecDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DefaultOasSpecDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasSpecDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.OasSpecDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.OpenApiDiffValidatorFactory; import org.springframework.stereotype.Component; @Component public class DefaultOasSpecDiffValidatorFactory implements OasSpecDiffValidatorFactory { private final OpenApiDiffValidatorFactory openApiDiffValidatorFactory; public DefaultOasSpecDiffValidatorFactory( OpenApiDiffValidatorFactory openApiDiffValidatorFactory) { this.openApiDiffValidatorFactory = openApiDiffValidatorFactory; } @Override public OasSpecDiffValidator create() { return new DefaultOasSpecDiffValidator(openApiDiffValidatorFactory.create()); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultOpenApiDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ComponentsDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.InfoDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.OpenApiDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.PathsDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ServerDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.TagDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiInfoDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiPathsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiServersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiTagsDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultOpenApiDiffValidatorFactory implements OpenApiDiffValidatorFactory { private final ComponentsDiffValidatorFactory componentsDiffValidatorFactory; private final InfoDiffValidatorFactory infoDiffValidatorFactory; private final PathsDiffValidatorFactory pathsDiffValidatorFactory; private final ServerDiffValidatorFactory serverDiffValidatorFactory; private final TagDiffValidatorFactory tagDiffValidatorFactory; public DefaultOpenApiDiffValidatorFactory( ComponentsDiffValidatorFactory componentsDiffValidatorFactory, InfoDiffValidatorFactory infoDiffValidatorFactory, PathsDiffValidatorFactory pathsDiffValidatorFactory, ServerDiffValidatorFactory serverDiffValidatorFactory, TagDiffValidatorFactory tagDiffValidatorFactory) { this.componentsDiffValidatorFactory = componentsDiffValidatorFactory; this.infoDiffValidatorFactory = infoDiffValidatorFactory; this.pathsDiffValidatorFactory = pathsDiffValidatorFactory; this.serverDiffValidatorFactory = serverDiffValidatorFactory; this.tagDiffValidatorFactory = tagDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new OpenApiComponentsDiffValidator(componentsDiffValidatorFactory.create())); validators.add(new OpenApiInfoDiffValidator(infoDiffValidatorFactory.create())); validators.add(new OpenApiPathsDiffValidator(pathsDiffValidatorFactory.create())); validators.add(new OpenApiServersDiffValidator(serverDiffValidatorFactory.create())); validators.add(new OpenApiTagsDiffValidator(tagDiffValidatorFactory.create())); // concretes return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultOperationDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.operation.OperationDeleteNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.operation.OperationIdNotSameDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.OperationDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ParameterDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.RequestBodyDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ResponsesDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation.OperationParametersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation.OperationRequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation.OperationResponsesDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultOperationDiffValidatorFactory implements OperationDiffValidatorFactory { private final ParameterDiffValidatorFactory parameterDiffValidatorFactory; private final RequestBodyDiffValidatorFactory requestBodyDiffValidatorFactory; private final ResponsesDiffValidatorFactory responsesDiffValidatorFactory; public DefaultOperationDiffValidatorFactory( ParameterDiffValidatorFactory parameterDiffValidatorFactory, RequestBodyDiffValidatorFactory requestBodyDiffValidatorFactory, ResponsesDiffValidatorFactory responsesDiffValidatorFactory) { this.parameterDiffValidatorFactory = parameterDiffValidatorFactory; this.requestBodyDiffValidatorFactory = requestBodyDiffValidatorFactory; this.responsesDiffValidatorFactory = responsesDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new OperationParametersDiffValidator(parameterDiffValidatorFactory.create())); validators.add(new OperationRequestBodyDiffValidator(requestBodyDiffValidatorFactory.create())); validators.add(new OperationResponsesDiffValidator(responsesDiffValidatorFactory.create())); // concretes validators.add(new OperationDeleteNotAllowedDiffValidator()); validators.add(new OperationIdNotSameDiffValidator()); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultParameterDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter.ParameterAddDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter.ParameterAllowEmptyValueChangeDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter.ParameterAllowReservedChangeDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter.ParameterExplodeNotSameDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter.ParameterRequiredChangeDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter.ParameterStyleNotSameDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.MediaTypeDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ParameterDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.SchemaDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.parameter.ParameterContentDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.parameter.ParameterSchemaDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultParameterDiffValidatorFactory implements ParameterDiffValidatorFactory { private final MediaTypeDiffValidatorFactory mediaTypeDiffValidatorFactory; private final SchemaDiffValidatorFactory schemaDiffValidatorFactory; public DefaultParameterDiffValidatorFactory( MediaTypeDiffValidatorFactory mediaTypeDiffValidatorFactory, SchemaDiffValidatorFactory schemaDiffValidatorFactory) { this.mediaTypeDiffValidatorFactory = mediaTypeDiffValidatorFactory; this.schemaDiffValidatorFactory = schemaDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new ParameterContentDiffValidator(mediaTypeDiffValidatorFactory.create())); validators.add(new ParameterSchemaDiffValidator(schemaDiffValidatorFactory.create())); // concretes validators.add(new ParameterAddDiffValidator()); validators.add(new ParameterRequiredChangeDiffValidator()); validators.add(new ParameterAllowEmptyValueChangeDiffValidator()); validators.add(new ParameterStyleNotSameDiffValidator()); validators.add(new ParameterExplodeNotSameDiffValidator()); validators.add(new ParameterAllowReservedChangeDiffValidator()); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultPathItemDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.pathitem.PathItemDeleteNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathItemDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.OperationDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ParameterDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.PathItemDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.pathitem.PathItemOperationsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.pathitem.PathItemParametersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.paths.PathsPathItemsDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultPathItemDiffValidatorFactory implements PathItemDiffValidatorFactory { private final OperationDiffValidatorFactory operationDiffValidatorFactory; private final ParameterDiffValidatorFactory parameterDiffValidatorFactory; public DefaultPathItemDiffValidatorFactory( OperationDiffValidatorFactory operationDiffValidatorFactory, ParameterDiffValidatorFactory parameterDiffValidatorFactory) { this.operationDiffValidatorFactory = operationDiffValidatorFactory; this.parameterDiffValidatorFactory = parameterDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new PathItemOperationsDiffValidator(operationDiffValidatorFactory.create())); validators.add(new PathItemParametersDiffValidator(parameterDiffValidatorFactory.create())); // concretes validators.add(new PathItemDeleteNotAllowedDiffValidator()); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultPathsDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.PathItemDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.PathsDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.paths.PathsPathItemsDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultPathsDiffValidatorFactory implements PathsDiffValidatorFactory { private final PathItemDiffValidatorFactory pathItemDiffValidatorFactory; public DefaultPathsDiffValidatorFactory( PathItemDiffValidatorFactory pathItemDiffValidatorFactory) { this.pathItemDiffValidatorFactory = pathItemDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new PathsPathItemsDiffValidator(pathItemDiffValidatorFactory.create())); // concretes return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultRequestBodyDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.requestbody.RequestBodyRequiredChangeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.MediaTypeDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.RequestBodyDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.requestbody.RequestBodyContentDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultRequestBodyDiffValidatorFactory implements RequestBodyDiffValidatorFactory { private final MediaTypeDiffValidatorFactory mediaTypeDiffValidatorFactory; public DefaultRequestBodyDiffValidatorFactory( MediaTypeDiffValidatorFactory mediaTypeDiffValidatorFactory) { this.mediaTypeDiffValidatorFactory = mediaTypeDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new RequestBodyContentDiffValidator(mediaTypeDiffValidatorFactory.create())); // concretes validators.add(new RequestBodyRequiredChangeDiffValidator()); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultResponseDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.response.ResponseAddNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponseDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.HeaderDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.MediaTypeDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ResponseDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.response.ResponseContentDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.response.ResponseHeadersDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultResponseDiffValidatorFactory implements ResponseDiffValidatorFactory { private final MediaTypeDiffValidatorFactory mediaTypeDiffValidatorFactory; private final HeaderDiffValidatorFactory headerDiffValidatorFactory; public DefaultResponseDiffValidatorFactory( MediaTypeDiffValidatorFactory mediaTypeDiffValidatorFactory, HeaderDiffValidatorFactory headerDiffValidatorFactory) { this.mediaTypeDiffValidatorFactory = mediaTypeDiffValidatorFactory; this.headerDiffValidatorFactory = headerDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new ResponseContentDiffValidator(mediaTypeDiffValidatorFactory.create())); validators.add(new ResponseHeadersDiffValidator(headerDiffValidatorFactory.create())); // concretes validators.add(new ResponseAddNotAllowedDiffValidator()); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultResponsesDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponsesDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ResponseDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ResponsesDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.responses.ResponsesResponsesDiffValidator; import org.springframework.stereotype.Component; @Component public class DefaultResponsesDiffValidatorFactory implements ResponsesDiffValidatorFactory { private final ResponseDiffValidatorFactory responseDiffValidatorFactory; public DefaultResponsesDiffValidatorFactory( ResponseDiffValidatorFactory responseDiffValidatorFactory) { this.responseDiffValidatorFactory = responseDiffValidatorFactory; } @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new ResponsesResponsesDiffValidator(responseDiffValidatorFactory.create())); // concretes return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultSchemaDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaDiscriminatorChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaReadOnlyChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaWriteOnlyChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaXmlChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaEnumChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaExclusiveMaximumChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaExclusiveMinimumChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMaxItemsChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMaxLengthChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMaxPropertiesChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMaximumChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMinItemsChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMinLengthChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMinPropertiesChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMinimumChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaMultipleOfChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaNullableChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaRequiredChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaTypeFormatChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.SchemaUniqueItemsChangeInRequestValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaEnumChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaExclusiveMaximumChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaExclusiveMinimumChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMaxItemsChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMaxLengthChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMaxPropertiesChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMaximumChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMinItemsChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMinLengthChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMinPropertiesChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMinimumChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaMultipleOfChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaNullableChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaRequiredChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaTypeFormatChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.SchemaUniqueItemsChangeInResponseValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.SchemaDiffValidatorFactory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.schema.SchemaDiffValidatorEngine; import org.springframework.stereotype.Component; @Component public class DefaultSchemaDiffValidatorFactory implements SchemaDiffValidatorFactory { @Override public List create() { List validators = new ArrayList<>(); // skeletons validators.add(new SchemaDiffValidatorEngine( Collections.emptyList(), Collections.emptyList(), compareValidators() )); // concretes return Collections.unmodifiableList(validators); } private List compareValidators() { List compareValidators = new ArrayList<>(); // in common conntext compareValidators.add(new SchemaReadOnlyChangeValidator()); compareValidators.add(new SchemaWriteOnlyChangeValidator()); compareValidators.add(new SchemaXmlChangeValidator()); compareValidators.add(new SchemaDiscriminatorChangeValidator()); // for request context compareValidators.add(new SchemaTypeFormatChangeInRequestValidator()); compareValidators.add(new SchemaMaximumChangeInRequestValidator()); compareValidators.add(new SchemaExclusiveMinimumChangeInRequestValidator()); compareValidators.add(new SchemaExclusiveMaximumChangeInRequestValidator()); compareValidators.add(new SchemaMultipleOfChangeInRequestValidator()); compareValidators.add(new SchemaMaxItemsChangeInRequestValidator()); compareValidators.add(new SchemaMaxLengthChangeInRequestValidator()); compareValidators.add(new SchemaMaxPropertiesChangeInRequestValidator()); compareValidators.add(new SchemaMinimumChangeInRequestValidator()); compareValidators.add(new SchemaMinItemsChangeInRequestValidator()); compareValidators.add(new SchemaMinLengthChangeInRequestValidator()); compareValidators.add(new SchemaMinPropertiesChangeInRequestValidator()); compareValidators.add(new SchemaUniqueItemsChangeInRequestValidator()); compareValidators.add(new SchemaRequiredChangeInRequestValidator()); compareValidators.add(new SchemaEnumChangeInRequestValidator()); compareValidators.add(new SchemaNullableChangeInRequestValidator()); // for response context compareValidators.add(new SchemaTypeFormatChangeInResponseValidator()); compareValidators.add(new SchemaMaximumChangeInResponseValidator()); compareValidators.add(new SchemaExclusiveMinimumChangeInResponseValidator()); compareValidators.add(new SchemaExclusiveMaximumChangeInResponseValidator()); compareValidators.add(new SchemaMultipleOfChangeInResponseValidator()); compareValidators.add(new SchemaMaxItemsChangeInResponseValidator()); compareValidators.add(new SchemaMaxLengthChangeInResponseValidator()); compareValidators.add(new SchemaMaxPropertiesChangeInResponseValidator()); compareValidators.add(new SchemaMinimumChangeInResponseValidator()); compareValidators.add(new SchemaMinItemsChangeInResponseValidator()); compareValidators.add(new SchemaMinLengthChangeInResponseValidator()); compareValidators.add(new SchemaMinPropertiesChangeInResponseValidator()); compareValidators.add(new SchemaUniqueItemsChangeInResponseValidator()); compareValidators.add(new SchemaRequiredChangeInResponseValidator()); compareValidators.add(new SchemaEnumChangeInResponseValidator()); compareValidators.add(new SchemaNullableChangeInResponseValidator()); return Collections.unmodifiableList(compareValidators); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultSecuritySchemeDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SecuritySchemeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.SecuritySchemeDiffValidatorFactory; import org.springframework.stereotype.Component; @Component public class DefaultSecuritySchemeDiffValidatorFactory implements SecuritySchemeDiffValidatorFactory { @Override public List create() { return Collections.emptyList(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultServerDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ServerDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.ServerDiffValidatorFactory; import org.springframework.stereotype.Component; @Component public class DefaultServerDiffValidatorFactory implements ServerDiffValidatorFactory { @Override public List create() { return Collections.emptyList(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultTagDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import java.util.Collections; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.TagDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.factory.TagDiffValidatorFactory; import org.springframework.stereotype.Component; @Component public class DefaultTagDiffValidatorFactory implements TagDiffValidatorFactory { @Override public List create() { return Collections.emptyList(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingAddNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.Encoding; import java.util.List; import static java.util.Collections.singletonList; public class EncodingAddNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements EncodingDiffValidator { @Override protected List validateAdd(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, Encoding rightOasObject) { return singletonList(OasDiffViolation.onlyRight(rightLocation, DiffViolationMessages.OP_ADD_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingAllowedReservedChangeDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasObjectDiffValidatorTemplate; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import io.swagger.v3.oas.models.media.Encoding; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; public class EncodingAllowedReservedChangeDiffValidator extends OasObjectDiffValidatorTemplate implements EncodingDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Encoding leftOasObject, OasObjectPropertyLocation rightLocation, Encoding rightOasObject) { if (ChangeRangeCheckUtils.isNotViolated( defaultIfNull(leftOasObject.getAllowReserved(), Boolean.FALSE), defaultIfNull(rightOasObject.getAllowReserved(), Boolean.FALSE), singletonList(new Object[] { false, true }))) { return emptyList(); } return singletonList(new OasDiffViolation( leftLocation.property("allowReserved"), rightLocation.property("allowReserved"), DiffViolationMessages.FALSE_TO_TRUE )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingContentTypeNotSameDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.Encoding; import java.util.List; import java.util.Objects; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public class EncodingContentTypeNotSameDiffValidator extends OasObjectDiffValidatorTemplate implements EncodingDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Encoding leftOasObject, OasObjectPropertyLocation rightLocation, Encoding rightOasObject) { if (Objects.equals(leftOasObject.getContentType(), rightOasObject.getContentType())) { return emptyList(); } return singletonList(new OasDiffViolation( leftLocation.property("contentType"), rightLocation.property("contentType"), DiffViolationMessages.NEW_NOT_EQ_OLD )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingDelNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.Encoding; import java.util.List; import static java.util.Collections.singletonList; public class EncodingDelNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements EncodingDiffValidator { @Override protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Encoding leftOasObject) { return singletonList(OasDiffViolation.onlyLeft(leftLocation, DiffViolationMessages.OP_DEL_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingExplodeNotSameDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.Encoding; import java.util.List; import java.util.Objects; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public class EncodingExplodeNotSameDiffValidator extends OasObjectDiffValidatorTemplate implements EncodingDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Encoding leftOasObject, OasObjectPropertyLocation rightLocation, Encoding rightOasObject) { if (Objects.equals(leftOasObject.getExplode(), rightOasObject.getExplode())) { return emptyList(); } return singletonList(new OasDiffViolation( leftLocation.property("explode"), rightLocation.property("explode"), DiffViolationMessages.NEW_NOT_EQ_OLD )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingStyleNotSameDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.Encoding; import java.util.List; import java.util.Objects; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public class EncodingStyleNotSameDiffValidator extends OasObjectDiffValidatorTemplate implements EncodingDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Encoding leftOasObject, OasObjectPropertyLocation rightLocation, Encoding rightOasObject) { if (Objects.equals(leftOasObject.getStyle(), rightOasObject.getStyle())) { return emptyList(); } return singletonList(new OasDiffViolation( leftLocation.property("style"), rightLocation.property("style"), DiffViolationMessages.NEW_NOT_EQ_OLD )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/header/HeaderAddInRequestBodyNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.header; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.headers.Header; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Adding Header Object under requestBody.content.'mediaType'.encoding.'encoding'.headers is not allowed */ public class HeaderAddInRequestBodyNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate
implements HeaderDiffValidator { @Override protected List validateAdd(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, Header rightOasObject) { if (!isInRequestBody(context)) { return emptyList(); } return singletonList(OasDiffViolation.onlyRight(rightLocation, DiffViolationMessages.OP_ADD_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/header/HeaderDelInResponseNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.header; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.headers.Header; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Deleting Header Object under responses.'response'.headers.headers is not allowed */ public class HeaderDelInResponseNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate
implements HeaderDiffValidator { @Override protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, Header rightOasObject) { if (!isInResponse(context)) { return emptyList(); } return singletonList(OasDiffViolation.onlyLeft(rightLocation, DiffViolationMessages.OP_DEL_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/MediaTypeAddInParameterNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.MediaType; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Adding MediaType Object under Parameter.content is not allowed */ public class MediaTypeAddInParameterNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements MediaTypeDiffValidator { @Override protected List validateAdd(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, MediaType rightOasObject) { if (!isInParameter(context)) { return emptyList(); } return singletonList(OasDiffViolation.onlyRight(rightLocation, DiffViolationMessages.OP_ADD_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/MediaTypeDelInParameterNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.MediaType; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Deleting MediaType Object under Parameter.content is not allowed */ public class MediaTypeDelInParameterNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements MediaTypeDiffValidator { @Override protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, MediaType leftOasObject) { if (!isInParameter(context)) { return emptyList(); } return singletonList(OasDiffViolation.onlyLeft(leftLocation, DiffViolationMessages.OP_DEL_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/MediaTypeDelInRequestBodyNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.MediaType; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Deleting MediaType Object under RequestBody.content is not allowed */ public class MediaTypeDelInRequestBodyNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements MediaTypeDiffValidator { @Override protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, MediaType leftOasObject) { if (!isInRequestBody(context)) { return emptyList(); } return singletonList(OasDiffViolation.onlyLeft(leftLocation, DiffViolationMessages.OP_DEL_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/MediaTypeDelInResponseNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.MediaType; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Deleting MediaType Object under responses.'response'.content.'mediaType' is not allowed */ public class MediaTypeDelInResponseNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements MediaTypeDiffValidator { @Override protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, MediaType leftOasObject) { if (!isInResponse(context)) { return emptyList(); } return singletonList(OasDiffViolation.onlyLeft(leftLocation, DiffViolationMessages.OP_DEL_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/operation/OperationDeleteNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.operation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.Operation; import java.util.List; import static java.util.Collections.singletonList; public class OperationDeleteNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements OperationDiffValidator { @Override protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Operation leftOasObject) { return singletonList(OasDiffViolation.onlyLeft(leftLocation, DiffViolationMessages.OP_DEL_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/operation/OperationIdNotSameDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.operation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.Operation; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public class OperationIdNotSameDiffValidator extends OasObjectDiffValidatorTemplate implements OperationDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Operation leftOasObject, OasObjectPropertyLocation rightLocation, Operation rightOasObject) { if (leftOasObject.getOperationId().equalsIgnoreCase(rightOasObject.getOperationId())) { return emptyList(); } return singletonList(new OasDiffViolation( leftLocation.property("operationId"), rightLocation.property("operationId"), DiffViolationMessages.NEW_NOT_EQ_OLD)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterAddDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasObjectDiffValidatorTemplate; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ParameterUtils; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public class ParameterAddDiffValidator extends OasObjectDiffValidatorTemplate implements ParameterDiffValidator { public static final String VIOLATION_MESSAGE = "required=true parameter is not allowed on right side"; @Override protected List validateAdd(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, Parameter rightOasObject) { if (Boolean.FALSE.equals(rightOasObject.getRequired())) { return emptyList(); } String message = new StringBuilder() .append(ParameterUtils.getKeyString(rightOasObject)) .append(':') .append(VIOLATION_MESSAGE) .toString() ; return singletonList(OasDiffViolation.onlyRight(rightLocation.property("required"), message)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterAllowEmptyValueChangeDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasObjectDiffValidatorTemplate; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ParameterUtils; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; /** * Parameter.allowEmpty only allow change false to true */ public class ParameterAllowEmptyValueChangeDiffValidator extends OasObjectDiffValidatorTemplate implements ParameterDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Parameter leftOasObject, OasObjectPropertyLocation rightLocation, Parameter rightOasObject) { if (ChangeRangeCheckUtils.isNotViolated( defaultIfNull(leftOasObject.getAllowEmptyValue(), Boolean.FALSE), defaultIfNull(rightOasObject.getAllowEmptyValue(), Boolean.FALSE), singletonList(new Object[] { false, true }))) { return emptyList(); } String message = new StringBuilder() .append(ParameterUtils.getKeyString(rightOasObject)) .append(':') .append(DiffViolationMessages.FALSE_TO_TRUE) .toString(); return singletonList(new OasDiffViolation( leftLocation.property("allowEmptyValue"), rightLocation.property("allowEmptyValue"), message )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterAllowReservedChangeDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasObjectDiffValidatorTemplate; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ParameterUtils; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; /** * Parameter.allowReserved only allow change false to true */ public class ParameterAllowReservedChangeDiffValidator extends OasObjectDiffValidatorTemplate implements ParameterDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Parameter leftOasObject, OasObjectPropertyLocation rightLocation, Parameter rightOasObject) { if (ChangeRangeCheckUtils.isNotViolated( defaultIfNull(leftOasObject.getAllowReserved(), Boolean.FALSE), defaultIfNull(rightOasObject.getAllowReserved(), Boolean.FALSE), singletonList(new Object[] { false, true }))) { return emptyList(); } String message = new StringBuilder() .append(ParameterUtils.getKeyString(rightOasObject)) .append(':') .append(DiffViolationMessages.FALSE_TO_TRUE) .toString(); return singletonList(new OasDiffViolation( leftLocation.property("allowReserved"), rightLocation.property("allowReserved"), message )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterExplodeNotSameDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ParameterUtils; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import java.util.Objects; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public class ParameterExplodeNotSameDiffValidator extends OasObjectDiffValidatorTemplate implements ParameterDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Parameter leftOasObject, OasObjectPropertyLocation rightLocation, Parameter rightOasObject) { if (Objects.equals(leftOasObject.getExplode(), rightOasObject.getExplode())) { return emptyList(); } String message = new StringBuilder() .append(ParameterUtils.getKeyString(rightOasObject)) .append(':') .append(DiffViolationMessages.NEW_NOT_EQ_OLD) .toString(); return singletonList(new OasDiffViolation( leftLocation.property("explode"), rightLocation.property("explode"), message )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterRequiredChangeDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasObjectDiffValidatorTemplate; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ParameterUtils; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; /** * Parameter.required only allow change true->false */ public class ParameterRequiredChangeDiffValidator extends OasObjectDiffValidatorTemplate implements ParameterDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Parameter leftOasObject, OasObjectPropertyLocation rightLocation, Parameter rightOasObject) { if (ChangeRangeCheckUtils.isNotViolated( defaultIfNull(leftOasObject.getRequired(), Boolean.FALSE), defaultIfNull(rightOasObject.getRequired(), Boolean.FALSE), singletonList(new Object[] { true, false }))) { return emptyList(); } String message = new StringBuilder() .append(ParameterUtils.getKeyString(rightOasObject)) .append(':') .append(DiffViolationMessages.TRUE_TO_FALSE) .toString(); return singletonList(new OasDiffViolation( leftLocation.property("required"), rightLocation.property("required"), message )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterStyleNotSameDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ParameterUtils; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import java.util.Objects; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public class ParameterStyleNotSameDiffValidator extends OasObjectDiffValidatorTemplate implements ParameterDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Parameter leftOasObject, OasObjectPropertyLocation rightLocation, Parameter rightOasObject) { if (Objects.equals(leftOasObject.getStyle(), rightOasObject.getStyle())) { return emptyList(); } String message = new StringBuilder() .append(ParameterUtils.getKeyString(rightOasObject)) .append(':') .append(DiffViolationMessages.NEW_NOT_EQ_OLD) .toString(); return singletonList(new OasDiffViolation( leftLocation.property("style"), rightLocation.property("style"), message )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/pathitem/PathItemDeleteNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.pathitem; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.PathItem; import java.util.List; import static java.util.Collections.singletonList; public class PathItemDeleteNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements PathItemDiffValidator { @Override protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, PathItem leftOasObject) { return singletonList(OasDiffViolation.onlyLeft(leftLocation, DiffViolationMessages.OP_DEL_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/requestbody/RequestBodyRequiredChangeDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.requestbody; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasObjectDiffValidatorTemplate; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import io.swagger.v3.oas.models.parameters.RequestBody; import org.apache.commons.lang3.ObjectUtils; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * RequestBody.required only allow change true->false */ public class RequestBodyRequiredChangeDiffValidator extends OasObjectDiffValidatorTemplate implements RequestBodyDiffValidator { @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, RequestBody leftOasObject, OasObjectPropertyLocation rightLocation, RequestBody rightOasObject) { if (ChangeRangeCheckUtils.isNotViolated( ObjectUtils.defaultIfNull(leftOasObject.getRequired(), Boolean.FALSE), ObjectUtils.defaultIfNull(rightOasObject.getRequired(), Boolean.FALSE), singletonList(new Object[] { true, false }))) { return emptyList(); } return singletonList(new OasDiffViolation( leftLocation.property("required"), rightLocation.property("required"), DiffViolationMessages.TRUE_TO_FALSE )); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/response/ResponseAddNotAllowedDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.response; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.responses.ApiResponse; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation.onlyRight; import static java.util.Collections.singletonList; /** * Adding Response Object under responses.'http status code' is not allowed */ public class ResponseAddNotAllowedDiffValidator extends OasObjectDiffValidatorTemplate implements ResponseDiffValidator { @Override protected List validateAdd(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, ApiResponse rightOasObject) { return singletonList(onlyRight(rightLocation, DiffViolationMessages.OP_ADD_FORBIDDEN)); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaDiscriminatorChangeValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import io.swagger.v3.oas.models.media.Discriminator; import io.swagger.v3.oas.models.media.Schema; public class SchemaDiscriminatorChangeValidator extends SchemaPropertyChangeValidator { @Override protected Discriminator getProperty(Schema schema) { return schema.getDiscriminator(); } @Override protected String getPropertyName() { return "discriminator"; } @Override protected boolean isAllowed(Discriminator leftProperty, Discriminator rightProperty) { return leftProperty.equals(rightProperty); } @Override protected String getMessage(Discriminator leftProperty, Discriminator rightProperty) { return DiffViolationMessages.NEW_NOT_EQ_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return true; } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaPropertyChangeValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import io.swagger.v3.oas.models.media.Schema; import java.util.List; import java.util.Objects; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public abstract class SchemaPropertyChangeValidator implements SchemaCompareValidator { @Override public final List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject, OasObjectPropertyLocation rightLocation, Schema rightOasObject) { if (!needValidate(context)) { return emptyList(); } T leftNumber = getProperty(leftOasObject); T rightNumber = getProperty(rightOasObject); if (Objects.equals(leftNumber, rightNumber)) { return emptyList(); } String propertyName = getPropertyName(); if (leftNumber == null || rightNumber == null) { return singletonList(new OasDiffViolation( leftLocation.property(propertyName), rightLocation.property(propertyName), getMessage(leftNumber, rightNumber) ) ); } if (!isAllowed(leftNumber, rightNumber)) { return singletonList(new OasDiffViolation( leftLocation.property(propertyName), rightLocation.property(propertyName), getMessage(leftNumber, rightNumber) ) ); } return emptyList(); } protected abstract T getProperty(Schema schema); protected abstract String getPropertyName(); protected abstract String getMessage(T leftProperty, T rightProperty); protected abstract boolean isAllowed(T leftProperty, T rightProperty); protected abstract boolean needValidate(OasDiffValidationContext context); } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaReadOnlyChangeValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; public class SchemaReadOnlyChangeValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getReadOnly(), Boolean.FALSE); } @Override protected String getPropertyName() { return "readOnly"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return leftProperty.equals(rightProperty); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.NEW_NOT_EQ_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return true; } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaTypeFormatChangeValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import io.swagger.v3.oas.models.media.Schema; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public abstract class SchemaTypeFormatChangeValidator implements SchemaCompareValidator { @Override public final List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject, OasObjectPropertyLocation rightLocation, Schema rightOasObject) { if (!needValidate(context)) { return emptyList(); } TypeFormat leftTypeFormat = new TypeFormat(leftOasObject); TypeFormat rightTypeFormat = new TypeFormat(rightOasObject); if (ChangeRangeCheckUtils.isNotViolated(leftTypeFormat, rightTypeFormat, getAllowedChangedList())) { return emptyList(); } StringBuilder message = new StringBuilder("the change "); message .append("(type=") .append(leftTypeFormat.getType()) .append(",format=") .append(leftTypeFormat.getFormat()) .append(')') .append("->") .append("(type=") .append(rightTypeFormat.getType()) .append(",format=") .append(rightTypeFormat.getFormat()) .append(')') .append(" is not allowed"); return singletonList(new OasDiffViolation(leftLocation, rightLocation, message.toString())); } protected abstract List getAllowedChangedList(); protected abstract boolean needValidate(OasDiffValidationContext context); } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaWriteOnlyChangeValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; public class SchemaWriteOnlyChangeValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getWriteOnly(), Boolean.FALSE); } @Override protected String getPropertyName() { return "writeOnly"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return leftProperty.equals(rightProperty); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.NEW_NOT_EQ_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return true; } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaXmlChangeValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.XML; public class SchemaXmlChangeValidator extends SchemaPropertyChangeValidator { @Override protected XML getProperty(Schema schema) { return schema.getXml(); } @Override protected String getPropertyName() { return "xml"; } @Override protected boolean isAllowed(XML leftProperty, XML rightProperty) { return leftProperty.equals(rightProperty); } @Override protected String getMessage(XML leftProperty, XML rightProperty) { return DiffViolationMessages.NEW_NOT_EQ_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return true; } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/TypeFormat.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import io.swagger.v3.oas.models.media.Schema; import java.util.Objects; import java.util.StringJoiner; public class TypeFormat { private final String type; private final String format; public TypeFormat(String type, String format) { this.type = type; this.format = format; } public TypeFormat(Schema schema) { this.type = schema.getType(); this.format = schema.getFormat(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TypeFormat that = (TypeFormat) o; return Objects.equals(type, that.type) && Objects.equals(format, that.format); } @Override public int hashCode() { return Objects.hash(type, format); } @Override public String toString() { return new StringJoiner(", ", TypeFormat.class.getSimpleName() + "[", "]") .add("type='" + type + "'") .add("format='" + format + "'") .toString(); } public String getType() { return type; } public String getFormat() { return format; } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaEnumChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; import static java.util.Collections.emptyList; public class SchemaEnumChangeInRequestValidator extends SchemaPropertyChangeValidator { public static final String VIOLATION_MESSAGE = "deleting enum on right side is not allowed"; @Override protected List getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getEnum(), emptyList()); } @Override protected String getPropertyName() { return "enum"; } @Override protected boolean isAllowed(List leftProperty, List rightProperty) { return rightProperty.containsAll(leftProperty); } @Override protected String getMessage(List leftProperty, List rightProperty) { return VIOLATION_MESSAGE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaExclusiveMaximumChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; import static java.util.Collections.singletonList; public class SchemaExclusiveMaximumChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getExclusiveMaximum(), Boolean.FALSE); } @Override protected String getPropertyName() { return "exclusiveMaximum"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return ChangeRangeCheckUtils .isNotViolated(leftProperty, rightProperty, singletonList(new Object[] { true, false })); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.TRUE_TO_FALSE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaExclusiveMinimumChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; import static java.util.Collections.singletonList; public class SchemaExclusiveMinimumChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getExclusiveMinimum(), Boolean.FALSE); } @Override protected String getPropertyName() { return "exclusiveMinimum"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return ChangeRangeCheckUtils .isNotViolated(leftProperty, rightProperty, singletonList(new Object[] { true, false })); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.TRUE_TO_FALSE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMaxItemsChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMaxItemsChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMaxItems(); } @Override protected String getPropertyName() { return "maxItems"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) >= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_GTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMaxLengthChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMaxLengthChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMaxLength(); } @Override protected String getPropertyName() { return "maxLength"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) >= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_GTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMaxPropertiesChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMaxPropertiesChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMaxProperties(); } @Override protected String getPropertyName() { return "maxProperties"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) >= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_GTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMaximumChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import java.math.BigDecimal; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMaximumChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected BigDecimal getProperty(Schema schema) { return schema.getMaximum(); } @Override protected String getPropertyName() { return "maximum"; } @Override protected boolean isAllowed(BigDecimal leftProperty, BigDecimal rightProperty) { return rightProperty.compareTo(leftProperty) >= 0; } @Override protected String getMessage(BigDecimal leftProperty, BigDecimal rightProperty) { return DiffViolationMessages.NEW_NOT_GTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMinItemsChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMinItemsChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMinItems(); } @Override protected String getPropertyName() { return "minItems"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) <= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_LTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMinLengthChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMinLengthChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMinLength(); } @Override protected String getPropertyName() { return "minLength"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) <= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_LTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMinPropertiesChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMinPropertiesChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMinProperties(); } @Override protected String getPropertyName() { return "minProperties"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) <= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_LTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMinimumChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import java.math.BigDecimal; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMinimumChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected BigDecimal getProperty(Schema schema) { return schema.getMinimum(); } @Override protected String getPropertyName() { return "minimum"; } @Override protected boolean isAllowed(BigDecimal leftProperty, BigDecimal rightProperty) { return rightProperty.compareTo(leftProperty) <= 0; } @Override protected String getMessage(BigDecimal leftProperty, BigDecimal rightProperty) { return DiffViolationMessages.NEW_NOT_LTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMultipleOfChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import java.math.BigDecimal; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaMultipleOfChangeInRequestValidator extends SchemaPropertyChangeValidator { public static final String VIOLATION_MESSAGE = "right value is neither equal to left value nor a factor of left value"; @Override protected BigDecimal getProperty(Schema schema) { return schema.getMultipleOf(); } @Override protected String getPropertyName() { return "multipleOf"; } @Override protected String getMessage(BigDecimal leftProperty, BigDecimal rightProperty) { return VIOLATION_MESSAGE; } @Override protected boolean isAllowed(BigDecimal leftProperty, BigDecimal rightProperty) { return BigDecimal.ZERO.compareTo(leftProperty.divideAndRemainder(rightProperty)[1]) == 0; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaNullableChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; import static java.util.Collections.singletonList; public class SchemaNullableChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getNullable(), Boolean.FALSE); } @Override protected String getPropertyName() { return "nullable"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return ChangeRangeCheckUtils .isNotViolated(leftProperty, rightProperty, singletonList(new Object[] { false, true })); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.FALSE_TO_TRUE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaRequiredChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; import static java.util.Collections.emptyList; public class SchemaRequiredChangeInRequestValidator extends SchemaPropertyChangeValidator> { public static final String VIOLATION_MESSAGE = "adding required fields is not allowed on right side"; @Override protected List getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getRequired(), emptyList()); } @Override protected String getPropertyName() { return "required"; } @Override protected boolean isAllowed(List leftProperty, List rightProperty) { return leftProperty.containsAll(rightProperty); } @Override protected String getMessage(List leftProperty, List rightProperty) { return VIOLATION_MESSAGE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaTypeFormatChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaTypeFormatChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.TypeFormat; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; public class SchemaTypeFormatChangeInRequestValidator extends SchemaTypeFormatChangeValidator { private static final List allowedChangedList; static { Object[][] allowedChange = new Object[][] { new Object[] { new TypeFormat("integer", null), new TypeFormat("integer", "int64") }, new Object[] { new TypeFormat("integer", null), new TypeFormat("number", "double") }, new Object[] { new TypeFormat("integer", null), new TypeFormat("number", null) }, new Object[] { new TypeFormat("integer", "int32"), new TypeFormat("integer", "int64") }, new Object[] { new TypeFormat("integer", "int32"), new TypeFormat("integer", null) }, new Object[] { new TypeFormat("integer", "int32"), new TypeFormat("number", "float") }, new Object[] { new TypeFormat("integer", "int32"), new TypeFormat("number", "double") }, new Object[] { new TypeFormat("integer", "int32"), new TypeFormat("number", null) }, new Object[] { new TypeFormat("integer", "int64"), new TypeFormat("integer", null) }, new Object[] { new TypeFormat("integer", "int64"), new TypeFormat("number", "double") }, new Object[] { new TypeFormat("integer", "int64"), new TypeFormat("number", null) }, new Object[] { new TypeFormat("number", null), new TypeFormat("number", "double") }, new Object[] { new TypeFormat("number", "float"), new TypeFormat("number", null) }, new Object[] { new TypeFormat("number", "float"), new TypeFormat("number", "double") }, new Object[] { new TypeFormat("number", "double"), new TypeFormat("number", null) }, new Object[] { new TypeFormat("string", null), new TypeFormat("string", "password") }, new Object[] { new TypeFormat("string", "password"), new TypeFormat("string", null) }, }; allowedChangedList = Collections.unmodifiableList(Arrays.asList(allowedChange)); } @Override protected List getAllowedChangedList() { return allowedChangedList; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInRequestBody(context) || isInParameter(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaUniqueItemsChangeInRequestValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInParameter; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInRequestBody; import static java.util.Collections.singletonList; public class SchemaUniqueItemsChangeInRequestValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return schema.getUniqueItems(); } @Override protected String getPropertyName() { return "uniqueItems"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return ChangeRangeCheckUtils .isNotViolated(leftProperty, rightProperty, singletonList(new Object[] { true, false })); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.TRUE_TO_FALSE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInParameter(context) || isInRequestBody(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaEnumChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; import static java.util.Collections.emptyList; public class SchemaEnumChangeInResponseValidator extends SchemaPropertyChangeValidator { public static final String VIOLATION_MESSAGE = "adding enum on right side is not allowed"; @Override protected List getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getEnum(), emptyList()); } @Override protected String getPropertyName() { return "enum"; } @Override protected boolean isAllowed(List leftProperty, List rightProperty) { return leftProperty.containsAll(rightProperty); } @Override protected String getMessage(List leftProperty, List rightProperty) { return VIOLATION_MESSAGE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaExclusiveMaximumChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; import static java.util.Collections.singletonList; public class SchemaExclusiveMaximumChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getExclusiveMaximum(), Boolean.FALSE); } @Override protected String getPropertyName() { return "exclusiveMaximum"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return ChangeRangeCheckUtils .isNotViolated(leftProperty, rightProperty, singletonList(new Object[] { false, true })); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.FALSE_TO_TRUE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaExclusiveMinimumChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; import static java.util.Collections.singletonList; public class SchemaExclusiveMinimumChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getExclusiveMinimum(), Boolean.FALSE); } @Override protected String getPropertyName() { return "exclusiveMinimum"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return ChangeRangeCheckUtils .isNotViolated(leftProperty, rightProperty, singletonList(new Object[] { false, true })); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.FALSE_TO_TRUE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMaxItemsChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.*; public class SchemaMaxItemsChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMaxItems(); } @Override protected String getPropertyName() { return "maxItems"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) <= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_LTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMaxLengthChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.*; public class SchemaMaxLengthChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMaxLength(); } @Override protected String getPropertyName() { return "maxLength"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) <= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_LTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMaxPropertiesChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; public class SchemaMaxPropertiesChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMaxProperties(); } @Override protected String getPropertyName() { return "maxProperties"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) <= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_LTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMaximumChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import java.math.BigDecimal; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; public class SchemaMaximumChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected BigDecimal getProperty(Schema schema) { return schema.getMaximum(); } @Override protected String getPropertyName() { return "maximum"; } @Override protected boolean isAllowed(BigDecimal leftProperty, BigDecimal rightProperty) { return rightProperty.compareTo(leftProperty) <= 0; } @Override protected String getMessage(BigDecimal leftProperty, BigDecimal rightProperty) { return DiffViolationMessages.NEW_NOT_LTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMinItemsChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; public class SchemaMinItemsChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMinItems(); } @Override protected String getPropertyName() { return "minItems"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) >= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_GTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMinLengthChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; public class SchemaMinLengthChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMinLength(); } @Override protected String getPropertyName() { return "minLength"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) >= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_GTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMinPropertiesChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; public class SchemaMinPropertiesChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Integer getProperty(Schema schema) { return schema.getMinProperties(); } @Override protected String getPropertyName() { return "minProperties"; } @Override protected boolean isAllowed(Integer leftProperty, Integer rightProperty) { return rightProperty.compareTo(leftProperty) >= 0; } @Override protected String getMessage(Integer leftProperty, Integer rightProperty) { return DiffViolationMessages.NEW_NOT_GTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMinimumChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import java.math.BigDecimal; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.*; public class SchemaMinimumChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected BigDecimal getProperty(Schema schema) { return schema.getMinimum(); } @Override protected String getPropertyName() { return "minimum"; } @Override protected boolean isAllowed(BigDecimal leftProperty, BigDecimal rightProperty) { return rightProperty.compareTo(leftProperty) >= 0; } @Override protected String getMessage(BigDecimal leftProperty, BigDecimal rightProperty) { return DiffViolationMessages.NEW_NOT_GTE_OLD; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMultipleOfChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import java.math.BigDecimal; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; public class SchemaMultipleOfChangeInResponseValidator extends SchemaPropertyChangeValidator { public static final String VIOLATION_MESSAGE = "right value is neither equal to left value nor multiple of left value"; @Override protected BigDecimal getProperty(Schema schema) { return schema.getMultipleOf(); } @Override protected String getPropertyName() { return "multipleOf"; } @Override protected String getMessage(BigDecimal leftProperty, BigDecimal rightProperty) { return VIOLATION_MESSAGE; } @Override protected boolean isAllowed(BigDecimal leftProperty, BigDecimal rightProperty) { return BigDecimal.ZERO.compareTo(rightProperty.divideAndRemainder(leftProperty)[1]) == 0; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaNullableChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; import static java.util.Collections.singletonList; public class SchemaNullableChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getNullable(), Boolean.FALSE); } @Override protected String getPropertyName() { return "nullable"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return ChangeRangeCheckUtils .isNotViolated(leftProperty, rightProperty, singletonList(new Object[] { true, false })); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.TRUE_TO_FALSE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaRequiredChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ObjectUtils; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; import static java.util.Collections.emptyList; public class SchemaRequiredChangeInResponseValidator extends SchemaPropertyChangeValidator> { public static final String VIOLATION_MESSAGE = "deleting required fields is not allowed on right side"; @Override protected List getProperty(Schema schema) { return ObjectUtils.defaultIfNull(schema.getRequired(), emptyList()); } @Override protected String getPropertyName() { return "required"; } @Override protected boolean isAllowed(List leftProperty, List rightProperty) { return rightProperty.containsAll(leftProperty); } @Override protected String getMessage(List leftProperty, List rightProperty) { return SchemaRequiredChangeInResponseValidator.VIOLATION_MESSAGE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaTypeFormatChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaTypeFormatChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.TypeFormat; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; public class SchemaTypeFormatChangeInResponseValidator extends SchemaTypeFormatChangeValidator { private static final List allowedChangedList; static { Object[][] allowedChange = new Object[][] { new Object[] { new TypeFormat("integer", null), new TypeFormat("integer", "int64") }, new Object[] { new TypeFormat("integer", null), new TypeFormat("integer", "int32") }, new Object[] { new TypeFormat("integer", "int64"), new TypeFormat("integer", null) }, new Object[] { new TypeFormat("integer", "int64"), new TypeFormat("integer", "int32") }, new Object[] { new TypeFormat("number", null), new TypeFormat("number", "double") }, new Object[] { new TypeFormat("number", null), new TypeFormat("number", "float") }, new Object[] { new TypeFormat("number", "double"), new TypeFormat("number", null) }, new Object[] { new TypeFormat("number", "double"), new TypeFormat("number", "float") }, new Object[] { new TypeFormat("string", null), new TypeFormat("string", "password") }, new Object[] { new TypeFormat("string", "password"), new TypeFormat("string", null) }, }; allowedChangedList = Collections.unmodifiableList(Arrays.asList(allowedChange)); } @Override protected List getAllowedChangedList() { return allowedChangedList; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaUniqueItemsChangeInResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.ChangeRangeCheckUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaPropertyChangeValidator; import io.swagger.v3.oas.models.media.Schema; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.isInResponse; import static java.util.Collections.singletonList; public class SchemaUniqueItemsChangeInResponseValidator extends SchemaPropertyChangeValidator { @Override protected Boolean getProperty(Schema schema) { return schema.getUniqueItems(); } @Override protected String getPropertyName() { return "uniqueItems"; } @Override protected boolean isAllowed(Boolean leftProperty, Boolean rightProperty) { return ChangeRangeCheckUtils .isNotViolated(leftProperty, rightProperty, singletonList(new Object[] { false, true })); } @Override protected String getMessage(Boolean leftProperty, Boolean rightProperty) { return DiffViolationMessages.FALSE_TO_TRUE; } @Override protected boolean needValidate(OasDiffValidationContext context) { return isInResponse(context); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/CompatibilityCheckParserTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import io.swagger.v3.parser.core.models.SwaggerParseResult; import io.swagger.v3.parser.util.ClasspathHelper; public class CompatibilityCheckParserTest { @Test public void parseYaml() { String yaml = loadRelative("parser-test.yaml"); SwaggerParseResult swaggerParseResult = CompatibilityCheckParser.parseYaml(yaml); assertThat(swaggerParseResult).isNotNull(); assertThat(swaggerParseResult.getOpenAPI()).isNotNull(); assertThat(swaggerParseResult.getMessages()).isEmpty(); } private String loadRelative(String filename) { String basePath = getClass().getPackage().getName().replaceAll("\\.", "/"); return ClasspathHelper.loadFileFromClasspath(basePath + "/" + filename); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultCallbackDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.CallbackDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultCallbackDiffValidatorFactoryTest { @Autowired private DefaultCallbackDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultComponentsDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultComponentsDiffValidatorFactoryTest { @Autowired private DefaultComponentsDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(6); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultEncodingDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultEncodingDiffValidatorFactoryTest { @Autowired private DefaultEncodingDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(7); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultInfoDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.InfoDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultInfoDiffValidatorFactoryTest { @Autowired private DefaultInfoDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultLinkDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.LinkDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultLinkDiffValidatorFactoryTest { @Autowired private DefaultLinkDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultMediaTypeDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultMediaTypeDiffValidatorFactoryTest { @Autowired private DefaultMediaTypeDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(6); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultOasSpecDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultOasSpecDiffValidatorFactoryTest { @Autowired private DefaultOasSpecDiffValidatorFactory validatorFactory; @Test public void create() { assertThat(validatorFactory.create()).isNotNull(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultOpenApiDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultOpenApiDiffValidatorFactoryTest { @Autowired private DefaultOpenApiDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(5); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultOperationDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultOperationDiffValidatorFactoryTest { @Autowired private DefaultOperationDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(5); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultParameterDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultParameterDiffValidatorFactoryTest { @Autowired private DefaultParameterDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(8); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultPathItemDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathItemDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultPathItemDiffValidatorFactoryTest { @Autowired private DefaultPathItemDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(3); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultPathsDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathsDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultPathsDiffValidatorFactoryTest { @Autowired private DefaultPathsDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(1); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultRequestBodyDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultRequestBodyDiffValidatorFactoryTest { @Autowired private DefaultRequestBodyDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(2); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultResponseDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponseDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultResponseDiffValidatorFactoryTest { @Autowired private DefaultResponseDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(3); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultResponsesDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponsesDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultResponsesDiffValidatorFactoryTest { @Autowired private DefaultResponsesDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(1); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultSchemaDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultSchemaDiffValidatorFactoryTest { @Autowired private DefaultSchemaDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).hasSize(1); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultSecuritySchemeDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SecuritySchemeDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultSecuritySchemeDiffValidatorFactoryTest { @Autowired private DefaultSecuritySchemeDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultServerDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ServerDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultServerDiffValidatorFactoryTest { @Autowired private DefaultServerDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DefaultTagDiffValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.TagDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = DiffValidatorFactoryTestConfiguration.class) public class DefaultTagDiffValidatorFactoryTest { @Autowired private DefaultTagDiffValidatorFactory validatorFactory; @Test public void create() { List validators = validatorFactory.create(); assertThat(validators).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/factory/DiffValidatorFactoryTestConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.factory; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration @ComponentScan class DiffValidatorFactoryTestConfiguration { } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/OasCompatibilityTestBase.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators; import org.apache.servicecomb.toolkit.oasv.compatibility.CompatibilityCheckParser; import org.apache.servicecomb.toolkit.oasv.diffvalidation.test.OasDiffValidatorTestBase; import io.swagger.v3.parser.core.models.SwaggerParseResult; import io.swagger.v3.parser.util.ClasspathHelper; public class OasCompatibilityTestBase extends OasDiffValidatorTestBase { @Override protected SwaggerParseResult parseAbsolute(String classpath) { String content = ClasspathHelper.loadFileFromClasspath(classpath); return CompatibilityCheckParser.parseYaml(content); } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingAddNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = EncodingAddNotAllowedDiffValidatorTest.TestConfiguration.class) public class EncodingAddNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-encoding-add-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-encoding-add-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationRight( DiffViolationMessages.OP_ADD_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'bar'", ENCODING } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public EncodingDiffValidator encodingAddNotAllowedDiffValidator() { return new EncodingAddNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingAllowedReservedChangeDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = EncodingAllowedReservedChangeDiffValidatorTest.TestConfiguration.class) public class EncodingAllowedReservedChangeDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-encoding-allow-reserved-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-encoding-allow-reserved-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( DiffViolationMessages.FALSE_TO_TRUE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "allowReserved", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "allowReserved", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public EncodingDiffValidator encodingAllowedReservedChangeDiffValidator() { return new EncodingAllowedReservedChangeDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingContentTypeNotSameDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = EncodingContentTypeNotSameDiffValidatorTest.TestConfiguration.class) public class EncodingContentTypeNotSameDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-encoding-content-type-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-encoding-content-type-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "contentType", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "contentType", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public EncodingDiffValidator encodingContentTypeNotSameDiffValidator() { return new EncodingContentTypeNotSameDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingDelNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = EncodingDelNotAllowedDiffValidatorTest.TestConfiguration.class) public class EncodingDelNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-encoding-del-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-encoding-del-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationLeft( DiffViolationMessages.OP_DEL_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'bar'", ENCODING } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public EncodingDiffValidator encodingDelNotAllowedDiffValidator() { return new EncodingDelNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingExplodeNotSameDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = EncodingExplodeNotSameDiffValidatorTest.TestConfiguration.class) public class EncodingExplodeNotSameDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-encoding-explode-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-encoding-explode-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "explode", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "explode", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public EncodingDiffValidator encodingExplodeNotSameDiffValidator() { return new EncodingExplodeNotSameDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/EncodingStyleNotSameDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = EncodingStyleNotSameDiffValidatorTest.TestConfiguration.class) public class EncodingStyleNotSameDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-encoding-style-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-encoding-style-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "style", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "style", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public EncodingDiffValidator encodingStyleNotSameDiffValidator() { return new EncodingStyleNotSameDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/header/HeaderAddInRequestBodyNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.header; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = HeaderAddInRequestBodyNotAllowedDiffValidatorTest.TestConfiguration.class) public class HeaderAddInRequestBodyNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-header-add-in-request-body-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-header-add-in-request-body-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationRight( DiffViolationMessages.OP_ADD_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/x-www-form-urlencoded'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "headers.'X-Foo'", HEADER } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public HeaderDiffValidator headerAddInRequestBodyNotAllowed() { return new HeaderAddInRequestBodyNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/header/HeaderDelInResponseNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.header; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = HeaderDelInResponseNotAllowedDiffValidatorTest.TestConfiguration.class) public class HeaderDelInResponseNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-header-del-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-header-del-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationLeft( DiffViolationMessages.OP_DEL_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "headers.'X-Bar'", HEADER } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public HeaderDiffValidator headerDelInResponseNotAllowed() { return new HeaderDelInResponseNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/MediaTypeAddInParameterNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = MediaTypeAddInParameterNotAllowedDiffValidatorTest.TestConfiguration.class) public class MediaTypeAddInParameterNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-media-type-add-in-parameter-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-media-type-add-in-parameter-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationRight( DiffViolationMessages.OP_ADD_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "content.'application/json'", MEDIA_TYPE } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public MediaTypeDiffValidator mediaTypeAddInParameterNotAllowedDiffValidator() { return new MediaTypeAddInParameterNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/MediaTypeDelInParameterNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = MediaTypeDelInParameterNotAllowedDiffValidatorTest.TestConfiguration.class) public class MediaTypeDelInParameterNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-media-type-del-in-parameter-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-media-type-del-in-parameter-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationLeft( DiffViolationMessages.OP_DEL_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "content.'application/json'", MEDIA_TYPE } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public MediaTypeDiffValidator mediaTypeDelInParameterNotAllowedDiffValidator() { return new MediaTypeDelInParameterNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/MediaTypeDelInRequestBodyNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = MediaTypeDelInRequestBodyNotAllowedDiffValidatorTest.TestConfiguration.class) public class MediaTypeDelInRequestBodyNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-media-type-del-in-request-body-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-media-type-del-in-request-body-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationLeft( DiffViolationMessages.OP_DEL_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/json'", MEDIA_TYPE } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public MediaTypeDiffValidator mediaTypeDelInRequestBodyNotAllowedDiffValidator() { return new MediaTypeDelInRequestBodyNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/MediaTypeDelInResponseNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = MediaTypeDelInResponseNotAllowedDiffValidatorTest.TestConfiguration.class) public class MediaTypeDelInResponseNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-media-type-del-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-media-type-del-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationLeft( DiffViolationMessages.OP_DEL_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public MediaTypeDiffValidator mediaTypeDelInResponseNotAllowedDiffValidator() { return new MediaTypeDelInResponseNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/operation/OperationDeleteNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.operation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = OperationDeleteNotAllowedDiffValidatorTest.TestConfiguration.class) public class OperationDeleteNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-operation-delete-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-operation-delete-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationLeft( DiffViolationMessages.OP_DEL_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public OperationDiffValidator operationDeleteNotAllowedDiffValidator() { return new OperationDeleteNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/operation/OperationIdNotSameDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.operation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = OperationIdNotSameDiffValidatorTest.TestConfiguration.class) public class OperationIdNotSameDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-operation-id-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-operation-id-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "operationId", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public OperationDiffValidator operationIdNotSameDiffValidator() { return new OperationIdNotSameDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterAddDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter.ParameterAddDiffValidator.VIOLATION_MESSAGE; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ParameterAddDiffValidatorTest.TestConfiguration.class) public class ParameterAddDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-parameter-add-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-parameter-add-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationRight( "[name=bar,in=query]:" + VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "required", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public ParameterDiffValidator parameterAddDiffValidator() { return new ParameterAddDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterAllowEmptyValueChangeDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ParameterAllowEmptyValueChangeDiffValidatorTest.TestConfiguration.class) public class ParameterAllowEmptyValueChangeDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-parameter-allow-empty-value-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-parameter-allow-empty-value-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( "[name=limit4,in=query]:" + DiffViolationMessages.FALSE_TO_TRUE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "allowEmptyValue", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[2]", PARAMETER, "allowEmptyValue", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public ParameterDiffValidator parameterAllowEmptyValueChangeDiffValidator() { return new ParameterAllowEmptyValueChangeDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterAllowReservedChangeDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ParameterAllowReservedChangeDiffValidatorTest.TestConfiguration.class) public class ParameterAllowReservedChangeDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { } @Test public void validateBroken() { OpenAPI leftOpenAPI = loadRelative("petstore-parameter-allow-reserved-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-parameter-allow-reserved-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( "[name=limit4,in=query]:" + DiffViolationMessages.FALSE_TO_TRUE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "allowReserved", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[2]", PARAMETER, "allowReserved", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public ParameterDiffValidator parameterAllowReservedChangeDiffValidator() { return new ParameterAllowReservedChangeDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterExplodeNotSameDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ParameterExplodeNotSameDiffValidatorTest.TestConfiguration.class) public class ParameterExplodeNotSameDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-parameter-explode-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-parameter-explode-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( "[name=limit,in=query]:" + DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "explode", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "explode", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public ParameterDiffValidator parameterExplodeNotSameDiffValidator() { return new ParameterExplodeNotSameDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterRequiredChangeDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ParameterRequiredChangeDiffValidatorTest.TestConfiguration.class) public class ParameterRequiredChangeDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-parameter-required-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-parameter-required-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( "[name=limit,in=query]:" + DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "required", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "required", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public ParameterDiffValidator parameterRequiredChangeDiffValidator() { return new ParameterRequiredChangeDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/ParameterStyleNotSameDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ParameterStyleNotSameDiffValidatorTest.TestConfiguration.class) public class ParameterStyleNotSameDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-parameter-style-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-parameter-style-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation( "[name=limit,in=query]:" + DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "style", null }, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "style", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public ParameterDiffValidator parameterStyleNotSameDiffValidator() { return new ParameterStyleNotSameDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/pathitem/PathItemDeleteNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.pathitem; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathItemDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATHS; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATH_ITEM; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = PathItemDeleteNotAllowedDiffValidatorTest.TestConfiguration.class) public class PathItemDeleteNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-path-item-delete-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-path-item-delete-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationLeft( DiffViolationMessages.OP_DEL_FORBIDDEN, new Object[] { "paths", PATHS, "/pets/{petId}", PATH_ITEM } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public PathItemDiffValidator pathItemDeleteNotAllowedValidator() { return new PathItemDeleteNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/requestbody/RequestBodyRequiredChangeDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.requestbody; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = RequestBodyRequiredChangeDiffValidatorTest.TestConfiguration.class) public class RequestBodyRequiredChangeDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-request-body-required-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-request-body-required-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "required", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public RequestBodyDiffValidator requestBodyRequiredChangeDiffValidator() { return new RequestBodyRequiredChangeDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/response/ResponseAddNotAllowedDiffValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponseDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; public class ResponseAddNotAllowedDiffValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-response-add-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-response-add-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationRight( DiffViolationMessages.OP_ADD_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "302", RESPONSE } ), createViolationRight( DiffViolationMessages.OP_ADD_FORBIDDEN, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "default", RESPONSE } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public ResponseDiffValidator responseAddNotAllowedDiffValidator() { return new ResponseAddNotAllowedDiffValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaDiscriminatorChangeValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaDiscriminatorChangeValidatorTest.TestConfiguration.class) public class SchemaDiscriminatorChangeValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-discriminator-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-discriminator-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "discriminator", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "discriminator", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "discriminator", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaDiscriminatorChangeValidator() { return new SchemaDiscriminatorChangeValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaReadOnlyChangeValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaReadOnlyChangeValidatorTest.TestConfiguration.class) public class SchemaReadOnlyChangeValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-read-only-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-read-only-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "readOnly", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "readOnly", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "readOnly", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaReadOnlyChangeValidator() { return new SchemaReadOnlyChangeValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaWriteOnlyChangeValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaWriteOnlyChangeValidatorTest.TestConfiguration.class) public class SchemaWriteOnlyChangeValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-write-only-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-write-only-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "writeOnly", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "writeOnly", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "writeOnly", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaWriteOnlyChangeValidator() { return new SchemaWriteOnlyChangeValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/SchemaXmlChangeValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaXmlChangeValidatorTest.TestConfiguration.class) public class SchemaXmlChangeValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-xml-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-xml-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "xml", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "xml", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_EQ_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "xml", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaXmlChangeValidator() { return new SchemaXmlChangeValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaEnumChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.MEDIA_TYPE; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.OPERATION; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PARAMETER; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATHS; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATH_ITEM; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.REQUEST_BODY; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import io.swagger.v3.oas.models.OpenAPI; @ContextConfiguration(classes = SchemaEnumChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaEnumChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-enum-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-enum-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( SchemaEnumChangeInRequestValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "enum", null } ), createViolationBoth( SchemaEnumChangeInRequestValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "enum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaEnumChangeInRequestValidator() { return new SchemaEnumChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaExclusiveMaximumChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaExclusiveMaximumChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaExclusiveMaximumChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-exclusive-maximum-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-exclusive-maximum-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "exclusiveMaximum", null } ), createViolationBoth( DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "exclusiveMaximum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaExclusiveMaximumChangeInRequestValidator() { return new SchemaExclusiveMaximumChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaExclusiveMinimumChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaExclusiveMinimumChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaExclusiveMinimumChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-exclusive-minimum-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-exclusive-minimum-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "exclusiveMinimum", null } ), createViolationBoth( DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "exclusiveMinimum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaExclusiveMinimumChangeInRequestValidator() { return new SchemaExclusiveMinimumChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMaxItemsChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMaxItemsChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMaxItemsChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-max-items-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-max-items-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxItems", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxItems", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMaxItemsChangeInRequestValidator() { return new SchemaMaxItemsChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMaxLengthChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMaxLengthChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMaxLengthChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-max-length-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-max-length-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxLength", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxLength", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMaxLengthChangeInRequestValidator() { return new SchemaMaxLengthChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMaxPropertiesChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMaxPropertiesChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMaxPropertiesChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-max-properties-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-max-properties-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxProperties", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxProperties", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMaxPropertiesChangeInRequestValidator() { return new SchemaMaxPropertiesChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMaximumChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMaximumChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMaximumChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-maximum-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-maximum-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maximum", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maximum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMaximumChangeInRequestValidator() { return new SchemaMaximumChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMinItemsChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMinItemsChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMinItemsChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-min-items-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-min-items-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minItems", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minItems", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMinItemsChangeInRequestValidator() { return new SchemaMinItemsChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMinLengthChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMinLengthChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMinLengthChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-min-length-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-min-length-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minLength", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minLength", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMinLengthChangeInRequestValidator() { return new SchemaMinLengthChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMinPropertiesChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMinPropertiesChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMinPropertiesChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-min-properties-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-min-properties-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minProperties", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minProperties", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMinPropertiesChangeInRequestValidator() { return new SchemaMinPropertiesChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMinimumChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMinimumChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMinimumChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-minimum-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-minimum-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minimum", null } ), createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minimum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMinimumChangeInRequestValidator() { return new SchemaMinimumChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaMultipleOfChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMultipleOfChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaMultipleOfChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-multiple-of-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-multiple-of-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( SchemaMultipleOfChangeInRequestValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "multipleOf", null } ), createViolationBoth( SchemaMultipleOfChangeInRequestValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "multipleOf", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMultipleOfChangeValidator() { return new SchemaMultipleOfChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaNullableChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaNullableChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaNullableChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-nullable-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-nullable-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.FALSE_TO_TRUE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "nullable", null } ), createViolationBoth( DiffViolationMessages.FALSE_TO_TRUE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "nullable", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaNullableChangeInRequestValidator() { return new SchemaNullableChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaRequiredChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaRequiredChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaRequiredChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-required-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-required-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( SchemaRequiredChangeInRequestValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "required", null } ), createViolationBoth( SchemaRequiredChangeInRequestValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "required", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaRequiredChangeInRequestValidator() { return new SchemaRequiredChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaTypeFormatChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaTypeFormatChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaTypeFormatChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-type-format-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-type-format-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( "the change (type=integer,format=null)->(type=string,format=null) is not allowed", new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA } ), createViolationBoth( "the change (type=integer,format=null)->(type=string,format=null) is not allowed", new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaTypeFormatInRequestCompareValidator() { return new SchemaTypeFormatChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/SchemaUniqueItemsChangeInRequestValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaUniqueItemsChangeInRequestValidatorTest.TestConfiguration.class) public class SchemaUniqueItemsChangeInRequestValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-unique-items-in-request-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-unique-items-in-request-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'foo'", SCHEMA, "uniqueItems", null } ), createViolationBoth( DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "requestBody", REQUEST_BODY, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "uniqueItems", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaUniqueItemsChangeInRequestValidator() { return new SchemaUniqueItemsChangeInRequestValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaEnumChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaEnumChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaEnumChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-enum-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-enum-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( SchemaEnumChangeInResponseValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "enum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaEnumChangeInResponseValidator() { return new SchemaEnumChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaExclusiveMaximumChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaExclusiveMaximumChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaExclusiveMaximumChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-exclusive-maximum-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-exclusive-maximum-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.FALSE_TO_TRUE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "exclusiveMaximum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaExclusiveMaximumChangeInResponseValidator() { return new SchemaExclusiveMaximumChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaExclusiveMinimumChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaExclusiveMinimumChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaExclusiveMinimumChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-exclusive-minimum-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-exclusive-minimum-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.FALSE_TO_TRUE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "exclusiveMinimum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaExclusiveMinimumChangeInResponseValidator() { return new SchemaExclusiveMinimumChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMaxItemsChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMaxItemsChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMaxItemsChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-max-items-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-max-items-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxItems", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMaxItemsChangeInResponseValidator() { return new SchemaMaxItemsChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMaxLengthChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMaxLengthChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMaxLengthChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-max-length-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-max-length-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxLength", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMaxLengthChangeInResponseValidator() { return new SchemaMaxLengthChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMaxPropertiesChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMaxPropertiesChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMaxPropertiesChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-max-properties-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-max-properties-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maxProperties", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMaxPropertiesChangeInResponseValidator() { return new SchemaMaxPropertiesChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMaximumChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMaximumChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMaximumChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-maximum-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-maximum-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_LTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "maximum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMaximumChangeInResponseValidator() { return new SchemaMaximumChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMinItemsChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMinItemsChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMinItemsChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-min-items-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-min-items-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minItems", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMinItemsChangeInResponseValidator() { return new SchemaMinItemsChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMinLengthChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMinLengthChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMinLengthChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-min-length-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-min-length-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minLength", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMinLengthChangeInResponseValidator() { return new SchemaMinLengthChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMinPropertiesChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMinPropertiesChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMinPropertiesChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-min-properties-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-min-properties-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minProperties", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMinPropertiesChangeInResponseValidator() { return new SchemaMinPropertiesChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMinimumChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMinimumChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMinimumChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-minimum-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-minimum-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.NEW_NOT_GTE_OLD, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "minimum", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMinimumChangeInResponseValidator() { return new SchemaMinimumChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaMultipleOfChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaMultipleOfChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaMultipleOfChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-multiple-of-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-multiple-of-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( SchemaMultipleOfChangeInResponseValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/json'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "multipleOf", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaMultipleOfChangeValidator() { return new SchemaMultipleOfChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaNullableChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaNullableChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaNullableChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-nullable-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-nullable-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.TRUE_TO_FALSE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "nullable", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaNullableChangeInResponseValidator() { return new SchemaNullableChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaRequiredChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaRequiredChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaRequiredChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-required-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-required-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( SchemaRequiredChangeInResponseValidator.VIOLATION_MESSAGE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "required", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaRequiredChangeInResponseValidator() { return new SchemaRequiredChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaTypeFormatChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaTypeFormatChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaTypeFormatChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-type-format-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-type-format-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( "the change (type=integer,format=int32)->(type=integer,format=int64) is not allowed", new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaTypeFormatInResponseCompareValidator() { return new SchemaTypeFormatChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/SchemaUniqueItemsChangeInResponseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DiffViolationMessages; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.OasCompatibilityTestBase; import io.swagger.v3.oas.models.OpenAPI; import org.junit.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = SchemaUniqueItemsChangeInResponseValidatorTest.TestConfiguration.class) public class SchemaUniqueItemsChangeInResponseValidatorTest extends OasCompatibilityTestBase { @Test public void validate() { OpenAPI leftOpenAPI = loadRelative("petstore-schema-unique-items-in-response-a.yaml"); OpenAPI rightOpenAPI = loadRelative("petstore-schema-unique-items-in-response-b.yaml"); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolationBoth( DiffViolationMessages.FALSE_TO_TRUE, new Object[] { "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/xml'", MEDIA_TYPE, "schema", SCHEMA, "properties.'foo'", SCHEMA, "uniqueItems", null } ) ); } @Configuration @Import(OasDiffValidatorsSkeletonConfiguration.class) public static class TestConfiguration { @Bean public SchemaCompareValidator schemaUniqueItemsChangeInResponseValidator() { return new SchemaUniqueItemsChangeInResponseValidator(); } } } ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/logback-test.xml ================================================ ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/parser-test.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Pet petstore paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-add-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-add-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' bar: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-allow-reserved-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' allowReserved: true bar: contentType: 'application/octet-stream' allowReserved: false responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-allow-reserved-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' allowReserved: false bar: contentType: 'application/octet-stream' allowReserved: true responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-content-type-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-content-type-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'text/plain' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-del-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' bar: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-del-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-explode-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' explode: true responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-explode-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' explode: false responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-style-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'text/plain' style: form responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/encoding/petstore-encoding-style-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'text/plain' style: spaceDelimited responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/header/petstore-header-add-in-request-body-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/header/petstore-header-add-in-request-body-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' headers: X-Foo: schema: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/header/petstore-header-del-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets headers: X-Foo: schema: type: string X-Bar: schema: type: string post: summary: List all pets operationId: foo responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/header/petstore-header-del-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets headers: X-Foo: schema: type: string post: summary: List all pets operationId: foo responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/petstore-media-type-add-in-parameter-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo in: query responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/petstore-media-type-add-in-parameter-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo in: query content: application/json: schema: type: string responses: '200': description: A paged array of pets post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/petstore-media-type-del-in-parameter-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo in: query content: application/json: schema: type: string responses: '200': description: A paged array of pets post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/petstore-media-type-del-in-parameter-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo in: query responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/petstore-media-type-del-in-request-body-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets requestBody: content: application/json: schema: type: string application/xml: schema: type: string responses: '200': description: A paged array of pets post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/petstore-media-type-del-in-request-body-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets requestBody: content: application/xml: schema: type: string responses: '200': description: A paged array of pets post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/petstore-media-type-del-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/json: schema: type: string application/xml: schema: type: string post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/mediatype/petstore-media-type-del-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/json: schema: type: string post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/operation/petstore-operation-delete-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/operation/petstore-operation-delete-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/operation/petstore-operation-id-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/operation/petstore-operation-id-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-add-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit in: query required: false responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-add-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: parameters: - name: foo in: query - name: bar in: query required: true get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit in: query required: false responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-allow-empty-value-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit3 in: query allowEmptyValue: false - name: limit4 in: query allowEmptyValue: true responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-allow-empty-value-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: foo in: query - name: limit3 in: query allowEmptyValue: true - name: limit4 in: query allowEmptyValue: false responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-allow-reserved-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit3 in: query allowReserved: false - name: limit4 in: query allowReserved: true responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-allow-reserved-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: foo in: query - name: limit3 in: query allowReserved: true - name: limit4 in: query allowReserved: false responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-explode-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit in: query explode: true - name: limit2 in: query explode: true responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-explode-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: foo in: query - name: limit in: query explode: false - name: limit2 in: query explode: true responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-required-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit in: query required: false - name: limit2 in: query required: true responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-required-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: foo in: query - name: limit in: query required: true - name: limit2 in: query required: false responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-style-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit in: query style: simple - name: limit2 in: query style: form responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/parameter/petstore-parameter-style-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: foo in: query - name: limit in: query style: form - name: limit2 in: query style: form responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/pathitem/petstore-path-item-delete-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/pathitem/petstore-path-item-delete-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets /pets/{PetId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: PetId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/requestbody/petstore-request-body-required-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets requestBody: required: false content: application/json: schema: type: string responses: '200': description: A paged array of pets post: summary: List all pets operationId: bar requestBody: required: true content: application/json: schema: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/requestbody/petstore-request-body-required-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets requestBody: required: true content: application/json: schema: type: string responses: '200': description: A paged array of pets post: summary: List all pets operationId: bar requestBody: required: false content: application/json: schema: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/response/petstore-response-add-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/response/petstore-response-add-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets '302': description: foo default: description: bar post: summary: List all pets operationId: bar responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/petstore-schema-discriminator-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: object properties: petType: type: string petId: type: string discriminator: propertyName: petType - name: foo2 in: query schema: type: object properties: foo: type: object properties: petType: type: string petId: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: object properties: petType: type: string petId: type: string discriminator: propertyName: petType application/json: schema: type: object properties: foo: type: object properties: petType: type: string petId: type: string responses: '200': description: A paged array of pets content: application/xml: schema: properties: foo: type: object properties: petType: type: string petId: type: string discriminator: propertyName: petType application/json: schema: properties: foo: type: object properties: petType: type: string petId: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/petstore-schema-discriminator-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: object properties: petType: type: string petId: type: string discriminator: propertyName: petId - name: foo2 in: query schema: type: object properties: foo: type: object properties: petType: type: string petId: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: object properties: petType: type: string petId: type: string discriminator: propertyName: petId application/json: schema: type: object properties: foo: type: object properties: petType: type: string petId: type: string responses: '200': description: A paged array of pets content: application/xml: schema: properties: foo: type: object properties: petType: type: string petId: type: string discriminator: propertyName: petId application/json: schema: properties: foo: type: object properties: petType: type: string petId: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/petstore-schema-read-only-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer readOnly: true - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer readOnly: true application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets content: application/xml: schema: properties: foo: type: integer readOnly: true application/json: schema: properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/petstore-schema-read-only-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer readOnly: false - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer readOnly: false application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets content: application/xml: schema: properties: foo: type: integer readOnly: false application/json: schema: properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/petstore-schema-write-only-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer writeOnly: true - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer writeOnly: true application/json: schema: type: object properties: foo: type: integer writeOnly: true responses: '200': description: A paged array of pets content: application/xml: schema: properties: foo: type: integer writeOnly: true application/json: schema: properties: foo: type: integer writeOnly: true ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/petstore-schema-write-only-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer writeOnly: false - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer writeOnly: false application/json: schema: type: object properties: foo: type: integer writeOnly: true responses: '200': description: A paged array of pets content: application/xml: schema: properties: foo: type: integer writeOnly: false application/json: schema: properties: foo: type: integer writeOnly: true ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/petstore-schema-xml-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets content: application/xml: schema: properties: foo: type: string application/json: schema: properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/petstore-schema-xml-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string xml: name: foo - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string xml: name: foo application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets content: application/xml: schema: properties: foo: type: string xml: name: foo application/json: schema: properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-enum-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string enum: - a - b - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string enum: - a - b application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-enum-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string enum: - a - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string enum: - a application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-exclusive-maximum-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer maximum: 1 exclusiveMaximum: false - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer maximum: 1 exclusiveMaximum: false application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-exclusive-maximum-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer maximum: 1 exclusiveMaximum: true - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer maximum: 1 exclusiveMaximum: true application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-exclusive-minimum-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer minimum: 1 exclusiveMinimum: false - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer minimum: 1 exclusiveMinimum: false application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-exclusive-minimum-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer minimum: 1 exclusiveMinimum: true - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer minimum: 1 exclusiveMinimum: true application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-max-items-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: array items: type: string maxItems: 1 - name: foo2 in: query schema: type: object properties: foo: type: array items: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: array items: type: string maxItems: 1 application/json: schema: type: object properties: foo: type: array items: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-max-items-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: array items: type: string maxItems: 0 - name: foo2 in: query schema: type: object properties: foo: type: array items: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: array items: type: string maxItems: 0 application/json: schema: type: object properties: foo: type: array items: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-max-length-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string maxLength: 1 - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string maxLength: 1 application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-max-length-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string maxLength: 0 - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string maxLength: 0 application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-max-properties-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: object maxProperties: 1 - name: foo2 in: query schema: type: object properties: foo: type: object requestBody: content: application/xml: schema: type: object properties: foo: type: object maxProperties: 1 application/json: schema: type: object properties: foo: type: object responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-max-properties-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: object maxProperties: 0 - name: foo2 in: query schema: type: object properties: foo: type: object requestBody: content: application/xml: schema: type: object properties: foo: type: object maxProperties: 0 application/json: schema: type: object properties: foo: type: object responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-maximum-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer maximum: 1 - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer maximum: 1 application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-maximum-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer maximum: 0 - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer maximum: 0 application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-min-items-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: array items: type: string minItems: 1 - name: foo2 in: query schema: type: object properties: foo: type: array items: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: array items: type: string minItems: 1 application/json: schema: type: object properties: foo: type: array items: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-min-items-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: array items: type: string minItems: 2 - name: foo2 in: query schema: type: object properties: foo: type: array items: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: array items: type: string minItems: 2 application/json: schema: type: object properties: foo: type: array items: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-min-length-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string minLength: 1 - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string minLength: 1 application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-min-length-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string minLength: 2 - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string minLength: 2 application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-min-properties-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: object minProperties: 1 - name: foo2 in: query schema: type: object properties: foo: type: object requestBody: content: application/xml: schema: type: object properties: foo: type: object minProperties: 1 application/json: schema: type: object properties: foo: type: object responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-min-properties-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: object minProperties: 2 - name: foo2 in: query schema: type: object properties: foo: type: object requestBody: content: application/xml: schema: type: object properties: foo: type: object minProperties: 2 application/json: schema: type: object properties: foo: type: object responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-minimum-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer minimum: 1 - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer minimum: 1 application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-minimum-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer minimum: 2 - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer minimum: 2 application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-multiple-of-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer multipleOf: 6 - name: foo2 in: query schema: type: object properties: foo: type: integer multipleOf: 6 requestBody: content: application/xml: schema: type: object properties: foo: type: integer multipleOf: 6 application/json: schema: type: object properties: foo: type: integer multipleOf: 6 responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-multiple-of-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer multipleOf: 4 - name: foo2 in: query schema: type: object properties: foo: type: integer multipleOf: 2 requestBody: content: application/xml: schema: type: object properties: foo: type: integer multipleOf: 4 application/json: schema: type: object properties: foo: type: integer multipleOf: 2 responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-nullable-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string nullable: true bar: type: string - name: foo2 in: query schema: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: string nullable: true application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-nullable-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string nullable: false bar: type: string nullable: true - name: foo2 in: query schema: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: string nullable: false application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-required-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-required-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string required: - foo - name: foo2 in: query schema: type: object properties: foo: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: string required: - foo application/json: schema: type: object properties: foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-type-format-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: integer - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: integer application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-type-format-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: string - name: foo2 in: query schema: type: object properties: foo: type: integer requestBody: content: application/xml: schema: type: object properties: foo: type: string application/json: schema: type: object properties: foo: type: integer responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-unique-items-in-request-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: array items: type: string uniqueItems: false - name: foo2 in: query schema: type: object properties: foo: type: array items: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: array items: type: string uniqueItems: false application/json: schema: type: object properties: foo: type: array items: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/request/petstore-schema-unique-items-in-request-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets parameters: - name: foo1 in: query schema: type: object properties: foo: type: array items: type: string uniqueItems: true - name: foo2 in: query schema: type: object properties: foo: type: array items: type: string requestBody: content: application/xml: schema: type: object properties: foo: type: array items: type: string uniqueItems: true application/json: schema: type: object properties: foo: type: array items: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-enum-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string enum: - a application/json: schema: type: object properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-enum-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string enum: - a - b application/json: schema: type: object properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-exclusive-maximum-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer maximum: 0 exclusiveMaximum: true application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-exclusive-maximum-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer maximum: 0 exclusiveMaximum: false application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-exclusive-minimum-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer minimum: 0 exclusiveMinimum: true application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-exclusive-minimum-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer minimum: 0 exclusiveMinimum: false application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-max-items-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: array items: type: string maxItems: 1 application/json: schema: type: object properties: foo: type: array items: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-max-items-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: array items: type: string maxItems: 2 application/json: schema: type: object properties: foo: type: array items: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-max-length-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string maxLength: 1 application/json: schema: type: object properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-max-length-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string maxLength: 2 application/json: schema: type: object properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-max-properties-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: object maxProperties: 1 application/json: schema: type: object properties: foo: type: object ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-max-properties-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: object maxProperties: 2 application/json: schema: type: object properties: foo: type: object ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-maximum-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer maximum: 0 application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-maximum-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer maximum: 1 application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-min-items-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: array items: type: string minItems: 1 application/json: schema: type: object properties: foo: type: array items: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-min-items-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: array items: type: string minItems: 0 application/json: schema: type: object properties: foo: type: array items: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-min-length-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string minLength: 1 application/json: schema: type: object properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-min-length-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string minLength: 0 application/json: schema: type: object properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-min-properties-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: object minProperties: 1 application/json: schema: type: object properties: foo: type: object ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-min-properties-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: object minProperties: 0 application/json: schema: type: object properties: foo: type: object ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-minimum-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer minimum: 1 application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-minimum-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer minimum: 0 application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-multiple-of-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/json: schema: type: object properties: foo: type: integer multipleOf: 3 application/xml: schema: type: object properties: foo: type: integer multipleOf: 3 ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-multiple-of-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/json: schema: type: object properties: foo: type: integer multipleOf: 4 application/xml: schema: type: object properties: foo: type: integer multipleOf: 6 ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-nullable-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string nullable: false application/json: schema: type: object properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-nullable-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string nullable: true application/json: schema: type: object properties: foo: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-required-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string required: - foo application/json: schema: type: object properties: foo: type: string required: - foo ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-required-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: string application/json: schema: type: object properties: foo: type: string required: - foo ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-type-format-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer format: int32 application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-type-format-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: integer format: int64 application/json: schema: type: object properties: foo: type: integer ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-unique-items-in-response-a.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: array items: type: string uniqueItems: true application/json: schema: type: object properties: foo: type: array items: type: string ================================================ FILE: oas-validator/oas-validator-compatibility/src/test/resources/org/apache/servicecomb/toolkit/oasv/compatibility/validators/schema/response/petstore-schema-unique-items-in-response-b.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets content: application/xml: schema: type: object properties: foo: type: array items: type: string uniqueItems: false application/json: schema: type: object properties: foo: type: array items: type: string ================================================ FILE: oas-validator/oas-validator-compatibility-spring/pom.xml ================================================ org.apache.servicecomb.toolkit oas-validator-parent 0.3.0-SNAPSHOT ../pom.xml 4.0.0 oas-validator-compatibility-spring org.apache.servicecomb.toolkit oas-validator-compatibility org.apache.servicecomb.toolkit oas-validator-core-spring org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-test test org.apache.maven.plugins maven-surefire-plugin org.apache.maven.plugins maven-surefire-report-plugin ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/EncodingDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.encoding.*; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class EncodingDiffValidatorsConfiguration { @Bean public EncodingDiffValidator encodingAddNotAllowedDiffValidator() { return new EncodingAddNotAllowedDiffValidator(); } @Bean public EncodingDiffValidator encodingDelNotAllowedDiffValidator() { return new EncodingDelNotAllowedDiffValidator(); } @Bean public EncodingDiffValidator encodingAllowedReservedChangeDiffValidator() { return new EncodingAllowedReservedChangeDiffValidator(); } @Bean public EncodingDiffValidator encodingContentTypeNotSameDiffValidator() { return new EncodingContentTypeNotSameDiffValidator(); } @Bean public EncodingDiffValidator encodingExplodeNotSameDiffValidator() { return new EncodingExplodeNotSameDiffValidator(); } @Bean public EncodingDiffValidator encodingStyleNotSameDiffValidator() { return new EncodingStyleNotSameDiffValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/HeaderDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.header.HeaderAddInRequestBodyNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.header.HeaderDelInResponseNotAllowedDiffValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class HeaderDiffValidatorsConfiguration { @Bean public HeaderDiffValidator headerAddInRequestBodyNotAllowedDiffValidator() { return new HeaderAddInRequestBodyNotAllowedDiffValidator(); } @Bean public HeaderDiffValidator headerDelInResponseNotAllowedDiffValidator() { return new HeaderDelInResponseNotAllowedDiffValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/MediaTypeDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype.MediaTypeAddInParameterNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype.MediaTypeDelInParameterNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype.MediaTypeDelInRequestBodyNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.mediatype.MediaTypeDelInResponseNotAllowedDiffValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class MediaTypeDiffValidatorsConfiguration { @Bean public MediaTypeDiffValidator mediaTypeAddInParameterNotAllowedDiffValidator() { return new MediaTypeAddInParameterNotAllowedDiffValidator(); } @Bean public MediaTypeDiffValidator mediaTypeDelInParameterNotAllowedDiffValidator() { return new MediaTypeDelInParameterNotAllowedDiffValidator(); } @Bean public MediaTypeDiffValidator mediaTypeDelInRequestBodyNotAllowedDiffValidator() { return new MediaTypeDelInRequestBodyNotAllowedDiffValidator(); } @Bean public MediaTypeDiffValidator mediaTypeDelInResponseNotAllowedDiffValidator() { return new MediaTypeDelInResponseNotAllowedDiffValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/OperationDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.operation.OperationDeleteNotAllowedDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.operation.OperationIdNotSameDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class OperationDiffValidatorsConfiguration { @Bean public OperationDiffValidator operationDeleteNotAllowedDiffValidator() { return new OperationDeleteNotAllowedDiffValidator(); } @Bean public OperationDiffValidator operationIdNotSameDiffValidator() { return new OperationIdNotSameDiffValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/ParameterDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.parameter.*; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class ParameterDiffValidatorsConfiguration { @Bean public ParameterDiffValidator parameterAddDiffValidator() { return new ParameterAddDiffValidator(); } @Bean public ParameterDiffValidator parameterRequiredChangeDiffValidator() { return new ParameterRequiredChangeDiffValidator(); } @Bean public ParameterDiffValidator parameterAllowEmptyValueChangeDiffValidator() { return new ParameterAllowEmptyValueChangeDiffValidator(); } @Bean public ParameterDiffValidator parameterStyleNotSameDiffValidator() { return new ParameterStyleNotSameDiffValidator(); } @Bean public ParameterDiffValidator parameterExplodeNotSameDiffValidator() { return new ParameterExplodeNotSameDiffValidator(); } @Bean public ParameterDiffValidator parameterAllowReservedChangeDiffValidator() { return new ParameterAllowReservedChangeDiffValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/PathItemDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathItemDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.pathitem.PathItemDeleteNotAllowedDiffValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class PathItemDiffValidatorsConfiguration { @Bean public PathItemDiffValidator pathItemDeleteNotAllowedValidator() { return new PathItemDeleteNotAllowedDiffValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/RequestBodyDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.requestbody.RequestBodyRequiredChangeDiffValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class RequestBodyDiffValidatorsConfiguration { @Bean public RequestBodyDiffValidator requestBodyRequiredChangeDiffValidator() { return new RequestBodyRequiredChangeDiffValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/ResponseDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponseDiffValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.response.ResponseAddNotAllowedDiffValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class ResponseDiffValidatorsConfiguration { @Bean public ResponseDiffValidator responseAddNotAllowedDiffValidator() { return new ResponseAddNotAllowedDiffValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/SchemaDiffValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.request.*; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.response.*; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaDiscriminatorChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaReadOnlyChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaWriteOnlyChangeValidator; import org.apache.servicecomb.toolkit.oasv.compatibility.validators.schema.SchemaXmlChangeValidator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class SchemaDiffValidatorsConfiguration { @Bean public SchemaCompareValidator schemaTypeFormatInRequestCompareValidator() { return new SchemaTypeFormatChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaTypeFormatInResponseCompareValidator() { return new SchemaTypeFormatChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMultipleOfChangeInRequestValidator() { return new SchemaMultipleOfChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaMaximumChangeInResponseValidator() { return new SchemaMaximumChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMaximumChangeInRequestValidator() { return new SchemaMaximumChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaExclusiveMinimumChangeInRequestValidator() { return new SchemaExclusiveMinimumChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaExclusiveMaximumChangeInRequestValidator() { return new SchemaExclusiveMaximumChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaExclusiveMaximumChangeInResponseValidator() { return new SchemaExclusiveMaximumChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaExclusiveMinimumChangeInResponseValidator() { return new SchemaExclusiveMinimumChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMaxItemsChangeInRequestValidator() { return new SchemaMaxItemsChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaMaxLengthChangeInRequestValidator() { return new SchemaMaxLengthChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaMaxPropertiesChangeInRequestValidator() { return new SchemaMaxPropertiesChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaMinimumChangeInRequestValidator() { return new SchemaMinimumChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaMinItemsChangeInRequestValidator() { return new SchemaMinItemsChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaMinLengthChangeInRequestValidator() { return new SchemaMinLengthChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaMinPropertiesChangeInRequestValidator() { return new SchemaMinPropertiesChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaUniqueItemsChangeInRequestValidator() { return new SchemaUniqueItemsChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaRequiredChangeInRequestValidator() { return new SchemaRequiredChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaEnumChangeInRequestValidator() { return new SchemaEnumChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaNullableChangeInRequestValidator() { return new SchemaNullableChangeInRequestValidator(); } @Bean public SchemaCompareValidator schemaReadOnlyChangeValidator() { return new SchemaReadOnlyChangeValidator(); } @Bean public SchemaCompareValidator schemaWriteOnlyChangeValidator() { return new SchemaWriteOnlyChangeValidator(); } @Bean public SchemaCompareValidator schemaXmlChangeValidator() { return new SchemaXmlChangeValidator(); } @Bean public SchemaCompareValidator schemaDiscriminatorChangeValidator() { return new SchemaDiscriminatorChangeValidator(); } @Bean public SchemaCompareValidator schemaMultipleOfChangeInResponseValidator() { return new SchemaMultipleOfChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMaxItemsChangeInResponseValidator() { return new SchemaMaxItemsChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMaxLengthChangeInResponseValidator() { return new SchemaMaxLengthChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMaxPropertiesChangeInResponseValidator() { return new SchemaMaxPropertiesChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMinimumChangeInResponseValidator() { return new SchemaMinimumChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMinItemsChangeInResponseValidator() { return new SchemaMinItemsChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMinLengthChangeInResponseValidator() { return new SchemaMinLengthChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaMinPropertiesChangeInResponseValidator() { return new SchemaMinPropertiesChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaUniqueItemsChangeInResponseValidator() { return new SchemaUniqueItemsChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaRequiredChangeInResponseValidator() { return new SchemaRequiredChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaEnumChangeInResponseValidator() { return new SchemaEnumChangeInResponseValidator(); } @Bean public SchemaCompareValidator schemaNullableChangeInResponseValidator() { return new SchemaNullableChangeInResponseValidator(); } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/main/resources/META-INF/spring.factories ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.apache.servicecomb.toolkit.oasv.compatibility.config.EncodingDiffValidatorsConfiguration,\ org.apache.servicecomb.toolkit.oasv.compatibility.config.HeaderDiffValidatorsConfiguration,\ org.apache.servicecomb.toolkit.oasv.compatibility.config.MediaTypeDiffValidatorsConfiguration,\ org.apache.servicecomb.toolkit.oasv.compatibility.config.OperationDiffValidatorsConfiguration,\ org.apache.servicecomb.toolkit.oasv.compatibility.config.ParameterDiffValidatorsConfiguration,\ org.apache.servicecomb.toolkit.oasv.compatibility.config.PathItemDiffValidatorsConfiguration,\ org.apache.servicecomb.toolkit.oasv.compatibility.config.RequestBodyDiffValidatorsConfiguration,\ org.apache.servicecomb.toolkit.oasv.compatibility.config.ResponseDiffValidatorsConfiguration,\ org.apache.servicecomb.toolkit.oasv.compatibility.config.SchemaDiffValidatorsConfiguration ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/test/java/org/apache/servicecomb/toolkit/oasv/compatibility/config/ValidatorConfigurationsTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.compatibility.config; import static org.assertj.core.api.Assertions.assertThat; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathItemDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponseDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaDiffValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.BeansException; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest @SpringBootApplication public class ValidatorConfigurationsTest implements ApplicationContextAware { private ApplicationContext applicationContext; @Test public void testConfigurations() { assertThat(applicationContext.getBeansOfType(EncodingDiffValidator.class)).hasSize(7); assertThat(applicationContext.getBeansOfType(HeaderDiffValidator.class)).hasSize(3); assertThat(applicationContext.getBeansOfType(MediaTypeDiffValidator.class)).hasSize(6); assertThat(applicationContext.getBeansOfType(OperationDiffValidator.class)).hasSize(5); assertThat(applicationContext.getBeansOfType(ParameterDiffValidator.class)).hasSize(8); assertThat(applicationContext.getBeansOfType(PathItemDiffValidator.class)).hasSize(3); assertThat(applicationContext.getBeansOfType(RequestBodyDiffValidator.class)).hasSize(2); assertThat(applicationContext.getBeansOfType(ResponseDiffValidator.class)).hasSize(3); assertThat(applicationContext.getBeansOfType(SchemaDiffValidator.class)).hasSize(1); } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } } ================================================ FILE: oas-validator/oas-validator-compatibility-spring/src/test/resources/logback-test.xml ================================================ ================================================ FILE: oas-validator/oas-validator-core/pom.xml ================================================ org.apache.servicecomb.toolkit oas-validator-parent 0.3.0-SNAPSHOT ../pom.xml 4.0.0 oas-validator-core org.apache.commons commons-lang3 org.apache.commons commons-collections4 io.swagger.parser.v3 swagger-parser org.springframework.boot spring-boot-starter-test test org.apache.maven.plugins maven-surefire-plugin org.apache.maven.plugins maven-surefire-report-plugin ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/FactoryOptions.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv; import org.apache.commons.lang3.StringUtils; import java.util.*; public class FactoryOptions { private final Map options; public FactoryOptions(Map options) { this.options = Collections.unmodifiableMap(new HashMap<>(options)); } public FactoryOptions(Properties properties) { Map options = new HashMap<>(); Set keys = properties.keySet(); for (Object key : keys) { options.put((String) key, (String) properties.get(key)); } this.options = Collections.unmodifiableMap(options); } public String getString(String key) { String value = options.get(key); if (StringUtils.isNotBlank(value)) { return value; } return null; } public Boolean getBoolean(String key) { String value = options.get(key); if (StringUtils.isNotBlank(value)) { return Boolean.valueOf(value); } return null; } public Integer getInteger(String key) { String value = options.get(key); if (StringUtils.isNotBlank(value)) { return Integer.valueOf(value); } return null; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/common/OasObjectProperty.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.common; import java.util.Objects; import java.util.StringJoiner; /** * OpenAPI V3 object property information */ public class OasObjectProperty { /** * property name */ private final String name; /** * property object type, if null means primitive types, otherwise means OAS object */ private final OasObjectType objectType; public OasObjectProperty(String name) { this(null, name); } public OasObjectProperty(OasObjectType objectType, String name) { this.objectType = objectType; this.name = name; } public OasObjectType getObjectType() { return objectType; } public String getName() { return name; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OasObjectProperty that = (OasObjectProperty) o; return objectType == that.objectType && Objects.equals(name, that.name); } @Override public int hashCode() { return Objects.hash(objectType, name); } @Override public String toString() { return new StringJoiner(", ", OasObjectProperty.class.getSimpleName() + "[", "]") .add("name='" + name + "'") .add("objectType=" + objectType) .toString(); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/common/OasObjectPropertyLocation.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.common; import com.fasterxml.jackson.annotation.JsonIgnore; import java.util.*; import static java.util.Collections.singletonList; /** * OpenAPI v3 object location *

本对象immutable

*/ public class OasObjectPropertyLocation { /** * first element stands for root object * last element stands for current object * this list stands for the path from root to current object */ private final List path; private OasObjectPropertyLocation(OasObjectProperty path) { this(singletonList(path)); } private OasObjectPropertyLocation(List path) { this.path = Collections.unmodifiableList(path); } /** * Create a location for root object * * @return */ public static OasObjectPropertyLocation root() { return new OasObjectPropertyLocation(new OasObjectProperty(OasObjectType.OPENAPI, "$")); } /** * Add property to this location and return a new location * * @param propertyName property name * @param propertyType OAS object type of property * @return a new {@link OasObjectPropertyLocation},origin {@link OasObjectPropertyLocation} is untouched */ public OasObjectPropertyLocation property(String propertyName, OasObjectType propertyType) { ArrayList oasObjectProperties = new ArrayList<>(path); oasObjectProperties.add(new OasObjectProperty(propertyType, propertyName)); return new OasObjectPropertyLocation(oasObjectProperties); } /** * Add a non-object(primitive) type property to this location, and return a new location * * @param propertyName property name * @return a new {@link OasObjectPropertyLocation},origin {@link OasObjectPropertyLocation} is untouched */ public OasObjectPropertyLocation property(String propertyName) { ArrayList oasObjectProperties = new ArrayList<>(path); oasObjectProperties.add(new OasObjectProperty(propertyName)); return new OasObjectPropertyLocation(oasObjectProperties); } /** * Get a path from root to leaf * * @return */ public List getPath() { return Collections.unmodifiableList(path); } /** * Get parent property * * @return */ @JsonIgnore public OasObjectProperty getParent() { if (path.size() <= 1) { return null; } return path.get(path.size() - 2); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OasObjectPropertyLocation that = (OasObjectPropertyLocation) o; return Objects.equals(path, that.path); } @Override public int hashCode() { return Objects.hash(path); } @Override public String toString() { return new StringJoiner(", ", OasObjectPropertyLocation.class.getSimpleName() + "[", "]") .add("path=" + path) .toString(); } public static String toPathString(OasObjectPropertyLocation location) { if (location == null) { return ""; } StringBuilder sb = new StringBuilder(); List path = location.getPath(); for (OasObjectProperty property : path) { sb.append(property.getName()).append('.'); } sb.deleteCharAt(sb.length() - 1); return sb.toString(); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/common/OasObjectType.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.common; /** * OpenAPI v3 Object Type *

* Corresponding to OpenAPI Specification - Schema *

*/ public enum OasObjectType { OPENAPI, INFO, CONTACT, LICENSE, SERVER, SERVER_VARIABLE, COMPONENTS, PATHS, PATH_ITEM, OPERATION, EXTERNAL_DOCUMENTATION, PARAMETER, REQUEST_BODY, MEDIA_TYPE, ENCODING, RESPONSES, RESPONSE, CALLBACK, EXAMPLE, HEADER, TAG, REFERENCE, SCHEMA, DISCRIMINATOR, XML, SECURITY_SCHEME, OAUTH_FLOWS, OAUTH_FLOW, LINK, SECURITY_REQUIREMENT } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/CallbackDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.callbacks.Callback; public interface CallbackDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/ComponentsDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.Components; public interface ComponentsDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/DefaultOasSpecDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import io.swagger.v3.oas.models.OpenAPI; import java.util.ArrayList; import java.util.List; import static java.util.stream.Collectors.toList; public class DefaultOasSpecDiffValidator implements OasSpecDiffValidator { private final List openApiDiffValidators; public DefaultOasSpecDiffValidator(List openApiDiffValidators) { this.openApiDiffValidators = new ArrayList<>(openApiDiffValidators); } @Override public List validate(OasDiffValidationContext context, OpenAPI leftOpenApi, OpenAPI rightOpenApi) { OasObjectPropertyLocation leftRoot = OasObjectPropertyLocation.root(); OasObjectPropertyLocation rightRoot = OasObjectPropertyLocation.root(); return openApiDiffValidators .stream() .map(validator -> validator.validate(context, leftRoot, leftOpenApi, rightRoot, rightOpenApi)) .flatMap(list -> list.stream()) .collect(toList()); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/DiffViolationMessages.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; public abstract class DiffViolationMessages { public static final String OP_DEL_FORBIDDEN = "deletion is no allowed on right side"; public static final String OP_ADD_FORBIDDEN = "adding is not allowed on right side"; public static final String NEW_NOT_EQ_OLD = "not equal on both side"; public static final String NEW_NOT_GTE_OLD = "left side must be >= right side"; public static final String NEW_NOT_LTE_OLD = "left side must be <= right side"; public static final String FALSE_TO_TRUE = "only false->true is allowed"; public static final String TRUE_TO_FALSE = "only true->false is allowed"; } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/EncodingDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.media.Encoding; public interface EncodingDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/HeaderDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.headers.Header; public interface HeaderDiffValidator extends OasObjectDiffValidator
{ } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/InfoDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.info.Info; public interface InfoDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/LinkDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.links.Link; public interface LinkDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/ListPropertyDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import java.util.List; import java.util.function.Function; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasObjectDiffValidatorUtils.doDiffValidateListProperty; public abstract class ListPropertyDiffValidator extends OasObjectDiffValidatorTemplate { private final List> elementDiffValidators; private final Function elementKeyMapper; protected ListPropertyDiffValidator( List> elementDiffValidators, Function elementKeyMapper) { this.elementDiffValidators = elementDiffValidators; this.elementKeyMapper = elementKeyMapper; } @Override public List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject) { return doDiffValidateListProperty( context, getListPropertyName(), leftLocation, getListProperty(leftOasObject), rightLocation, getListProperty(rightOasObject), getElementType(), elementKeyMapper, elementDiffValidators ); } protected abstract List

getListProperty(T oasObject); protected abstract String getListPropertyName(); protected abstract OasObjectType getElementType(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/MapPropertyDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasObjectDiffValidatorUtils.doDiffValidateMapProperty; public abstract class MapPropertyDiffValidator extends OasObjectDiffValidatorTemplate { private final List> valueDiffValidators; protected MapPropertyDiffValidator(List> valueDiffValidators) { this.valueDiffValidators = valueDiffValidators; } @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject) { return doDiffValidateMapProperty( context, getMapPropertyName(), leftLocation, getMapProperty(leftOasObject), rightLocation, getMapProperty(rightOasObject), getValueType(), valueDiffValidators ); } protected abstract Map getMapProperty(T oasObject); protected abstract String getMapPropertyName(); protected abstract OasObjectType getValueType(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/MediaTypeDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.media.MediaType; public interface MediaTypeDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/OasDiffValidationContext.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.OpenAPI; import java.util.HashMap; import java.util.Map; public class OasDiffValidationContext { private final OpenAPI leftOpenAPI; private final OpenAPI rightOpenAPI; private final Map attributes = new HashMap<>(); public OasDiffValidationContext(OpenAPI leftOpenAPI, OpenAPI rightOpenAPI) { this.leftOpenAPI = leftOpenAPI; this.rightOpenAPI = rightOpenAPI; } public OpenAPI getLeftOpenAPI() { return leftOpenAPI; } public OpenAPI getRightOpenAPI() { return rightOpenAPI; } public T getAttribute(String name) { return (T) attributes.get(name); } public void setAttribute(String name, T attr) { this.attributes.put(name, attr); } public void removeAttribute(String name) { this.attributes.remove(name); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/OasDiffValidationException.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; public class OasDiffValidationException extends RuntimeException { public OasDiffValidationException() { } public OasDiffValidationException(String message) { super(message); } public OasDiffValidationException(String message, Throwable cause) { super(message, cause); } public OasDiffValidationException(Throwable cause) { super(cause); } public OasDiffValidationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/OasDiffViolation.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import java.util.Objects; import java.util.StringJoiner; public class OasDiffViolation { /** * left OAS object location */ private final OasObjectPropertyLocation leftLocation; /** * right OAS object location */ private final OasObjectPropertyLocation rightLocation; private final String error; public static OasDiffViolation onlyLeft(OasObjectPropertyLocation location, String error) { return new OasDiffViolation(location, null, error); } public static OasDiffViolation onlyRight(OasObjectPropertyLocation location, String error) { return new OasDiffViolation(null, location, error); } public OasDiffViolation(OasObjectPropertyLocation leftLocation, OasObjectPropertyLocation rightLocation, String error) { this.leftLocation = leftLocation; this.rightLocation = rightLocation; this.error = error; } public OasObjectPropertyLocation getLeftLocation() { return leftLocation; } public OasObjectPropertyLocation getRightLocation() { return rightLocation; } public String getError() { return error; } @Override public String toString() { return new StringJoiner(", ", OasDiffViolation.class.getSimpleName() + "[", "]") .add("leftLocation=" + leftLocation) .add("rightLocation=" + rightLocation) .add("error='" + error + "'") .toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OasDiffViolation that = (OasDiffViolation) o; return Objects.equals(leftLocation, that.leftLocation) && Objects.equals(rightLocation, that.rightLocation) && Objects.equals(error, that.error); } @Override public int hashCode() { return Objects.hash(leftLocation, rightLocation, error); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/OasObjectDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import java.util.List; /** * OAS Object difference validator interface * * @param OpenAPI Specification Object */ public interface OasObjectDiffValidator { /** * leftOasObject and rightOasObject should not be null at the same time * * @param context difference validation context * @param leftLocation left OAS Object location (maybe null) * @param leftOasObject left OAS Object (maybe null) * @param rightLocation right OAS Object location (maybe null) * @param rightOasObject right OAS Object (maybe null) * @return difference validation violations, maybe a empty list */ List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/OasObjectDiffValidatorTemplate.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasObjectDiffValidatorUtils.assertNullGood; import static java.util.Collections.emptyList; public class OasObjectDiffValidatorTemplate implements OasObjectDiffValidator { @Override public List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject) { assertNullGood(leftLocation, leftOasObject, rightLocation, rightOasObject); if (leftOasObject == null && rightOasObject != null) { return validateAdd(context, rightLocation, rightOasObject); } if (leftOasObject != null && rightOasObject == null) { return validateDel(context, leftLocation, leftOasObject); } return validateCompare(context, leftLocation, leftOasObject, rightLocation, rightOasObject); } /** * validate the adding situation, left side doesn't exist but right side exists * * @param context * @param rightLocation * @param rightOasObject * @return */ protected List validateAdd(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, T rightOasObject) { return emptyList(); } /** * validate the deleting situation, left side exists but right side doesn't exist * * @param context * @param leftLocation * @param leftOasObject * @return */ protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, T leftOasObject) { return emptyList(); } /** * validate the modification situation, both left side and right side right exists. * notice that left maybe equals to right * * @param context * @param leftLocation * @param leftOasObject * @param rightLocation * @param rightOasObject * @return */ protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject) { return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/OasSpecDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.OpenAPI; import java.util.List; /** * OAS Spec difference validator */ public interface OasSpecDiffValidator { List validate(OasDiffValidationContext context, OpenAPI leftOpenApi, OpenAPI rightOpenApi); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/ObjectPropertyDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasObjectDiffValidatorUtils.doDiffValidateProperty; /** * OAS Object object property difference validator * * @param Object defined in OpenAPI Specification * @param

Property type */ public abstract class ObjectPropertyDiffValidator extends OasObjectDiffValidatorTemplate { private final List> diffValidators; protected ObjectPropertyDiffValidator(List> diffValidators) { this.diffValidators = diffValidators; } @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject) { P leftProperty = getPropertyObject(leftOasObject); P rightProperty = getPropertyObject(rightOasObject); OasObjectPropertyLocation leftPropertyLoc = leftProperty == null ? null : leftLocation.property(getPropertyName(), getPropertyType()); OasObjectPropertyLocation rightPropertyLoc = rightProperty == null ? null : rightLocation.property(getPropertyName(), getPropertyType()); return doDiffValidateProperty(context, leftPropertyLoc, leftProperty, rightPropertyLoc, rightProperty, diffValidators); } /** * @param oasObject will never be null * @return */ protected abstract P getPropertyObject(T oasObject); protected abstract String getPropertyName(); protected abstract OasObjectType getPropertyType(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/OpenApiDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.OpenAPI; public interface OpenApiDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/OperationDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.Operation; public interface OperationDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/ParameterDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.parameters.Parameter; public interface ParameterDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/PathItemDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.PathItem; public interface PathItemDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/PathsDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.Paths; public interface PathsDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/RequestBodyDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.parameters.RequestBody; public interface RequestBodyDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/ResponseDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.responses.ApiResponse; public interface ResponseDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/ResponsesDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.responses.ApiResponses; public interface ResponsesDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/SchemaAddValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import io.swagger.v3.oas.models.media.Schema; import java.util.List; public interface SchemaAddValidator { /** * validate the adding situation, left side not exist but right side exists * * @param context * @param rightLocation * @param rightOasObject added schema object * @return */ List validate(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, Schema rightOasObject); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/SchemaCompareValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.schema.SchemaDiffValidatorEngine; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import io.swagger.v3.oas.models.media.Schema; import java.util.List; public interface SchemaCompareValidator { /** * validate the modification situation, both left side and right side right exists. *

* there is no need to check allOf, anyOf, oneOf, items, properties *

* they will be recursively checked by {@link SchemaDiffValidatorEngine} * * @param context * @param leftLocation * @param leftOasObject * @param rightLocation * @param rightOasObject * @return */ List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject, OasObjectPropertyLocation rightLocation, Schema rightOasObject); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/SchemaDelValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import io.swagger.v3.oas.models.media.Schema; import java.util.List; public interface SchemaDelValidator { /** * validate the deleting situation, left side exists but right side not exist * * @param context * @param leftLocation * @param leftOasObject deleted schema object * @return */ List validate( OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/SchemaDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.media.Schema; public interface SchemaDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/SecuritySchemeDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.security.SecurityScheme; public interface SecuritySchemeDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/ServerDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.servers.Server; public interface ServerDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/api/TagDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.api; import io.swagger.v3.oas.models.tags.Tag; public interface TagDiffValidator extends OasObjectDiffValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/CallbackDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.CallbackDiffValidator; public interface CallbackDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/ComponentsDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; public interface ComponentsDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/EncodingDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; public interface EncodingDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/HeaderDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; public interface HeaderDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/InfoDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.InfoDiffValidator; public interface InfoDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/LinkDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.LinkDiffValidator; public interface LinkDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/MediaTypeDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; public interface MediaTypeDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/OasObjectDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasObjectDiffValidator; public interface OasObjectDiffValidatorFactory { List create(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/OasSpecDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasSpecDiffValidator; public interface OasSpecDiffValidatorFactory { OasSpecDiffValidator create(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/OpenApiDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; public interface OpenApiDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/OperationDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; public interface OperationDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/ParameterDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; public interface ParameterDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/PathItemDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathItemDiffValidator; public interface PathItemDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/PathsDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathsDiffValidator; public interface PathsDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/RequestBodyDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; public interface RequestBodyDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/ResponseDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponseDiffValidator; public interface ResponseDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/ResponsesDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponsesDiffValidator; public interface ResponsesDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/SchemaDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaDiffValidator; public interface SchemaDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/SecuritySchemeDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SecuritySchemeDiffValidator; public interface SecuritySchemeDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/ServerDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ServerDiffValidator; public interface ServerDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/factory/TagDiffValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.factory; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.TagDiffValidator; public interface TagDiffValidatorFactory extends OasObjectDiffValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/components/ComponentsCallbacksDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.CallbackDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MapPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.callbacks.Callback; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.CALLBACK; public class ComponentsCallbacksDiffValidator extends MapPropertyDiffValidator implements ComponentsDiffValidator { public ComponentsCallbacksDiffValidator(List diffValidators) { super(diffValidators); } @Override protected Map getMapProperty(Components oasObject) { return oasObject.getCallbacks(); } @Override protected String getMapPropertyName() { return "callbacks"; } @Override protected OasObjectType getValueType() { return CALLBACK; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/components/ComponentsHeadersDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MapPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.headers.Header; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.HEADER; public class ComponentsHeadersDiffValidator extends MapPropertyDiffValidator implements ComponentsDiffValidator { public ComponentsHeadersDiffValidator(List diffValidators) { super(diffValidators); } @Override protected Map getMapProperty(Components oasObject) { return oasObject.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } @Override protected OasObjectType getValueType() { return HEADER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/components/ComponentsLinksDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.LinkDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MapPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.links.Link; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.LINK; public class ComponentsLinksDiffValidator extends MapPropertyDiffValidator implements ComponentsDiffValidator { public ComponentsLinksDiffValidator(List diffValidators) { super(diffValidators); } @Override protected Map getMapProperty(Components oasObject) { return oasObject.getLinks(); } @Override protected String getMapPropertyName() { return "links"; } @Override protected OasObjectType getValueType() { return LINK; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/components/ComponentsParametersDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MapPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PARAMETER; public class ComponentsParametersDiffValidator extends MapPropertyDiffValidator implements ComponentsDiffValidator { public ComponentsParametersDiffValidator(List diffValidators) { super(diffValidators); } @Override protected Map getMapProperty(Components oasObject) { return oasObject.getParameters(); } @Override protected String getMapPropertyName() { return "parameters"; } @Override protected OasObjectType getValueType() { return PARAMETER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/components/ComponentsRequestBodiesDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MapPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.parameters.RequestBody; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.REQUEST_BODY; public class ComponentsRequestBodiesDiffValidator extends MapPropertyDiffValidator implements ComponentsDiffValidator { public ComponentsRequestBodiesDiffValidator(List diffValidators) { super(diffValidators); } @Override protected Map getMapProperty(Components oasObject) { return oasObject.getRequestBodies(); } @Override protected String getMapPropertyName() { return "requestBodies"; } @Override protected OasObjectType getValueType() { return REQUEST_BODY; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/components/ComponentsResponsesDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MapPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponseDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.responses.ApiResponse; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.RESPONSE; public class ComponentsResponsesDiffValidator extends MapPropertyDiffValidator implements ComponentsDiffValidator { public ComponentsResponsesDiffValidator(List diffValidators) { super(diffValidators); } @Override protected Map getMapProperty(Components oasObject) { return oasObject.getResponses(); } @Override protected String getMapPropertyName() { return "responses"; } @Override protected OasObjectType getValueType() { return RESPONSE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/encoding/EncodingHeadersDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.encoding; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MapPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.headers.Header; import io.swagger.v3.oas.models.media.Encoding; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.HEADER; public class EncodingHeadersDiffValidator extends MapPropertyDiffValidator implements EncodingDiffValidator { public EncodingHeadersDiffValidator(List diffValidators) { super(diffValidators); } @Override protected Map getMapProperty(Encoding oasObject) { return oasObject.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } @Override protected OasObjectType getValueType() { return HEADER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/header/HeaderSchemaDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.header; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ObjectPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.headers.Header; import io.swagger.v3.oas.models.media.Schema; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; public class HeaderSchemaDiffValidator extends ObjectPropertyDiffValidator implements HeaderDiffValidator { public HeaderSchemaDiffValidator(List oasObjectValidators) { super(oasObjectValidators); } @Override protected Schema getPropertyObject(Header oasObject) { return oasObject.getSchema(); } @Override protected String getPropertyName() { return "schema"; } @Override protected OasObjectType getPropertyType() { return SCHEMA; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/mediatype/MediaTypeEncodingDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.mediatype; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.media.Encoding; import io.swagger.v3.oas.models.media.MediaType; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.ENCODING; public class MediaTypeEncodingDiffValidator extends MapPropertyDiffValidator implements MediaTypeDiffValidator { public MediaTypeEncodingDiffValidator(List diffValidators) { super(diffValidators); } @Override public List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, MediaType leftOasObject, OasObjectPropertyLocation rightLocation, MediaType rightOasObject) { List violations = super .validate(context, leftLocation, leftOasObject, rightLocation, rightOasObject); return violations; } @Override protected Map getMapProperty(MediaType oasObject) { return oasObject.getEncoding(); } @Override protected String getMapPropertyName() { return "encoding"; } @Override protected OasObjectType getValueType() { return ENCODING; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/mediatype/MediaTypeSchemaDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.mediatype; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ObjectPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.media.Schema; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; public class MediaTypeSchemaDiffValidator extends ObjectPropertyDiffValidator implements MediaTypeDiffValidator { public MediaTypeSchemaDiffValidator(List oasObjectValidators) { super(oasObjectValidators); } @Override protected Schema getPropertyObject(MediaType oasObject) { return oasObject.getSchema(); } @Override protected String getPropertyName() { return "schema"; } @Override protected OasObjectType getPropertyType() { return SCHEMA; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/openapi/OpenApiComponentsDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ObjectPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; public class OpenApiComponentsDiffValidator extends ObjectPropertyDiffValidator implements OpenApiDiffValidator { public OpenApiComponentsDiffValidator( List componentsDiffValidators) { super(componentsDiffValidators); } @Override protected Components getPropertyObject(OpenAPI oasObject) { return oasObject.getComponents(); } @Override protected String getPropertyName() { return "components"; } @Override protected OasObjectType getPropertyType() { return COMPONENTS; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/openapi/OpenApiInfoDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.InfoDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ObjectPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.INFO; public class OpenApiInfoDiffValidator extends ObjectPropertyDiffValidator implements OpenApiDiffValidator { public OpenApiInfoDiffValidator(List pathsDiffValidators) { super(pathsDiffValidators); } @Override protected Info getPropertyObject(OpenAPI oasObject) { return oasObject.getInfo(); } @Override protected String getPropertyName() { return "info"; } @Override protected OasObjectType getPropertyType() { return INFO; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/openapi/OpenApiPathsDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ObjectPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathsDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Paths; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATHS; public class OpenApiPathsDiffValidator extends ObjectPropertyDiffValidator implements OpenApiDiffValidator { public OpenApiPathsDiffValidator(List pathsDiffValidators) { super(pathsDiffValidators); } @Override protected Paths getPropertyObject(OpenAPI oasObject) { return oasObject.getPaths(); } @Override protected String getPropertyName() { return "paths"; } @Override protected OasObjectType getPropertyType() { return PATHS; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/openapi/OpenApiServersDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ListPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ServerDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.servers.Server; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SERVER; public class OpenApiServersDiffValidator extends ListPropertyDiffValidator implements OpenApiDiffValidator { public OpenApiServersDiffValidator(List diffValidators) { super(diffValidators, server -> server.getUrl()); } @Override protected List getListProperty(OpenAPI oasObject) { return oasObject.getServers(); } @Override protected String getListPropertyName() { return "servers"; } @Override protected OasObjectType getElementType() { return SERVER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/openapi/OpenApiTagsDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ListPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.TagDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.tags.Tag; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.TAG; public class OpenApiTagsDiffValidator extends ListPropertyDiffValidator implements OpenApiDiffValidator { public OpenApiTagsDiffValidator(List diffValidators) { super(diffValidators, tag -> tag.getName()); } @Override protected List getListProperty(OpenAPI oasObject) { return oasObject.getTags(); } @Override protected String getListPropertyName() { return "tags"; } @Override protected OasObjectType getElementType() { return TAG; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/operation/OperationParametersDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ListPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PARAMETER; public class OperationParametersDiffValidator extends ListPropertyDiffValidator implements OperationDiffValidator { public OperationParametersDiffValidator(List parameterValidators) { super(parameterValidators, parameter -> "in:" + parameter.getIn() + "/name:" + parameter.getName()); } @Override protected List getListProperty(Operation oasObject) { return oasObject.getParameters(); } protected String getListPropertyName() { return "parameters"; } protected OasObjectType getElementType() { return PARAMETER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/operation/OperationRequestBodyDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ObjectPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.parameters.RequestBody; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.REQUEST_BODY; public class OperationRequestBodyDiffValidator extends ObjectPropertyDiffValidator implements OperationDiffValidator { public OperationRequestBodyDiffValidator( List requestBodyDiffValidators) { super(requestBodyDiffValidators); } @Override protected RequestBody getPropertyObject(Operation oasObject) { return oasObject.getRequestBody(); } @Override protected String getPropertyName() { return "requestBody"; } @Override protected OasObjectType getPropertyType() { return REQUEST_BODY; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/operation/OperationResponsesDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ObjectPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponsesDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.responses.ApiResponses; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.RESPONSES; public class OperationResponsesDiffValidator extends ObjectPropertyDiffValidator implements OperationDiffValidator { public OperationResponsesDiffValidator(List responsesDiffValidators) { super(responsesDiffValidators); } @Override protected ApiResponses getPropertyObject(Operation oasObject) { return oasObject.getResponses(); } @Override protected String getPropertyName() { return "responses"; } @Override protected OasObjectType getPropertyType() { return RESPONSES; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/parameter/ParameterContentDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.parameter; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.MEDIA_TYPE; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.*; public class ParameterContentDiffValidator extends MapPropertyDiffValidator implements ParameterDiffValidator { public ParameterContentDiffValidator(List mediaTypeValidators) { super(mediaTypeValidators); } @Override public List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Parameter leftOasObject, OasObjectPropertyLocation rightLocation, Parameter rightOasObject) { enterParameter(context); List violations = super .validate(context, leftLocation, leftOasObject, rightLocation, rightOasObject); leaveParameter(context); return violations; } @Override protected Map getMapProperty(Parameter oasObject) { return oasObject.getContent(); } @Override protected String getMapPropertyName() { return "content"; } @Override protected OasObjectType getValueType() { return MEDIA_TYPE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/parameter/ParameterSchemaDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.parameter; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.*; public class ParameterSchemaDiffValidator extends ObjectPropertyDiffValidator implements ParameterDiffValidator { public ParameterSchemaDiffValidator(List schemaDiffValidators) { super(schemaDiffValidators); } @Override public List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Parameter leftOasObject, OasObjectPropertyLocation rightLocation, Parameter rightOasObject) { enterParameter(context); List violations = super .validate(context, leftLocation, leftOasObject, rightLocation, rightOasObject); leaveParameter(context); return violations; } @Override protected Schema getPropertyObject(Parameter oasObject) { return oasObject.getSchema(); } @Override protected String getPropertyName() { return "schema"; } @Override protected OasObjectType getPropertyType() { return SCHEMA; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/pathitem/PathItemOperationsDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.pathitem; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.PathItem; import java.util.ArrayList; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.OPERATION; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasObjectDiffValidatorUtils.doDiffValidateProperty; public class PathItemOperationsDiffValidator extends OasObjectDiffValidatorTemplate implements PathItemDiffValidator { private final List operationValidators; public PathItemOperationsDiffValidator(List operationValidators) { this.operationValidators = operationValidators; } @Override public List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, PathItem leftOasObject, OasObjectPropertyLocation rightLocation, PathItem rightOasObject) { Map leftOperationMap = leftOasObject.readOperationsMap(); Map rightOperationMap = rightOasObject.readOperationsMap(); List violations = new ArrayList<>(); for (Map.Entry entry : leftOperationMap.entrySet()) { PathItem.HttpMethod leftMethod = entry.getKey(); Operation leftOperation = entry.getValue(); OasObjectPropertyLocation leftOperationLoc = leftLocation .property(leftMethod.toString().toLowerCase(), OPERATION); Operation rightOperation = rightOperationMap.get(leftMethod); if (rightOperation == null) { violations.addAll( doDiffValidateProperty( context, leftOperationLoc, leftOperation, null, null, operationValidators ) ); } else { OasObjectPropertyLocation rightOperationLoc = rightLocation .property(leftMethod.toString().toLowerCase(), OPERATION); violations.addAll( doDiffValidateProperty( context, leftOperationLoc, leftOperation, rightOperationLoc, rightOperation, operationValidators ) ); } } for (Map.Entry entry : rightOperationMap.entrySet()) { PathItem.HttpMethod rightMethod = entry.getKey(); if (leftOperationMap.containsKey(rightMethod)) { continue; } Operation rightOperation = rightOperationMap.get(rightMethod); OasObjectPropertyLocation rightOperationLoc = rightLocation .property(rightMethod.toString().toLowerCase(), OPERATION); violations.addAll( doDiffValidateProperty( context, null, null, rightOperationLoc, rightOperation, operationValidators ) ); } return violations; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/pathitem/PathItemParametersDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.pathitem; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ListPropertyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathItemDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PARAMETER; /** * Path Item Object * .parameters (List of Parameter Object)的校验器 */ public class PathItemParametersDiffValidator extends ListPropertyDiffValidator implements PathItemDiffValidator { public PathItemParametersDiffValidator(List parameterValidators) { super(parameterValidators, parameter -> "in:" + parameter.getIn() + "/name:" + parameter.getName()); } @Override protected List getListProperty(PathItem oasObject) { return oasObject.getParameters(); } @Override protected String getListPropertyName() { return "parameters"; } @Override protected OasObjectType getElementType() { return PARAMETER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/paths/PathsPathItemsDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.paths; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.Paths; import java.util.ArrayList; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasObjectDiffValidatorUtils.doDiffValidateProperty; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATH_ITEM; public class PathsPathItemsDiffValidator extends OasObjectDiffValidatorTemplate implements PathsDiffValidator { private final List pathItemValidators; public PathsPathItemsDiffValidator(List pathItemValidators) { this.pathItemValidators = pathItemValidators; } @Override public List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Paths leftOasObject, OasObjectPropertyLocation rightLocation, Paths rightOasObject) { List violations = new ArrayList<>(); for (Map.Entry entry : leftOasObject.entrySet()) { String lPath = entry.getKey(); PathItem lPathItem = entry.getValue(); OasObjectPropertyLocation lPathItemLoc = leftLocation.property(lPath, PATH_ITEM); PathItem rPathItem = rightOasObject.get(lPath); if (rPathItem == null) { violations.addAll(doDiffValidateProperty(context, lPathItemLoc, lPathItem, null, null, pathItemValidators)); } else { OasObjectPropertyLocation rPathItemLoc = rightLocation.property(lPath, PATH_ITEM); violations.addAll( doDiffValidateProperty(context, lPathItemLoc, lPathItem, rPathItemLoc, rPathItem, pathItemValidators)); } } for (Map.Entry entry : rightOasObject.entrySet()) { String rPath = entry.getKey(); if (leftOasObject.containsKey(rPath)) { continue; } PathItem rPathItem = entry.getValue(); OasObjectPropertyLocation rPathItemLoc = leftLocation.property(rPath, PATH_ITEM); violations.addAll(doDiffValidateProperty(context, null, null, rPathItemLoc, rPathItem, pathItemValidators)); } return violations; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/requestbody/RequestBodyContentDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.requestbody; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.parameters.RequestBody; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.MEDIA_TYPE; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.*; public class RequestBodyContentDiffValidator extends MapPropertyDiffValidator implements RequestBodyDiffValidator { public RequestBodyContentDiffValidator(List mediaTypeValidators) { super(mediaTypeValidators); } @Override public List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, RequestBody leftOasObject, OasObjectPropertyLocation rightLocation, RequestBody rightOasObject) { enterRequestBody(context); List violations = super .validate(context, leftLocation, leftOasObject, rightLocation, rightOasObject); leaveRequestBody(context); return violations; } @Override protected Map getMapProperty(RequestBody oasObject) { return oasObject.getContent(); } @Override protected String getMapPropertyName() { return "content"; } @Override protected OasObjectType getValueType() { return MEDIA_TYPE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/response/ResponseContentDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.response; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.responses.ApiResponse; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.MEDIA_TYPE; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.*; public class ResponseContentDiffValidator extends MapPropertyDiffValidator implements ResponseDiffValidator { public ResponseContentDiffValidator(List mediaTypeValidators) { super(mediaTypeValidators); } @Override public List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, ApiResponse leftOasObject, OasObjectPropertyLocation rightLocation, ApiResponse rightOasObject) { enterResponse(context); List violations = super .validate(context, leftLocation, leftOasObject, rightLocation, rightOasObject); leaveResponse(context); return violations; } @Override protected Map getMapProperty(ApiResponse oasObject) { return oasObject.getContent(); } @Override protected String getMapPropertyName() { return "content"; } @Override protected OasObjectType getValueType() { return MEDIA_TYPE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/response/ResponseHeadersDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.response; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import io.swagger.v3.oas.models.headers.Header; import io.swagger.v3.oas.models.responses.ApiResponse; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.HEADER; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.enterResponse; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasDiffValidationContextUtils.leaveResponse; public class ResponseHeadersDiffValidator extends MapPropertyDiffValidator implements ResponseDiffValidator { public ResponseHeadersDiffValidator(List valueValidators) { super(valueValidators); } @Override public List validate(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, ApiResponse leftOasObject, OasObjectPropertyLocation rightLocation, ApiResponse rightOasObject) { enterResponse(context); List violations = super .validate(context, leftLocation, leftOasObject, rightLocation, rightOasObject); leaveResponse(context); return violations; } @Override protected Map getMapProperty(ApiResponse components) { return components.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } @Override protected OasObjectType getValueType() { return HEADER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/responses/ResponsesResponsesDiffValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.responses; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponses; import java.util.ArrayList; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasObjectDiffValidatorUtils.doDiffValidateProperty; public class ResponsesResponsesDiffValidator extends OasObjectDiffValidatorTemplate implements ResponsesDiffValidator { private final List responseValidators; public ResponsesResponsesDiffValidator(List responseValidators) { this.responseValidators = responseValidators; } @Override public List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, ApiResponses leftOasObject, OasObjectPropertyLocation rightLocation, ApiResponses rightOasObject) { List violations = new ArrayList<>(); for (Map.Entry entry : leftOasObject.entrySet()) { String leftStatus = entry.getKey(); ApiResponse leftResponse = entry.getValue(); OasObjectPropertyLocation leftResponseLoc = leftLocation.property(leftStatus, OasObjectType.RESPONSE); ApiResponse rightResponse = rightOasObject.get(leftStatus); if (rightResponse == null) { violations.addAll( doDiffValidateProperty( context, leftResponseLoc, leftResponse, null, null, responseValidators ) ); } else { OasObjectPropertyLocation rightResponseLoc = rightLocation.property(leftStatus, OasObjectType.RESPONSE); violations.addAll( doDiffValidateProperty( context, leftResponseLoc, leftResponse, rightResponseLoc, rightResponse, responseValidators ) ); } } for (Map.Entry entry : rightOasObject.entrySet()) { String rightStatus = entry.getKey(); if (leftOasObject.containsKey(rightStatus)) { continue; } ApiResponse rightResponse = entry.getValue(); OasObjectPropertyLocation rightResponseLoc = rightLocation.property(rightStatus, OasObjectType.RESPONSE); violations.addAll( doDiffValidateProperty( context, null, null, rightResponseLoc, rightResponse, responseValidators ) ); } return violations; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/skeleton/schema/SchemaDiffValidatorEngine.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.schema; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.*; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ComposedSchema; import io.swagger.v3.oas.models.media.Schema; import java.util.ArrayList; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.diffvalidation.util.OasObjectDiffValidatorUtils.*; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; import static java.util.Collections.singletonList; import static java.util.stream.Collectors.toList; /** * Schema object difference validator engine. * It does validation recursively */ public class SchemaDiffValidatorEngine extends OasObjectDiffValidatorTemplate implements SchemaDiffValidator { private final List schemaAddValidators; private final List schemaDelValidators; private final List schemaCompareValidators; public SchemaDiffValidatorEngine( List schemaAddValidators, List schemaDelValidators, List schemaCompareValidators) { this.schemaAddValidators = new ArrayList<>(schemaAddValidators); this.schemaDelValidators = new ArrayList<>(schemaDelValidators); this.schemaCompareValidators = new ArrayList<>(schemaCompareValidators); } @Override protected List validateAdd(OasDiffValidationContext context, OasObjectPropertyLocation rightLocation, Schema rightOasObject) { return schemaAddValidators .stream() .map(v -> v.validate(context, rightLocation, rightOasObject)) .flatMap(list -> list.stream()) .collect(toList()); } @Override protected List validateDel(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject) { return schemaDelValidators .stream() .map(v -> v.validate(context, leftLocation, leftOasObject)) .flatMap(list -> list.stream()) .collect(toList()); } @Override protected List validateCompare(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject, OasObjectPropertyLocation rightLocation, Schema rightOasObject) { List violations = new ArrayList<>(); violations.addAll( schemaCompareValidators .stream() .map(v -> v.validate(context, leftLocation, leftOasObject, rightLocation, rightOasObject)) .flatMap(list -> list.stream()) .collect(toList()) ); violations.addAll( validateCompareOrdinary(context, leftLocation, leftOasObject, rightLocation, rightOasObject) ); violations.addAll( validateCompareArray(context, leftLocation, leftOasObject, rightLocation, rightOasObject) ); violations.addAll( validateCompareComposed(context, leftLocation, leftOasObject, rightLocation, rightOasObject) ); return violations; } private List validateCompareOrdinary(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject, OasObjectPropertyLocation rightLocation, Schema rightOasObject) { return doDiffValidateMapProperty( context, "properties", leftLocation, leftOasObject.getProperties(), rightLocation, rightOasObject.getProperties(), SCHEMA, singletonList(this) ); } private List validateCompareArray(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject, OasObjectPropertyLocation rightLocation, Schema rightOasObject) { Schema leftItems = null; OasObjectPropertyLocation leftItemsLocation = null; if (leftOasObject instanceof ArraySchema) { leftItems = ((ArraySchema) leftOasObject).getItems(); leftItemsLocation = leftLocation.property("items", SCHEMA); } Schema rightItems = null; OasObjectPropertyLocation rightItemsLocation = null; if (rightOasObject instanceof ArraySchema) { rightItems = ((ArraySchema) rightOasObject).getItems(); rightItemsLocation = rightLocation.property("items", SCHEMA); } return doDiffValidateProperty( context, leftItemsLocation, leftItems, rightItemsLocation, rightItems, singletonList(this) ); } private List validateCompareComposed(OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, Schema leftOasObject, OasObjectPropertyLocation rightLocation, Schema rightOasObject) { List violations = new ArrayList<>(); List leftAllOf = null; List leftOneOf = null; List leftAnyOf = null; if (leftOasObject instanceof ComposedSchema) { leftAllOf = ((ComposedSchema) leftOasObject).getAllOf(); leftOneOf = ((ComposedSchema) leftOasObject).getOneOf(); leftAnyOf = ((ComposedSchema) leftOasObject).getAnyOf(); } List rightAllOf = null; List rightOneOf = null; List rightAnyOf = null; if (rightOasObject instanceof ComposedSchema) { rightAllOf = ((ComposedSchema) rightOasObject).getAllOf(); rightOneOf = ((ComposedSchema) rightOasObject).getOneOf(); rightAnyOf = ((ComposedSchema) rightOasObject).getAnyOf(); } violations.addAll( doDiffValidateListProperty( context, "allOf", leftLocation, leftAllOf, rightLocation, rightAllOf, SCHEMA, schema -> System.identityHashCode(schema), singletonList(this) ) ); violations.addAll( doDiffValidateListProperty( context, "oneOf", leftLocation, leftOneOf, rightLocation, rightOneOf, SCHEMA, schema -> System.identityHashCode(schema), singletonList(this) ) ); violations.addAll( doDiffValidateListProperty( context, "anyOf", leftLocation, leftAnyOf, rightLocation, rightAnyOf, SCHEMA, schema -> System.identityHashCode(schema), singletonList(this) ) ); return violations; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/util/ChangeRangeCheckUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.util; import java.util.List; import java.util.Objects; public class ChangeRangeCheckUtils { public static boolean isNotViolated(Object left, Object right, List allowedList) { if (Objects.equals(left, right)) { return true; } for (Object[] objects : allowedList) { if (Objects.equals(objects[0], left) && Objects.equals(objects[1], right)) { return true; } } return false; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/util/OasDiffValidationContextUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.util; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; public class OasDiffValidationContextUtils { private static final String IN_REQUEST_BODY = OasDiffValidationContextUtils.class.getName() + ".IN_REQUEST_BODY"; private static final String IN_PARAMETER = OasDiffValidationContextUtils.class.getName() + ".IN_PARAMETER"; private static final String IN_RESPONSE = OasDiffValidationContextUtils.class.getName() + ".IN_RESPONSE"; public static void enterRequestBody(OasDiffValidationContext context) { context.setAttribute(IN_REQUEST_BODY, true); } public static void leaveRequestBody(OasDiffValidationContext context) { context.removeAttribute(IN_REQUEST_BODY); } public static void enterResponse(OasDiffValidationContext context) { context.setAttribute(IN_RESPONSE, true); } public static void leaveResponse(OasDiffValidationContext context) { context.removeAttribute(IN_RESPONSE); } public static void enterParameter(OasDiffValidationContext context) { context.setAttribute(IN_PARAMETER, true); } public static void leaveParameter(OasDiffValidationContext context) { context.removeAttribute(IN_PARAMETER); } public static boolean isInRequestBody(OasDiffValidationContext context) { return Boolean.TRUE.equals(context.getAttribute(IN_REQUEST_BODY)); } public static boolean isInResponse(OasDiffValidationContext context) { return Boolean.TRUE.equals(context.getAttribute(IN_RESPONSE)); } public static boolean isInParameter(OasDiffValidationContext context) { return Boolean.TRUE.equals(context.getAttribute(IN_PARAMETER)); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/util/OasObjectDiffValidatorUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.util; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationException; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasObjectDiffValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.function.Function; import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; public abstract class OasObjectDiffValidatorUtils { private OasObjectDiffValidatorUtils() { // singleton } /** * assert parameters is not null-malformed * * @param leftLocation * @param leftOasObject * @param rightLocation * @param rightOasObject * @param */ public static void assertNullGood( OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject) { assertNullConsistent(leftLocation, leftOasObject, rightLocation, rightOasObject); if (leftOasObject == null && rightOasObject == null) { throw new OasDiffValidationException("leftLocation, leftOasObject, rightLocation, rightOasObject are all null"); } } /** * @param context * @param leftLocation * @param leftOasObject null-safe * @param rightLocation * @param rightOasObject null-safe * @param validators * @param * @return */ public static List doDiffValidateProperty( OasDiffValidationContext context, OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject, List> validators) { assertNullConsistent(leftLocation, leftOasObject, rightLocation, rightOasObject); if (leftLocation == null && rightLocation == null) { return emptyList(); } List violations = new ArrayList<>(); for (OasObjectDiffValidator validator : validators) { violations.addAll(validator.validate(context, leftLocation, leftOasObject, rightLocation, rightOasObject)); } return violations; } /** * @param context * @param listPropertyName * @param leftOwnerLocation * @param leftListProperty null-safe * @param rightOwnerLocation * @param rightListProperty null-safe * @param elementType * @param elementKeyMapper * @param validators * @param * @return */ public static List doDiffValidateListProperty( OasDiffValidationContext context, String listPropertyName, OasObjectPropertyLocation leftOwnerLocation, List leftListProperty, OasObjectPropertyLocation rightOwnerLocation, List rightListProperty, OasObjectType elementType, Function elementKeyMapper, List> validators) { assertOwnerLocationNotNull(leftOwnerLocation, rightOwnerLocation); if (leftListProperty == null) { leftListProperty = emptyList(); } if (rightListProperty == null) { rightListProperty = emptyList(); } List violations = new ArrayList<>(); for (int i = 0; i < leftListProperty.size(); i++) { T leftElement = leftListProperty.get(i); Object leftElementKey = elementKeyMapper.apply(leftElement); OasObjectPropertyLocation leftElementLoc = leftOwnerLocation.property(listPropertyName + "[" + i + "]", elementType); int rightElementIndex = indexOf(rightListProperty, leftElementKey, elementKeyMapper); if (rightElementIndex == -1) { violations.addAll(doDiffValidateProperty(context, leftElementLoc, leftElement, null, null, validators)); } else { T rightElement = rightListProperty.get(rightElementIndex); OasObjectPropertyLocation rightElementLoc = rightOwnerLocation.property(listPropertyName + "[" + rightElementIndex + "]", elementType); violations.addAll( doDiffValidateProperty(context, leftElementLoc, leftElement, rightElementLoc, rightElement, validators)); } } for (int i = 0; i < rightListProperty.size(); i++) { T rightElement = rightListProperty.get(i); Object rightElementKey = elementKeyMapper.apply(rightElement); OasObjectPropertyLocation rightElementLoc = rightOwnerLocation.property(listPropertyName + "[" + i + "]", elementType); int leftElementIndex = indexOf(leftListProperty, rightElementKey, elementKeyMapper); if (leftElementIndex != -1) { continue; } violations.addAll(doDiffValidateProperty(context, null, null, rightElementLoc, rightElement, validators)); } return violations; } private static int indexOf(List elementList, Object searchKey, Function elementKeyMapper) { for (int i = 0; i < elementList.size(); i++) { T element = elementList.get(i); if (elementKeyMapper.apply(element).equals(searchKey)) { return i; } } return -1; } /** * @param context * @param mapPropertyName * @param leftOwnerLocation * @param leftMapProperty null-safe * @param rightOwnerLocation * @param rightMapProperty null-safe * @param valueType * @param validators * @param * @return */ public static List doDiffValidateMapProperty( OasDiffValidationContext context, String mapPropertyName, OasObjectPropertyLocation leftOwnerLocation, Map leftMapProperty, OasObjectPropertyLocation rightOwnerLocation, Map rightMapProperty, OasObjectType valueType, List> validators ) { assertOwnerLocationNotNull(leftOwnerLocation, rightOwnerLocation); if (leftMapProperty == null) { leftMapProperty = emptyMap(); } if (rightMapProperty == null) { rightMapProperty = emptyMap(); } List violations = new ArrayList<>(); for (Map.Entry entry : leftMapProperty.entrySet()) { String leftKey = entry.getKey(); T leftValue = entry.getValue(); String keyName = mapPropertyName + ".'" + leftKey + "'"; OasObjectPropertyLocation leftValueLoc = leftOwnerLocation.property(keyName, valueType); T rightValue = rightMapProperty.get(leftKey); if (rightValue == null) { violations.addAll(doDiffValidateProperty(context, leftValueLoc, leftValue, null, null, validators)); } else { OasObjectPropertyLocation rightValueLoc = rightOwnerLocation.property(keyName, valueType); violations .addAll(doDiffValidateProperty(context, leftValueLoc, leftValue, rightValueLoc, rightValue, validators)); } } for (Map.Entry entry : rightMapProperty.entrySet()) { String rightKey = entry.getKey(); if (leftMapProperty.containsKey(rightKey)) { continue; } T rightValue = entry.getValue(); String keyName = mapPropertyName + ".'" + rightKey + "'"; OasObjectPropertyLocation rightLoc = rightOwnerLocation.property(keyName, valueType); violations.addAll(doDiffValidateProperty(context, null, null, rightLoc, rightValue, validators)); } return violations; } private static void assertOwnerLocationNotNull( OasObjectPropertyLocation leftOwnerLocation, OasObjectPropertyLocation rightOwnerLocation) { if (leftOwnerLocation == null) { throw new OasDiffValidationException("leftOwnerLocation is null"); } if (rightOwnerLocation == null) { throw new OasDiffValidationException("rightOwnerLocation is null"); } } private static void assertNullConsistent( OasObjectPropertyLocation leftLocation, T leftOasObject, OasObjectPropertyLocation rightLocation, T rightOasObject) { if (leftLocation == null ^ leftOasObject == null) { throw new OasDiffValidationException("leftLocation, leftOasObject should be both null or not"); } if (rightLocation == null ^ rightOasObject == null) { throw new OasDiffValidationException("rightLocation, rightOasObject should be both null or not"); } } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/util/ParameterUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.util; import io.swagger.v3.oas.models.parameters.Parameter; public abstract class ParameterUtils { public static String getKeyString(Parameter parameter) { return new StringBuilder() .append("[name=") .append(parameter.getName()) .append(",in=") .append(parameter.getIn()) .append("]") .toString(); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/util/StringCaseUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.util; import org.apache.commons.lang3.StringUtils; import java.util.regex.Pattern; public abstract class StringCaseUtils { private static final Pattern LOWER_CAMEL_CASE = Pattern.compile("^[a-z]+((\\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?$"); private static final Pattern UPPER_CAMEL_CASE = Pattern.compile("^[A-Z]([a-z0-9]+[A-Z]?)*$"); private static final Pattern UPPER_HYPHEN_CASE = Pattern.compile("^([A-Z][a-z0-9]*-)*([A-Z][a-z0-9]*)$"); private StringCaseUtils() { // singleton } public static boolean isLowerCamelCase(String string) { if (StringUtils.isBlank(string)) { return false; } return LOWER_CAMEL_CASE.matcher(string).matches(); } public static boolean isUpperCamelCase(String string) { if (StringUtils.isBlank(string)) { return false; } return UPPER_CAMEL_CASE.matcher(string).matches(); } public static boolean isUpperHyphenCase(String string) { if (StringUtils.isBlank(string)) { return false; } return UPPER_HYPHEN_CASE.matcher(string).matches(); } public static boolean isMatchCase(String expectedCase, String string) { switch (expectedCase) { case "upper-camel-case": return isUpperCamelCase(string); case "lower-camel-case": return isLowerCamelCase(string); case "upper-hyphen-case": return isUpperHyphenCase(string); default: throw new IllegalArgumentException("Unrecognized case: " + expectedCase); } } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/util/SyntaxChecker.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.util; import static java.util.Collections.emptyList; import java.util.List; import io.swagger.v3.parser.OpenAPIV3Parser; import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.core.models.SwaggerParseResult; public class SyntaxChecker { private SyntaxChecker() { // singleton } public static List check(String oasSpecContent) { ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(false); parseOptions.setResolveFully(false); parseOptions.setResolveCombinators(false); parseOptions.setFlatten(false); OpenAPIV3Parser parser = new OpenAPIV3Parser(); SwaggerParseResult result = parser.readContents(oasSpecContent, null, parseOptions); return result.getMessages() == null ? emptyList() : result.getMessages(); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/CallbackValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.callbacks.Callback; /** * Callback Object validator */ public interface CallbackValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ComponentsValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.Components; /** * Components Object validator */ public interface ComponentsValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/DefaultOasSpecValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import io.swagger.v3.oas.models.OpenAPI; import java.util.List; import static java.util.stream.Collectors.toList; public class DefaultOasSpecValidator implements OasSpecValidator { private List openApiValidators; public DefaultOasSpecValidator(List openApiValidators) { this.openApiValidators = openApiValidators; } @Override public List validate(OasValidationContext context, OpenAPI openAPI) { OasObjectPropertyLocation location = OasObjectPropertyLocation.root(); return openApiValidators .stream() .map(validator -> validator.validate(context, location, openAPI)) .flatMap(list -> list.stream()) .collect(toList()); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/EncodingValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.media.Encoding; /** * Encoding Object validator */ public interface EncodingValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ExampleValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.examples.Example; /** * Example Object validator */ public interface ExampleValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/HeaderValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.headers.Header; /** * Header Object validator */ public interface HeaderValidator extends OasObjectValidator
{ } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/InfoValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.info.Info; /** * Info Object validator */ public interface InfoValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/LinkValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.links.Link; /** * Link Object validator */ public interface LinkValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ListPropertyRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; public abstract class ListPropertyRequiredValidator implements OasObjectValidator { @Override final public List validate(OasValidationContext context, OasObjectPropertyLocation location, T oasObject) { if (StringUtils.isNotBlank(get$ref(oasObject))) { return emptyList(); } List

listProperty = getListProperty(oasObject); if (CollectionUtils.isEmpty(listProperty)) { OasObjectPropertyLocation propertyLoc = location.property(getListPropertyName(), getElementType()); return singletonList(new OasViolation(propertyLoc, ViolationMessages.REQUIRED)); } return emptyList(); } protected abstract String get$ref(T oasObject); protected abstract List

getListProperty(T oasObject); protected abstract String getListPropertyName(); protected abstract OasObjectType getElementType(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ListPropertyValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.commons.lang3.StringUtils; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils.doValidateListProperty; import static java.util.Collections.emptyList; public abstract class ListPropertyValidator implements OasObjectValidator { private final List> valueValidators; protected ListPropertyValidator(List> valueValidators) { this.valueValidators = valueValidators; } @Override final public List validate(OasValidationContext context, OasObjectPropertyLocation location, T oasObject) { if (StringUtils.isNotBlank(get$ref(oasObject))) { return emptyList(); } return doValidateListProperty( context, location, getListPropertyName(), getListProperty(oasObject), getElementType(), valueValidators ); } protected abstract String get$ref(T oasObject); protected abstract List

getListProperty(T oasObject); protected abstract String getListPropertyName(); protected abstract OasObjectType getElementType(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/MapPropertyKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; import static org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils.doValidateMapPropertyKeys; import static java.util.Collections.emptyList; public abstract class MapPropertyKeysValidator implements OasObjectValidator { private final Predicate keyPredicate; private final Function errorFunction; public MapPropertyKeysValidator(Predicate keyPredicate, Function errorFunction) { this.keyPredicate = keyPredicate; this.errorFunction = errorFunction; } @Override final public List validate(OasValidationContext context, OasObjectPropertyLocation location, T oasObject) { if (StringUtils.isNotBlank(get$ref(oasObject))) { return emptyList(); } return doValidateMapPropertyKeys( location, getMapPropertyName(), getMapProperty(oasObject), keyPredicate, errorFunction ); } protected abstract String get$ref(T oasObject); protected abstract Map getMapProperty(T oasObject); protected abstract String getMapPropertyName(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/MapPropertyValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils.doValidateMapPropertyValues; import static java.util.Collections.emptyList; public abstract class MapPropertyValuesValidator implements OasObjectValidator { private final List> valueValidators; protected MapPropertyValuesValidator(List> valueValidators) { this.valueValidators = valueValidators; } @Override public final List validate(OasValidationContext context, OasObjectPropertyLocation location, T oasObject) { if (StringUtils.isNotBlank(get$ref(oasObject))) { return emptyList(); } return doValidateMapPropertyValues( context, location, getMapPropertyName(), getMapProperty(oasObject), getValueType(), valueValidators ); } protected abstract String get$ref(T oasObject); protected abstract Map getMapProperty(T oasObject); protected abstract String getMapPropertyName(); protected abstract OasObjectType getValueType(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/MediaTypeValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.media.MediaType; /** * Media Type Object validator */ public interface MediaTypeValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/OasObjectValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import java.util.List; /** * @param Objects defined in OpenAPI Specification */ public interface OasObjectValidator { /** * @param context validation context * @param location OpenAPI Object location * @param oasObject OpenAPI Object * @return validation violations, maybe empty list */ List validate(OasValidationContext context, OasObjectPropertyLocation location, T oasObject); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/OasSpecValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.OpenAPI; import java.util.List; /** * OAS Spec validator */ public interface OasSpecValidator { List validate(OasValidationContext context, OpenAPI openAPI); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/OasValidationContext.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.OpenAPI; import java.util.HashMap; import java.util.Map; /** * OAS object validation context */ public class OasValidationContext { private final OpenAPI openAPI; private final Map attributes = new HashMap<>(); public OasValidationContext(OpenAPI openAPI) { this.openAPI = openAPI; } public OpenAPI getOpenAPI() { return openAPI; } public T getAttribute(String name) { return (T) attributes.get(name); } public void setAttribute(String name, T attr) { this.attributes.put(name, attr); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/OasViolation.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import java.util.Objects; import java.util.StringJoiner; /** * OpenAPI v3 validation violation */ public class OasViolation { /** * Object location */ private final OasObjectPropertyLocation location; /** * Error message */ private final String error; public OasViolation(OasObjectPropertyLocation location, String error) { this.location = location; this.error = error; } public OasObjectPropertyLocation getLocation() { return location; } public String getError() { return error; } @Override public String toString() { return new StringJoiner(", ", OasViolation.class.getSimpleName() + "[", "]") .add("location=" + location) .add("error='" + error + "'") .toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OasViolation that = (OasViolation) o; return Objects.equals(location, that.location) && Objects.equals(error, that.error); } @Override public int hashCode() { return Objects.hash(location, error); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ObjectPropertyRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Object property should not be null validator * * @param Objects defined in OpenAPI Specification * @param

Property type */ public abstract class ObjectPropertyRequiredValidator implements OasObjectValidator { @Override final public List validate(OasValidationContext context, OasObjectPropertyLocation location, T oasObject) { if (StringUtils.isNotBlank(get$ref(oasObject))) { return emptyList(); } P propertyObject = getPropertyObject(oasObject); if (propertyObject == null) { OasObjectPropertyLocation propertyLoc = location.property(getPropertyName(), getPropertyType()); return singletonList(new OasViolation(propertyLoc, ViolationMessages.REQUIRED)); } if (propertyObject != null && String.class.equals(propertyObject.getClass()) && StringUtils.isBlank((CharSequence) propertyObject)) { OasObjectPropertyLocation propertyLoc = location.property(getPropertyName(), getPropertyType()); return singletonList(new OasViolation(propertyLoc, ViolationMessages.REQUIRED)); } return emptyList(); } protected abstract String get$ref(T oasObject); protected abstract P getPropertyObject(T oasObject); protected abstract String getPropertyName(); protected abstract OasObjectType getPropertyType(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ObjectPropertyValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.commons.lang3.StringUtils; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils.doValidateProperty; import static java.util.Collections.emptyList; /** * OAS Object object property validator * * @param Objects defined in OpenAPI Specification * @param

Property type */ public abstract class ObjectPropertyValidator implements OasObjectValidator { private final List> oasObjectValidators; protected ObjectPropertyValidator(List> oasObjectValidators) { this.oasObjectValidators = oasObjectValidators; } @Override final public List validate(OasValidationContext context, OasObjectPropertyLocation location, T oasObject) { if (StringUtils.isNotBlank(get$ref(oasObject))) { return emptyList(); } P propertyObject = getPropertyObject(oasObject); if (propertyObject == null) { return emptyList(); } OasObjectPropertyLocation propertyLoc = location.property(getPropertyName(), getPropertyType()); return doValidateProperty(context, propertyLoc, propertyObject, oasObjectValidators); } protected abstract String get$ref(T oasObject); protected abstract P getPropertyObject(T oasObject); protected abstract String getPropertyName(); protected abstract OasObjectType getPropertyType(); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/OpenApiValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.OpenAPI; /** * OpenAPI Object validator */ public interface OpenApiValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/OperationValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.Operation; /** * Operation Object validator */ public interface OperationValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ParameterValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.parameters.Parameter; /** * Parameter Object validator */ public interface ParameterValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/PathItemValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.PathItem; /** * Path Item Object validator */ public interface PathItemValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/PathsValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.Paths; /** * Paths Object validator */ public interface PathsValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/RequestBodyValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.parameters.RequestBody; /** * Request Object validator */ public interface RequestBodyValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ResponseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.responses.ApiResponse; /** * Response Object validator */ public interface ResponseValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ResponsesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.responses.ApiResponses; /** * Responses Object validator */ public interface ResponsesValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/SchemaValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.media.Schema; /** * Schema Object validator */ public interface SchemaValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/SecuritySchemeValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.security.SecurityScheme; /** * Security Scheme Object validator */ public interface SecuritySchemeValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ServerValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.servers.Server; /** * Server Object validator */ public interface ServerValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/TagValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; import io.swagger.v3.oas.models.tags.Tag; /** * Tag Object validator */ public interface TagValidator extends OasObjectValidator { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/api/ViolationMessages.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.api; public abstract class ViolationMessages { public static final String REQUIRED = "Required"; public static final String MUST_BE_EMPTY = "This field is no allowed"; public static final String LOWER_CAMEL_CASE = "Must be lower camel case"; public static final String UPPER_CAMEL_CASE = "Must be upper camel case"; public static final String UPPER_HYPHEN_CASE = "Must be upper hyphen case"; } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/CallbackValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.CallbackValidator; public interface CallbackValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/ComponentsValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; public interface ComponentsValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/EncodingValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.EncodingValidator; public interface EncodingValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/ExampleValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.ExampleValidator; public interface ExampleValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/HeaderValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.HeaderValidator; public interface HeaderValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/InfoValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.InfoValidator; public interface InfoValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/LinkValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.LinkValidator; public interface LinkValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/MediaTypeValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.MediaTypeValidator; public interface MediaTypeValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/OasObjectValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import java.util.List; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.OasObjectValidator; public interface OasObjectValidatorFactory { List create(FactoryOptions options); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/OasSpecValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; public interface OasSpecValidatorFactory { OasSpecValidator create(FactoryOptions options); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/OpenApiValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; public interface OpenApiValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/OperationValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; public interface OperationValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/ParameterValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; public interface ParameterValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/PathItemValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.PathItemValidator; public interface PathItemValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/PathsValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.PathsValidator; public interface PathsValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/RequestBodyValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.RequestBodyValidator; public interface RequestBodyValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/ResponseValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponseValidator; public interface ResponseValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/ResponsesValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponsesValidator; public interface ResponsesValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/SchemaValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.SchemaValidator; public interface SchemaValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/SecuritySchemeValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.SecuritySchemeValidator; public interface SecuritySchemeValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/ServerValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.ServerValidator; public interface ServerValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/factory/TagValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.factory; import org.apache.servicecomb.toolkit.oasv.validation.api.TagValidator; public interface TagValidatorFactory extends OasObjectValidatorFactory { } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsCallbacksKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; /** * Components Object * .callbacks property key validator */ public class ComponentsCallbacksKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsCallbacksKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getCallbacks(); } @Override protected String getMapPropertyName() { return "callbacks"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsCallbacksValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.CallbackValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.callbacks.Callback; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.CALLBACK; public class ComponentsCallbacksValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsCallbacksValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getCallbacks(); } @Override protected String getMapPropertyName() { return "callbacks"; } @Override protected OasObjectType getValueType() { return CALLBACK; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsExamplesKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; /** * Components Object * .examples property key validator */ public class ComponentsExamplesKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsExamplesKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getExamples(); } @Override protected String getMapPropertyName() { return "examples"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsExamplesValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ExampleValidator; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.examples.Example; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.EXAMPLE; public class ComponentsExamplesValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsExamplesValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getExamples(); } @Override protected String getMapPropertyName() { return "examples"; } @Override protected OasObjectType getValueType() { return EXAMPLE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsHeadersKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; public class ComponentsHeadersKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsHeadersKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsHeadersValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.HeaderValidator; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.headers.Header; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.HEADER; public class ComponentsHeadersValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsHeadersValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } @Override protected OasObjectType getValueType() { return HEADER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsLinksKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; public class ComponentsLinksKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsLinksKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getLinks(); } @Override protected String getMapPropertyName() { return "links"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsLinksValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.LinkValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.links.Link; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.LINK; public class ComponentsLinksValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsLinksValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getLinks(); } @Override protected String getMapPropertyName() { return "links"; } @Override protected OasObjectType getValueType() { return LINK; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsParametersKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; public class ComponentsParametersKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsParametersKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getParameters(); } @Override protected String getMapPropertyName() { return "parameters"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsParametersValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PARAMETER; public class ComponentsParametersValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsParametersValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getParameters(); } @Override protected String getMapPropertyName() { return "parameters"; } @Override protected OasObjectType getValueType() { return PARAMETER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsRequestBodiesKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; public class ComponentsRequestBodiesKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsRequestBodiesKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getRequestBodies(); } @Override protected String getMapPropertyName() { return "requestBodies"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsRequestBodiesValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.RequestBodyValidator; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.parameters.RequestBody; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.REQUEST_BODY; public class ComponentsRequestBodiesValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsRequestBodiesValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getRequestBodies(); } @Override protected String getMapPropertyName() { return "requestBodies"; } @Override protected OasObjectType getValueType() { return REQUEST_BODY; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsResponsesKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; public class ComponentsResponsesKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsResponsesKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getResponses(); } @Override protected String getMapPropertyName() { return "responses"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsResponsesValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponseValidator; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.responses.ApiResponse; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.RESPONSE; public class ComponentsResponsesValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsResponsesValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getResponses(); } @Override protected String getMapPropertyName() { return "responses"; } @Override protected OasObjectType getValueType() { return RESPONSE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsSchemasKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; public class ComponentsSchemasKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsSchemasKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getSchemas(); } @Override protected String getMapPropertyName() { return "schemas"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsSchemasValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.SchemaValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.media.Schema; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; public class ComponentsSchemasValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsSchemasValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getSchemas(); } @Override protected String getMapPropertyName() { return "schemas"; } @Override protected OasObjectType getValueType() { return SCHEMA; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsSecuritySchemesKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import io.swagger.v3.oas.models.Components; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; public class ComponentsSecuritySchemesKeysValidator extends MapPropertyKeysValidator implements ComponentsValidator { public ComponentsSecuritySchemesKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getSecuritySchemes(); } @Override protected String getMapPropertyName() { return "securitySchemes"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/components/ComponentsSecuritySchemesValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.components; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.SecuritySchemeValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.security.SecurityScheme; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SECURITY_SCHEME; public class ComponentsSecuritySchemesValuesValidator extends MapPropertyValuesValidator implements ComponentsValidator { public ComponentsSecuritySchemesValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Components oasObject) { return null; } @Override protected Map getMapProperty(Components components) { return components.getSecuritySchemes(); } @Override protected String getMapPropertyName() { return "securitySchemes"; } @Override protected OasObjectType getValueType() { return SECURITY_SCHEME; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/encoding/EncodingHeadersKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.encoding; import io.swagger.v3.oas.models.media.Encoding; import org.apache.servicecomb.toolkit.oasv.validation.api.EncodingValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; /** * Encoding Object * .headers property key validator */ public class EncodingHeadersKeysValidator extends MapPropertyKeysValidator implements EncodingValidator { public EncodingHeadersKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(Encoding oasObject) { return null; } @Override protected Map getMapProperty(Encoding oasObject) { return oasObject.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/encoding/EncodingHeadersValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.encoding; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.EncodingValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.HeaderValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import io.swagger.v3.oas.models.headers.Header; import io.swagger.v3.oas.models.media.Encoding; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.HEADER; public class EncodingHeadersValuesValidator extends MapPropertyValuesValidator implements EncodingValidator { public EncodingHeadersValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(Encoding oasObject) { return null; } @Override protected Map getMapProperty(Encoding oasObject) { return oasObject.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } @Override protected OasObjectType getValueType() { return HEADER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/header/HeaderSchemaValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.header; import org.apache.servicecomb.toolkit.oasv.validation.api.SchemaValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.HeaderValidator; import io.swagger.v3.oas.models.headers.Header; import io.swagger.v3.oas.models.media.Schema; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; /** * Header Object校验器 * .schema property validator */ public class HeaderSchemaValidator extends ObjectPropertyValidator implements HeaderValidator { public HeaderSchemaValidator(List oasObjectValidators) { super(oasObjectValidators); } @Override protected String get$ref(Header oasObject) { return oasObject.get$ref(); } @Override protected Schema getPropertyObject(Header oasObject) { return oasObject.getSchema(); } @Override protected String getPropertyName() { return "schema"; } @Override protected OasObjectType getPropertyType() { return SCHEMA; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/mediatype/MediaTypeEncodingValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.mediatype; import org.apache.servicecomb.toolkit.oasv.validation.api.EncodingValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MediaTypeValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.media.Encoding; import io.swagger.v3.oas.models.media.MediaType; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.ENCODING; /** * Media Type Object * .encoding property value validator */ public class MediaTypeEncodingValidator extends MapPropertyValuesValidator implements MediaTypeValidator { public MediaTypeEncodingValidator(List encodingValidators) { super(encodingValidators); } @Override protected String get$ref(MediaType oasObject) { return null; } @Override protected Map getMapProperty(MediaType oasObject) { return oasObject.getEncoding(); } @Override protected String getMapPropertyName() { return "encoding"; } @Override protected OasObjectType getValueType() { return ENCODING; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/mediatype/MediaTypeSchemaValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.mediatype; import org.apache.servicecomb.toolkit.oasv.validation.api.MediaTypeValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.SchemaValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.media.Schema; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; /** * Media Type Object * .schema property validator */ public class MediaTypeSchemaValidator extends ObjectPropertyValidator implements MediaTypeValidator { public MediaTypeSchemaValidator(List schemaValidators) { super(schemaValidators); } @Override protected String get$ref(MediaType oasObject) { return null; } @Override protected Schema getPropertyObject(MediaType oasObject) { return oasObject.getSchema(); } @Override protected String getPropertyName() { return "schema"; } @Override protected OasObjectType getPropertyType() { return SCHEMA; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/openapi/OpenApiComponentsValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyValidator; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; /** * OpenAPI Object * .components(Components Object) * validator */ public class OpenApiComponentsValidator extends ObjectPropertyValidator implements OpenApiValidator { public OpenApiComponentsValidator( List componentsValidators) { super(componentsValidators); } @Override protected String get$ref(OpenAPI oasObject) { return null; } @Override protected Components getPropertyObject(OpenAPI oasObject) { return oasObject.getComponents(); } @Override protected String getPropertyName() { return "components"; } @Override protected OasObjectType getPropertyType() { return COMPONENTS; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/openapi/OpenApiInfoValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.validation.api.InfoValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyValidator; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; import java.util.List; /** * OpenAPI Object * .info (Info Object) * validator */ public class OpenApiInfoValidator extends ObjectPropertyValidator implements OpenApiValidator { public OpenApiInfoValidator(List infoValidators) { super(infoValidators); } @Override protected String get$ref(OpenAPI oasObject) { return null; } @Override protected Info getPropertyObject(OpenAPI oasObject) { return oasObject.getInfo(); } @Override protected String getPropertyName() { return "info"; } @Override protected OasObjectType getPropertyType() { return OasObjectType.INFO; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/openapi/OpenApiPathsValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.PathsValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyValidator; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Paths; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATHS; /** * OpenAPI Object * .paths(Paths Object) * validator */ public class OpenApiPathsValidator extends ObjectPropertyValidator implements OpenApiValidator { public OpenApiPathsValidator(List pathsValidators) { super(pathsValidators); } @Override protected String get$ref(OpenAPI oasObject) { return null; } @Override protected Paths getPropertyObject(OpenAPI oasObject) { return oasObject.getPaths(); } @Override protected String getPropertyName() { return "paths"; } @Override protected OasObjectType getPropertyType() { return PATHS; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/openapi/OpenApiServersValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ServerValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ListPropertyValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.servers.Server; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SERVER; /** * OpenAPI Object * .servers(List of Server Object) * validator */ public class OpenApiServersValidator extends ListPropertyValidator implements OpenApiValidator { public OpenApiServersValidator(List serverValidators) { super(serverValidators); } @Override protected String get$ref(OpenAPI oasObject) { return null; } @Override protected List getListProperty(OpenAPI oasObject) { return oasObject.getServers(); } @Override protected String getListPropertyName() { return "servers"; } @Override protected OasObjectType getElementType() { return SERVER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/openapi/OpenApiTagsValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.openapi; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.TagValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ListPropertyValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.tags.Tag; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.TAG; /** * OpenAPI Object * .tags(List of Tag Object) * validator */ public class OpenApiTagsValidator extends ListPropertyValidator implements OpenApiValidator { public OpenApiTagsValidator(List tagValidators) { super(tagValidators); } @Override protected String get$ref(OpenAPI oasObject) { return null; } @Override protected List getListProperty(OpenAPI oasObject) { return oasObject.getTags(); } @Override protected String getListPropertyName() { return "tags"; } @Override protected OasObjectType getElementType() { return TAG; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/operation/OperationParametersValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ListPropertyValidator; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PARAMETER; /** * Operation Object * .parameters property validator */ public class OperationParametersValidator extends ListPropertyValidator implements OperationValidator { public OperationParametersValidator(List parameterValidators) { super(parameterValidators); } @Override protected String get$ref(Operation oasObject) { return null; } @Override protected List getListProperty(Operation oasObject) { return oasObject.getParameters(); } @Override protected String getListPropertyName() { return "parameters"; } @Override protected OasObjectType getElementType() { return PARAMETER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/operation/OperationRequestBodyValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.RequestBodyValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyValidator; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.parameters.RequestBody; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.REQUEST_BODY; /** * Operation Object * .requestBody property validator */ public class OperationRequestBodyValidator extends ObjectPropertyValidator implements OperationValidator { public OperationRequestBodyValidator( List requestBodyValidators) { super(requestBodyValidators); } @Override protected String get$ref(Operation oasObject) { return null; } @Override protected RequestBody getPropertyObject(Operation oasObject) { return oasObject.getRequestBody(); } @Override protected String getPropertyName() { return "requestBody"; } @Override protected OasObjectType getPropertyType() { return REQUEST_BODY; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/operation/OperationResponsesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponsesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyValidator; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.responses.ApiResponses; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.RESPONSES; /** * Operation Object * .responses property validator */ public class OperationResponsesValidator extends ObjectPropertyValidator implements OperationValidator { public OperationResponsesValidator(List responseValidators) { super(responseValidators); } @Override protected String get$ref(Operation oasObject) { return null; } @Override protected ApiResponses getPropertyObject(Operation oasObject) { return oasObject.getResponses(); } @Override protected String getPropertyName() { return "responses"; } @Override protected OasObjectType getPropertyType() { return RESPONSES; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/parameter/ParameterContentValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.parameter; import org.apache.servicecomb.toolkit.oasv.validation.api.MediaTypeValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.MEDIA_TYPE; /** * Parameter Object属性校验器 * .content property validator */ public class ParameterContentValidator extends MapPropertyValuesValidator implements ParameterValidator { public ParameterContentValidator(List mediaTypeValidators) { super(mediaTypeValidators); } @Override protected String get$ref(Parameter oasObject) { return oasObject.get$ref(); } @Override protected Map getMapProperty(Parameter oasObject) { return oasObject.getContent(); } @Override protected String getMapPropertyName() { return "content"; } @Override protected OasObjectType getValueType() { return MEDIA_TYPE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/parameter/ParameterSchemaValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.parameter; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.SchemaValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyValidator; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; /** * Parameter Object属性校验器 * .schema property validator */ public class ParameterSchemaValidator extends ObjectPropertyValidator implements ParameterValidator { public ParameterSchemaValidator( List schemaValidators) { super(schemaValidators); } @Override protected String get$ref(Parameter oasObject) { return oasObject.get$ref(); } @Override protected Schema getPropertyObject(Parameter oasObject) { return oasObject.getSchema(); } @Override protected String getPropertyName() { return "schema"; } @Override protected OasObjectType getPropertyType() { return SCHEMA; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/pathitem/PathItemOperationsValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.pathitem; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils; import org.apache.servicecomb.toolkit.oasv.validation.api.*; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.PathItem; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; import static java.util.Collections.emptyList; /** * Path Item Object * .get / .put / .post / .delete / .options / .head / .patch / .trace * Operation Object * validator */ public class PathItemOperationsValidator implements PathItemValidator { private final List operationValidators; public PathItemOperationsValidator(List operationValidators) { this.operationValidators = operationValidators; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, PathItem oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } List violations = new ArrayList<>(); Map operationMap = oasObject.readOperationsMap(); for (Map.Entry entry : operationMap.entrySet()) { PathItem.HttpMethod method = entry.getKey(); Operation operation = entry.getValue(); OasObjectPropertyLocation operationLocation = location.property(method.toString().toLowerCase(), OasObjectType.OPERATION); violations.addAll( OasObjectValidatorUtils.doValidateProperty(context, operationLocation, operation, operationValidators)); } return violations; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/pathitem/PathItemParametersValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.pathitem; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ListPropertyValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.PathItemValidator; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.parameters.Parameter; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PARAMETER; /** * Path Item Object * .parameters (List of Parameter Object) * validator */ public class PathItemParametersValidator extends ListPropertyValidator implements PathItemValidator { public PathItemParametersValidator(List parameterValidators) { super(parameterValidators); } @Override protected String get$ref(PathItem oasObject) { return oasObject.get$ref(); } @Override protected List getListProperty(PathItem oasObject) { return oasObject.getParameters(); } @Override protected String getListPropertyName() { return "parameters"; } @Override protected OasObjectType getElementType() { return PARAMETER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/paths/PathsPathItemsValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.paths; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.PathItemValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.PathsValidator; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.Paths; import java.util.ArrayList; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils.doValidateProperty; /** * Paths Object * /{path} (Map [String, Path Item Object]) * validator */ public class PathsPathItemsValidator implements PathsValidator { private final List pathItemValidators; public PathsPathItemsValidator(List pathItemValidators) { this.pathItemValidators = pathItemValidators; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Paths oasObject) { List violations = new ArrayList<>(); for (Map.Entry entry : oasObject.entrySet()) { String path = entry.getKey(); PathItem pathItem = entry.getValue(); OasObjectPropertyLocation pathItemLocation = location.property(path, OasObjectType.PATH_ITEM); violations.addAll(doValidateProperty(context, pathItemLocation, pathItem, pathItemValidators)); } return violations; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/requestbody/RequestBodyContentValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.requestbody; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.MediaTypeValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.RequestBodyValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.parameters.RequestBody; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.MEDIA_TYPE; /** * Request Object * .content property value validator */ public class RequestBodyContentValidator extends MapPropertyValuesValidator implements RequestBodyValidator { public RequestBodyContentValidator(List mediaTypeValidators) { super(mediaTypeValidators); } @Override protected String get$ref(RequestBody oasObject) { return oasObject.get$ref(); } @Override protected Map getMapProperty(RequestBody oasObject) { return oasObject.getContent(); } @Override protected String getMapPropertyName() { return "content"; } @Override protected OasObjectType getValueType() { return MEDIA_TYPE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/response/ResponseContentValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.response; import org.apache.servicecomb.toolkit.oasv.validation.api.MediaTypeValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.responses.ApiResponse; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.MEDIA_TYPE; /** * Response Object * .content property value validator */ public class ResponseContentValidator extends MapPropertyValuesValidator implements ResponseValidator { public ResponseContentValidator(List mediaTypeValidators) { super(mediaTypeValidators); } @Override protected String get$ref(ApiResponse oasObject) { return oasObject.get$ref(); } @Override protected Map getMapProperty(ApiResponse oasObject) { return oasObject.getContent(); } @Override protected String getMapPropertyName() { return "content"; } @Override protected OasObjectType getValueType() { return MEDIA_TYPE; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/response/ResponseHeadersKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.response; import io.swagger.v3.oas.models.responses.ApiResponse; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyKeysValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponseValidator; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; /** * ApiResponse Object * .headers property key validator */ public class ResponseHeadersKeysValidator extends MapPropertyKeysValidator implements ResponseValidator { public ResponseHeadersKeysValidator(Predicate keyPredicate, Function errorFunction) { super(keyPredicate, errorFunction); } @Override protected String get$ref(ApiResponse oasObject) { return oasObject.get$ref(); } @Override protected Map getMapProperty(ApiResponse oasObject) { return oasObject.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/response/ResponseHeadersValuesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.response; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.HeaderValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.MapPropertyValuesValidator; import io.swagger.v3.oas.models.headers.Header; import io.swagger.v3.oas.models.responses.ApiResponse; import java.util.List; import java.util.Map; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.HEADER; public class ResponseHeadersValuesValidator extends MapPropertyValuesValidator implements ResponseValidator { public ResponseHeadersValuesValidator(List valueValidators) { super(valueValidators); } @Override protected String get$ref(ApiResponse oasObject) { return oasObject.get$ref(); } @Override protected Map getMapProperty(ApiResponse components) { return components.getHeaders(); } @Override protected String getMapPropertyName() { return "headers"; } @Override protected OasObjectType getValueType() { return HEADER; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/responses/ResponsesResponsesValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.responses; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponsesValidator; import org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponses; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Responses Object * .default / .{Http Status Code} property validator */ public class ResponsesResponsesValidator implements ResponsesValidator { private final List responseValidators; public ResponsesResponsesValidator(List responseValidators) { this.responseValidators = responseValidators; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, ApiResponses oasObject) { List violations = new ArrayList<>(); for (Map.Entry entry : oasObject.entrySet()) { String statusCode = entry.getKey(); ApiResponse response = entry.getValue(); OasObjectPropertyLocation responseLoc = location.property(statusCode, OasObjectType.RESPONSE); violations.addAll(OasObjectValidatorUtils.doValidateProperty(context, responseLoc, response, responseValidators)); } return violations; } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/schema/SchemaPropertiesKeysValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.schema; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.collections4.MapUtils; import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; import static java.util.Collections.emptyList; /** * Schema Object * .properties property key validator */ public class SchemaPropertiesKeysValidator extends SchemaRecursiveValidatorTemplate { private final Predicate keyPredicate; private final Function errorFunction; public SchemaPropertiesKeysValidator(Predicate keyPredicate, Function errorFunction) { this.keyPredicate = keyPredicate; this.errorFunction = errorFunction; } @Override protected List validateCurrentSchemaObject(OasValidationContext context, Schema oasObject, OasObjectPropertyLocation location) { Map properties = oasObject.getProperties(); if (MapUtils.isEmpty(properties)) { return emptyList(); } return OasObjectValidatorUtils.doValidateMapPropertyKeys( location, "properties", properties, keyPredicate, errorFunction ); } } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/skeleton/schema/SchemaRecursiveValidatorTemplate.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.skeleton.schema; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.SchemaValidator; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ComposedSchema; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; import static org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils.doValidateListProperty; import static org.apache.servicecomb.toolkit.oasv.validation.util.OasObjectValidatorUtils.doValidateMapPropertyValues; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Template for recursively validate current Schema Object and Schema Object appears in its properties */ public abstract class SchemaRecursiveValidatorTemplate implements SchemaValidator { @Override public final List validate(OasValidationContext context, OasObjectPropertyLocation location, Schema oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (oasObject instanceof ComposedSchema) { return validateComposedSchema(context, (ComposedSchema) oasObject, location); } if (oasObject instanceof ArraySchema) { return validateArraySchema(context, (ArraySchema) oasObject, location); } return validateOrdinarySchema(context, oasObject, location); } private List validateOrdinarySchema(OasValidationContext context, Schema oasObject, OasObjectPropertyLocation location) { List violations = new ArrayList<>(); violations.addAll(validateCurrentSchemaObject(context, oasObject, location)); violations.addAll( doValidateMapPropertyValues( context, location, "properties", oasObject.getProperties(), SCHEMA, singletonList(this) ) ); return violations; } private List validateArraySchema(OasValidationContext context, ArraySchema oasObject, OasObjectPropertyLocation location) { return validate(context, location.property("items", SCHEMA), oasObject.getItems()); } private List validateComposedSchema(OasValidationContext context, ComposedSchema oasObject, OasObjectPropertyLocation location) { List violations = new ArrayList<>(); violations.addAll( doValidateListProperty( context, location, "allOf", oasObject.getAllOf(), SCHEMA, singletonList(this) ) ); violations.addAll( doValidateListProperty( context, location, "anyOf", oasObject.getAnyOf(), SCHEMA, singletonList(this) ) ); violations.addAll( doValidateListProperty( context, location, "oneOf", oasObject.getOneOf(), SCHEMA, singletonList(this) ) ); return violations; } protected abstract List validateCurrentSchemaObject(OasValidationContext context, Schema oasObject, OasObjectPropertyLocation location); } ================================================ FILE: oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/util/OasObjectValidatorUtils.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.util; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.*; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; import static java.util.Collections.emptyList; public abstract class OasObjectValidatorUtils { private OasObjectValidatorUtils() { // singleton } /** * @param context * @param propertyLoc * @param propertyObject * @param validators * @param * @return */ public static List doValidateProperty( OasValidationContext context, OasObjectPropertyLocation propertyLoc, T propertyObject, List> validators) { List violations = new ArrayList<>(); for (OasObjectValidator validator : validators) { violations.addAll(validator.validate(context, propertyLoc, propertyObject)); } return violations; } /** * @param * @param context * @param ownerLocation location of owner OAS object who own this listProperty * @param listPropertyName listProperty name appears in owner OAS object * @param listProperty null-safe * @param elementType type of elements in listProperty * @param validators * @return */ public static List doValidateListProperty( OasValidationContext context, OasObjectPropertyLocation ownerLocation, String listPropertyName, List listProperty, OasObjectType elementType, List> validators) { if (CollectionUtils.isEmpty(listProperty)) { return emptyList(); } List violations = new ArrayList<>(); for (int i = 0; i < listProperty.size(); i++) { T object = listProperty.get(i); String elementName = listPropertyName + "[" + i + "]"; OasObjectPropertyLocation elementLoc = ownerLocation.property(elementName, elementType); violations.addAll(doValidateProperty(context, elementLoc, object, validators)); } return violations; } /** * @param ownerLocation location of owner OAS object who own this mapProperty * @param mapPropertyName mapProperty name appears in owner OAS object * @param mapProperty null-safe * @param keyPredicate * @param errorMessage * @param * @return */ public static List doValidateMapPropertyKeys( OasObjectPropertyLocation ownerLocation, String mapPropertyName, Map mapProperty, Predicate keyPredicate, Function errorMessage ) { if (MapUtils.isEmpty(mapProperty)) { return emptyList(); } List violations = new ArrayList<>(); for (Map.Entry entry : mapProperty.entrySet()) { String key = entry.getKey(); String keyName = mapPropertyName + ".'" + key + "'"; OasObjectPropertyLocation keyLoc = ownerLocation.property(keyName); if (!keyPredicate.test(key)) { violations.add(new OasViolation(keyLoc, errorMessage.apply(key))); } } return violations; } /** * @param * @param context * @param ownerLocation location of owner OAS object who own this mapProperty * @param mapPropertyName mapProperty name appears in owner OAS object * @param mapProperty null-safe * @param valueType type of values in mapProperty * @param validators * @return */ public static List doValidateMapPropertyValues( OasValidationContext context, OasObjectPropertyLocation ownerLocation, String mapPropertyName, Map mapProperty, OasObjectType valueType, List> validators ) { if (MapUtils.isEmpty(mapProperty)) { return emptyList(); } List violations = new ArrayList<>(); for (Map.Entry entry : mapProperty.entrySet()) { String key = entry.getKey(); T value = entry.getValue(); String keyName = mapPropertyName + ".'" + key + "'"; OasObjectPropertyLocation valueLoc = ownerLocation.property(keyName, valueType); violations.addAll(doValidateProperty(context, valueLoc, value, validators)); } return violations; } } ================================================ FILE: oas-validator/oas-validator-core/src/test/java/org/apache/servicecomb/toolkit/oasv/common/OasObjectPropertyLocationTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.common; import static org.junit.Assert.assertEquals; import org.junit.Test; public class OasObjectPropertyLocationTest { @Test public void toPathString() { assertEquals("$.foo.bar", OasObjectPropertyLocation.toPathString(OasObjectPropertyLocation.root().property("foo").property("bar"))); assertEquals("", OasObjectPropertyLocation.toPathString(null)); } } ================================================ FILE: oas-validator/oas-validator-core/src/test/java/org/apache/servicecomb/toolkit/oasv/util/StringCaseUtilsTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.util; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; public class StringCaseUtilsTest { @Test public void isLowerCamelCase() { assertThat(StringCaseUtils.isLowerCamelCase("")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("A")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("A0")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("Aa")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("AA")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("0")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("00")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("0a")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("0A")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("a")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("a0")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aa")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aA")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("a00")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("a0a")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("a0A")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aa0")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aaa")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aaA")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aaA0")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aaAa")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aaAA")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("aaA00")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aaA0a")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("aaA0A")).isTrue(); assertThat(StringCaseUtils.isLowerCamelCase("_aaA00")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("a_aA00")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("aa_A00")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("aaA_00")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("aaA0_0")).isFalse(); assertThat(StringCaseUtils.isLowerCamelCase("aaA00_")).isFalse(); } @Test public void isUpperCamelCase() { assertThat(StringCaseUtils.isUpperCamelCase("")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("A")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("A0")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("Aa")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("AA")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("0")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("00")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("0a")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("0A")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("a")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("a0")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("aa")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("aA")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("A00")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("A0a")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("A0A")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("Aa0")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("Aaa")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("AaA")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("AaA0")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("AaAa")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("AaAA")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("AaA00")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("AaA0a")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("AaA0A")).isTrue(); assertThat(StringCaseUtils.isUpperCamelCase("_aaA00")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("a_aA00")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("aa_A00")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("aaA_00")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("aaA0_0")).isFalse(); assertThat(StringCaseUtils.isUpperCamelCase("aaA00_")).isFalse(); } @Test public void isUpperHyphenCase() { assertThat(StringCaseUtils.isUpperHyphenCase("")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("A0")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("Aa")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("AA")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("0")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("00")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("0a")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("0A")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("a")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("a0")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("aa")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("aA")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A00")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("A0a")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("A0A")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A-A")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("A-a")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A-0")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A-AA")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("AA-A")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("AA-a")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("AA-0")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("Aa-A")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("Aa-Aa")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("Aa-A0")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-A")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-Aa")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-A0")).isTrue(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-a0")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-aa")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-aA")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-0")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-00")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-0a")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("A0-0A")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("_aaA00")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("a_aA00")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("aa_A00")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("aaA_00")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("aaA0_0")).isFalse(); assertThat(StringCaseUtils.isUpperHyphenCase("aaA00_")).isFalse(); } @Test public void testIsMatchCase() { assertThat(StringCaseUtils.isMatchCase("lower-camel-case", "a0")).isTrue(); assertThat(StringCaseUtils.isMatchCase("upper-camel-case", "A0")).isTrue(); assertThat(StringCaseUtils.isMatchCase("upper-hyphen-case", "A-A")).isTrue(); } } ================================================ FILE: oas-validator/oas-validator-core/src/test/java/org/apache/servicecomb/toolkit/oasv/util/SyntaxCheckerTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.util; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.*; import java.util.List; import org.junit.Test; import io.swagger.v3.parser.util.ClasspathHelper; public class SyntaxCheckerTest { @Test public void checkGood() { String yaml = loadRelative("syntax-good.yaml"); List errors = SyntaxChecker.check(yaml); assertThat(errors).isEmpty(); } @Test public void checkBad() { String yaml = loadRelative("syntax-bad.yaml"); List errors = SyntaxChecker.check(yaml); assertThat(errors).containsExactly("attribute paths.'/pets'(post).summary2 is unexpected"); } private String loadRelative(String filename) { String basePath = getClass().getPackage().getName().replaceAll("\\.", "/"); return ClasspathHelper.loadFileFromClasspath(basePath + "/" + filename); } } ================================================ FILE: oas-validator/oas-validator-core/src/test/resources/org/apache/servicecomb/toolkit/oasv/util/syntax-bad.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Pet petstore paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary2: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-core/src/test/resources/org/apache/servicecomb/toolkit/oasv/util/syntax-good.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Pet petstore paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-core-spring/pom.xml ================================================ org.apache.servicecomb.toolkit oas-validator-parent 0.3.0-SNAPSHOT ../pom.xml 4.0.0 oas-validator-core-spring org.apache.servicecomb.toolkit oas-validator-core org.springframework.boot spring-boot-starter org.apache.maven.plugins maven-surefire-plugin org.apache.maven.plugins maven-surefire-report-plugin ================================================ FILE: oas-validator/oas-validator-core-spring/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/config/OasDiffValidatorsSkeletonConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.config; import java.util.List; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.CallbackDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.DefaultOasSpecDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.EncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.HeaderDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.InfoDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.LinkDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.MediaTypeDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasSpecDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OpenApiDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OperationDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ParameterDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathItemDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.PathsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.RequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponseDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ResponsesDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaAddValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaCompareValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaDelValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.SchemaDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.ServerDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.TagDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsCallbacksDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsHeadersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsLinksDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsParametersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsRequestBodiesDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.components.ComponentsResponsesDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.encoding.EncodingHeadersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.header.HeaderSchemaDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.mediatype.MediaTypeEncodingDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.mediatype.MediaTypeSchemaDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiComponentsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiInfoDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiPathsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiServersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.openapi.OpenApiTagsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation.OperationParametersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation.OperationRequestBodyDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.operation.OperationResponsesDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.parameter.ParameterContentDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.parameter.ParameterSchemaDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.pathitem.PathItemOperationsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.pathitem.PathItemParametersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.paths.PathsPathItemsDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.requestbody.RequestBodyContentDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.response.ResponseContentDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.response.ResponseHeadersDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.responses.ResponsesResponsesDiffValidator; import org.apache.servicecomb.toolkit.oasv.diffvalidation.skeleton.schema.SchemaDiffValidatorEngine; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class OasDiffValidatorsSkeletonConfiguration { @Bean public OasSpecDiffValidator oasSpecDiffValidator(List openApiDiffValidators) { return new DefaultOasSpecDiffValidator(openApiDiffValidators); } @Bean public ComponentsDiffValidator componentsCallbacksDiffValidator( List diffValidators) { return new ComponentsCallbacksDiffValidator(diffValidators); } @Bean public ComponentsDiffValidator componentsHeadersDiffValidator( List diffValidators) { return new ComponentsHeadersDiffValidator(diffValidators); } @Bean public ComponentsDiffValidator componentsLinksDiffValidator( List diffValidators) { return new ComponentsLinksDiffValidator(diffValidators); } @Bean public ComponentsDiffValidator componentsParametersDiffValidator( List diffValidators) { return new ComponentsParametersDiffValidator(diffValidators); } @Bean public ComponentsDiffValidator componentsRequestBodiesDiffValidator( List diffValidators) { return new ComponentsRequestBodiesDiffValidator(diffValidators); } @Bean public ComponentsDiffValidator componentsResponsesDiffValidator( List diffValidators) { return new ComponentsResponsesDiffValidator(diffValidators); } @Bean public EncodingDiffValidator encodingHeadersDiffValidator( List diffValidators) { return new EncodingHeadersDiffValidator(diffValidators); } @Bean public HeaderDiffValidator headerSchemaDiffValidator( List diffValidators) { return new HeaderSchemaDiffValidator(diffValidators); } @Bean public MediaTypeDiffValidator mediaTypeEncodingDiffValidator( List diffValidators) { return new MediaTypeEncodingDiffValidator(diffValidators); } @Bean public MediaTypeDiffValidator mediaTypeSchemaDiffValidator( List diffValidators) { return new MediaTypeSchemaDiffValidator(diffValidators); } @Bean public OpenApiDiffValidator openApiComponentsDiffValidator( List diffValidators) { return new OpenApiComponentsDiffValidator(diffValidators); } @Bean public OpenApiDiffValidator openApiInfoDiffValidator( List diffValidators) { return new OpenApiInfoDiffValidator(diffValidators); } @Bean public OpenApiDiffValidator openApiPathsDiffValidator( List diffValidators) { return new OpenApiPathsDiffValidator(diffValidators); } @Bean public OpenApiDiffValidator openApiServersDiffValidator( List diffValidators) { return new OpenApiServersDiffValidator(diffValidators); } @Bean public OpenApiDiffValidator openApiTagsDiffValidator( List diffValidators) { return new OpenApiTagsDiffValidator(diffValidators); } @Bean public OperationDiffValidator operationParametersDiffValidator( List diffValidators) { return new OperationParametersDiffValidator(diffValidators); } @Bean public OperationDiffValidator operationRequestBodyDiffValidator( List diffValidators) { return new OperationRequestBodyDiffValidator(diffValidators); } @Bean public OperationDiffValidator operationResponsesDiffValidator( List diffValidators) { return new OperationResponsesDiffValidator(diffValidators); } @Bean public ParameterDiffValidator parameterContentDiffValidator( List diffValidators) { return new ParameterContentDiffValidator(diffValidators); } @Bean public ParameterDiffValidator parameterSchemaDiffValidator( List diffValidators) { return new ParameterSchemaDiffValidator(diffValidators); } @Bean public PathItemDiffValidator pathItemOperationsDiffValidator( List diffValidators) { return new PathItemOperationsDiffValidator(diffValidators); } @Bean public PathItemDiffValidator pathItemParametersDiffValidator( List diffValidators) { return new PathItemParametersDiffValidator(diffValidators); } @Bean public PathsDiffValidator pathsPathItemsDiffValidator( List diffValidators) { return new PathsPathItemsDiffValidator(diffValidators); } @Bean public RequestBodyDiffValidator requestBodyContentDiffValidator( List diffValidators) { return new RequestBodyContentDiffValidator(diffValidators); } @Bean public ResponseDiffValidator responseContentDiffValidator( List diffValidators) { return new ResponseContentDiffValidator(diffValidators); } @Bean public ResponseDiffValidator responseHeadersDiffValidator( List diffValidators) { return new ResponseHeadersDiffValidator(diffValidators); } @Bean public ResponsesDiffValidator responsesResponsesDiffValidator( List diffValidators) { return new ResponsesResponsesDiffValidator(diffValidators); } @Bean public SchemaDiffValidator schemaDiffValidatorEngine( List schemaNewValidators, List schemaDelValidators, List schemaCompareValidators) { return new SchemaDiffValidatorEngine(schemaNewValidators, schemaDelValidators, schemaCompareValidators); } } ================================================ FILE: oas-validator/oas-validator-core-spring/src/main/resources/META-INF/spring.factories ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.apache.servicecomb.toolkit.oasv.diffvalidation.config.OasDiffValidatorsSkeletonConfiguration ================================================ FILE: oas-validator/oas-validator-style/pom.xml ================================================ org.apache.servicecomb.toolkit oas-validator-parent 0.3.0-SNAPSHOT ../pom.xml 4.0.0 oas-validator-style 2.11.0 org.apache.servicecomb.toolkit oas-validator-core org.springframework spring-context org.slf4j slf4j-api provided org.apache.servicecomb.toolkit oas-validator-test test org.springframework.boot spring-boot-starter-test test org.apache.maven.plugins maven-surefire-plugin org.apache.maven.plugins maven-surefire-report-plugin ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/StyleCheckParser.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style; import io.swagger.v3.parser.OpenAPIV3Parser; import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.core.models.SwaggerParseResult; public abstract class StyleCheckParser { private StyleCheckParser() { // singleton } public static SwaggerParseResult parseYaml(String yaml) { OpenAPIV3Parser parser = new OpenAPIV3Parser(); return parser.readContents(yaml, null, createParseOptions()); } private static ParseOptions createParseOptions() { ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(true); parseOptions.setResolveCombinators(false); parseOptions.setResolveFully(false); parseOptions.setFlatten(false); return parseOptions; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultComponentsValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.components.*; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.*; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.*; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultComponentsValidatorFactory implements ComponentsValidatorFactory { private HeaderValidatorFactory headerValidatorFactory; private ParameterValidatorFactory parameterValidatorFactory; private RequestBodyValidatorFactory requestBodyValidatorFactory; private ResponseValidatorFactory responseValidatorFactory; private SchemaValidatorFactory schemaValidatorFactory; private SecuritySchemeValidatorFactory securitySchemeValidatorFactory; public DefaultComponentsValidatorFactory( HeaderValidatorFactory headerValidatorFactory, ParameterValidatorFactory parameterValidatorFactory, RequestBodyValidatorFactory requestBodyValidatorFactory, ResponseValidatorFactory responseValidatorFactory, SchemaValidatorFactory schemaValidatorFactory, SecuritySchemeValidatorFactory securitySchemeValidatorFactory) { this.headerValidatorFactory = headerValidatorFactory; this.parameterValidatorFactory = parameterValidatorFactory; this.requestBodyValidatorFactory = requestBodyValidatorFactory; this.responseValidatorFactory = responseValidatorFactory; this.schemaValidatorFactory = schemaValidatorFactory; this.securitySchemeValidatorFactory = securitySchemeValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new ComponentsHeadersValuesValidator(headerValidatorFactory.create(options))); validators.add(new ComponentsParametersValuesValidator(parameterValidatorFactory.create(options))); validators.add(new ComponentsRequestBodiesValuesValidator(requestBodyValidatorFactory.create(options))); validators.add(new ComponentsResponsesValuesValidator(responseValidatorFactory.create(options))); validators.add(new ComponentsSchemasValuesValidator(schemaValidatorFactory.create(options))); validators.add(new ComponentsSecuritySchemesValuesValidator(securitySchemeValidatorFactory.create(options))); // concretes addComponentsCallbacksKeysCaseValidator(validators, options); addComponentsExamplesKeysCaseValidator(validators, options); addComponentsHeadersKeysCaseValidator(validators, options); addComponentsLinksKeysCaseValidator(validators, options); addComponentsParametersKeysCaseValidator(validators, options); addComponentsRequestBodiesKeysCaseValidator(validators, options); addComponentsResponsesKeysCaseValidator(validators, options); addComponentsSchemasKeysCaseValidator(validators, options); addComponentsSecuritySchemesKeysCaseValidator(validators, options); return Collections.unmodifiableList(validators); } private void addComponentsCallbacksKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsCallbacksKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsCallbacksKeysCaseValidator(expectedCase)); } } private void addComponentsExamplesKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsExamplesKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsExamplesKeysCaseValidator(expectedCase)); } } private void addComponentsHeadersKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsHeadersKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsHeadersKeysCaseValidator(expectedCase)); } } private void addComponentsLinksKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsLinksKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsLinksKeysCaseValidator(expectedCase)); } } private void addComponentsParametersKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsParametersKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsParametersKeysCaseValidator(expectedCase)); } } private void addComponentsRequestBodiesKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsRequestBodiesKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsRequestBodiesKeysCaseValidator(expectedCase)); } } private void addComponentsResponsesKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsResponsesKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsResponsesKeysCaseValidator(expectedCase)); } } private void addComponentsSchemasKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsSchemasKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsSchemasKeysCaseValidator(expectedCase)); } } private void addComponentsSecuritySchemesKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ComponentsSecuritySchemesKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ComponentsSecuritySchemesKeysCaseValidator(expectedCase)); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultEncodingValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.encoding.EncodingHeadersKeysCaseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.EncodingValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.EncodingValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.HeaderValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.encoding.EncodingHeadersValuesValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultEncodingValidatorFactory implements EncodingValidatorFactory { private final HeaderValidatorFactory headerValidatorFactory; public DefaultEncodingValidatorFactory( HeaderValidatorFactory headerValidatorFactory) { this.headerValidatorFactory = headerValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new EncodingHeadersValuesValidator(headerValidatorFactory.create(options))); // concrete addEncodingHeadersKeysCaseValidator(validators, options); return Collections.unmodifiableList(validators); } private void addEncodingHeadersKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(EncodingHeadersKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new EncodingHeadersKeysCaseValidator(expectedCase)); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultHeaderValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.header.HeaderDescriptionRequiredValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.HeaderValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.HeaderValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.SchemaValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.header.HeaderSchemaValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultHeaderValidatorFactory implements HeaderValidatorFactory { private final SchemaValidatorFactory schemaValidatorFactory; public DefaultHeaderValidatorFactory( SchemaValidatorFactory schemaValidatorFactory) { this.schemaValidatorFactory = schemaValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new HeaderSchemaValidator(schemaValidatorFactory.create(options))); // concretes addHeaderDescriptionRequiredValidator(validators, options); return Collections.unmodifiableList(validators); } private void addHeaderDescriptionRequiredValidator(List validators, FactoryOptions options) { Boolean required = options.getBoolean(HeaderDescriptionRequiredValidator.CONFIG_KEY); if (Boolean.TRUE.equals(required)) { validators.add(new HeaderDescriptionRequiredValidator()); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultInfoValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.info.InfoDescriptionRequiredValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.InfoValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.InfoValidatorFactory; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultInfoValidatorFactory implements InfoValidatorFactory { @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // concretes addInfoDescriptionRequiredValidator(validators, options); return Collections.unmodifiableList(validators); } private void addInfoDescriptionRequiredValidator(List validators, FactoryOptions options) { Boolean required = options.getBoolean(InfoDescriptionRequiredValidator.CONFIG_KEY); if (Boolean.TRUE.equals(required)) { validators.add(new InfoDescriptionRequiredValidator()); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultMediaTypeValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.MediaTypeValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.EncodingValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.MediaTypeValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.SchemaValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.mediatype.MediaTypeEncodingValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.mediatype.MediaTypeSchemaValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultMediaTypeValidatorFactory implements MediaTypeValidatorFactory { private final SchemaValidatorFactory schemaValidatorFactory; private final EncodingValidatorFactory encodingValidatorFactory; public DefaultMediaTypeValidatorFactory( SchemaValidatorFactory schemaValidatorFactory, EncodingValidatorFactory encodingValidatorFactory) { this.schemaValidatorFactory = schemaValidatorFactory; this.encodingValidatorFactory = encodingValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new MediaTypeSchemaValidator(schemaValidatorFactory.create(options))); validators.add(new MediaTypeEncodingValidator(encodingValidatorFactory.create(options))); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultOasSpecValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.DefaultOasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.OasSpecValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.OpenApiValidatorFactory; import org.springframework.stereotype.Component; @Component public class DefaultOasSpecValidatorFactory implements OasSpecValidatorFactory { private final OpenApiValidatorFactory openApiValidatorFactory; public DefaultOasSpecValidatorFactory( OpenApiValidatorFactory openApiValidatorFactory) { this.openApiValidatorFactory = openApiValidatorFactory; } @Override public OasSpecValidator create(FactoryOptions options) { return new DefaultOasSpecValidator(openApiValidatorFactory.create(options)); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultOpenApiValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.openapi.OpenApiSecuritySizeEqValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.openapi.OpenApiTagsSizeGteValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.openapi.OpenApiVersionGteValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.*; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.openapi.*; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultOpenApiValidatorFactory implements OpenApiValidatorFactory { private final TagValidatorFactory tagValidatorFactory; private final InfoValidatorFactory infoValidatorFactory; private final PathsValidatorFactory pathsValidatorFactory; private final ComponentsValidatorFactory componentsValidatorFactory; private final ServerValidatorFactory serverValidatorFactory; public DefaultOpenApiValidatorFactory( TagValidatorFactory tagValidatorFactory, InfoValidatorFactory infoValidatorFactory, PathsValidatorFactory pathsValidatorFactory, ComponentsValidatorFactory componentsValidatorFactory, ServerValidatorFactory serverValidatorFactory) { this.tagValidatorFactory = tagValidatorFactory; this.infoValidatorFactory = infoValidatorFactory; this.pathsValidatorFactory = pathsValidatorFactory; this.componentsValidatorFactory = componentsValidatorFactory; this.serverValidatorFactory = serverValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new OpenApiTagsValidator(tagValidatorFactory.create(options))); validators.add(new OpenApiInfoValidator(infoValidatorFactory.create(options))); validators.add(new OpenApiPathsValidator(pathsValidatorFactory.create(options))); validators.add(new OpenApiComponentsValidator(componentsValidatorFactory.create(options))); validators.add(new OpenApiServersValidator(serverValidatorFactory.create(options))); // concretes addOpenApiSecuritySizeValidator(validators, options); addOpenApiTagsSizeValidator(validators, options); addOpenApiVersionGteValidator(validators, options); return Collections.unmodifiableList(validators); } private void addOpenApiSecuritySizeValidator(List validators, FactoryOptions options) { Integer size = options.getInteger(OpenApiSecuritySizeEqValidator.CONFIG_KEY); if (size != null) { validators.add(new OpenApiSecuritySizeEqValidator(size)); } } private void addOpenApiTagsSizeValidator(List validators, FactoryOptions options) { Integer size = options.getInteger(OpenApiTagsSizeGteValidator.CONFIG_KEY); if (size != null) { validators.add(new OpenApiTagsSizeGteValidator(size)); } } private void addOpenApiVersionGteValidator(List validators, FactoryOptions options) { String versionGte = options.getString(OpenApiVersionGteValidator.CONFIG_KEY); if (versionGte != null) { validators.add(new OpenApiVersionGteValidator(versionGte)); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultOperationValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.operation.*; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.OperationValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.ParameterValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.RequestBodyValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.ResponsesValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation.OperationParametersValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation.OperationRequestBodyValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation.OperationResponsesValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultOperationValidatorFactory implements OperationValidatorFactory { private final ParameterValidatorFactory parameterValidatorFactory; private final ResponsesValidatorFactory responsesValidatorFactory; private final RequestBodyValidatorFactory requestBodyValidatorFactory; public DefaultOperationValidatorFactory( ParameterValidatorFactory parameterValidatorFactory, ResponsesValidatorFactory responsesValidatorFactory, RequestBodyValidatorFactory requestBodyValidatorFactory) { this.parameterValidatorFactory = parameterValidatorFactory; this.responsesValidatorFactory = responsesValidatorFactory; this.requestBodyValidatorFactory = requestBodyValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new OperationParametersValidator(parameterValidatorFactory.create(options))); validators.add(new OperationResponsesValidator(responsesValidatorFactory.create(options))); validators.add(new OperationRequestBodyValidator(requestBodyValidatorFactory.create(options))); // concretes addOperationSummaryRequiredValidator(validators, options); addOperationIdCaseValidator(validators, options); addOperationTagsSizeEqValidator(validators, options); addOperationServersSizeEqValidator(validators, options); addOperationTagsReferenceValidator(validators, options); return Collections.unmodifiableList(validators); } private void addOperationSummaryRequiredValidator(List validators, FactoryOptions options) { Boolean required = options.getBoolean(OperationSummaryRequiredValidator.CONFIG_KEY); if (Boolean.TRUE.equals(required)) { validators.add(new OperationSummaryRequiredValidator()); } } private void addOperationIdCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(OperationIdCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new OperationIdCaseValidator(expectedCase)); } } private void addOperationTagsSizeEqValidator(List validators, FactoryOptions options) { Integer expectedSize = options.getInteger(OperationTagsSizeEqValidator.CONFIG_KEY); if (expectedSize != null) { validators.add(new OperationTagsSizeEqValidator(expectedSize)); } } private void addOperationServersSizeEqValidator(List validators, FactoryOptions options) { Integer expectedSize = options.getInteger(OperationServersSizeEqValidator.CONFIG_KEY); if (expectedSize != null) { validators.add(new OperationServersSizeEqValidator(expectedSize)); } } private void addOperationTagsReferenceValidator(List validators, FactoryOptions options) { Boolean needCheck = options.getBoolean(OperationTagsReferenceValidator.CONFIG_KEY); if (Boolean.TRUE.equals(needCheck)) { validators.add(new OperationTagsReferenceValidator()); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultParameterValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.parameter.*; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.MediaTypeValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.ParameterValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.SchemaValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.parameter.ParameterContentValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.parameter.ParameterSchemaValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultParameterValidatorFactory implements ParameterValidatorFactory { private final SchemaValidatorFactory schemaValidatorFactory; private final MediaTypeValidatorFactory mediaTypeValidatorFactory; public DefaultParameterValidatorFactory( SchemaValidatorFactory schemaValidatorFactory, MediaTypeValidatorFactory mediaTypeValidatorFactory) { this.schemaValidatorFactory = schemaValidatorFactory; this.mediaTypeValidatorFactory = mediaTypeValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new ParameterSchemaValidator(schemaValidatorFactory.create(options))); validators.add(new ParameterContentValidator(mediaTypeValidatorFactory.create(options))); // concretes addParameterNameCookieCaseValidator(validators, options); addParameterNameHeaderCaseValidator(validators, options); addParameterNamePathCaseValidator(validators, options); addParameterNameQueryCaseValidator(validators, options); addParameterDescriptionRequiredValidator(validators, options); return Collections.unmodifiableList(validators); } private void addParameterNameCookieCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ParameterNameCookieCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ParameterNameCookieCaseValidator(expectedCase)); } } private void addParameterNameHeaderCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ParameterNameHeaderCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ParameterNameHeaderCaseValidator(expectedCase)); } } private void addParameterNamePathCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ParameterNamePathCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ParameterNamePathCaseValidator(expectedCase)); } } private void addParameterNameQueryCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ParameterNameQueryCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ParameterNameQueryCaseValidator(expectedCase)); } } private void addParameterDescriptionRequiredValidator(List validators, FactoryOptions options) { Boolean required = options.getBoolean(ParameterDescriptionRequiredValidator.CONFIG_KEY); if (Boolean.TRUE.equals(required)) { validators.add(new ParameterDescriptionRequiredValidator()); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultPathItemValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.PathItemValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.OperationValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.ParameterValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.PathItemValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.pathitem.PathItemOperationsValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.pathitem.PathItemParametersValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultPathItemValidatorFactory implements PathItemValidatorFactory { private final OperationValidatorFactory operationValidatorFactory; private final ParameterValidatorFactory parameterValidatorFactory; public DefaultPathItemValidatorFactory( OperationValidatorFactory operationValidatorFactory, ParameterValidatorFactory parameterValidatorFactory) { this.operationValidatorFactory = operationValidatorFactory; this.parameterValidatorFactory = parameterValidatorFactory; } @Override public List create(FactoryOptions options) { ArrayList validators = new ArrayList<>(); // skeletons validators.add(new PathItemOperationsValidator(operationValidatorFactory.create(options))); validators.add(new PathItemParametersValidator(parameterValidatorFactory.create(options))); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultPathsValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.paths.PathsKeyCaseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.PathsValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.PathItemValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.PathsValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.paths.PathsPathItemsValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultPathsValidatorFactory implements PathsValidatorFactory { private final PathItemValidatorFactory pathItemValidatorFactory; public DefaultPathsValidatorFactory( PathItemValidatorFactory pathItemValidatorFactory) { this.pathItemValidatorFactory = pathItemValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new PathsPathItemsValidator(pathItemValidatorFactory.create(options))); // concretes addPathsKeyCaseValidator(validators, options); return Collections.unmodifiableList(validators); } private void addPathsKeyCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(PathsKeyCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new PathsKeyCaseValidator(expectedCase)); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultRequestBodyValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.requestbody.RequestBodyDescriptionRequiredValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.RequestBodyValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.MediaTypeValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.RequestBodyValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.requestbody.RequestBodyContentValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultRequestBodyValidatorFactory implements RequestBodyValidatorFactory { private final MediaTypeValidatorFactory mediaTypeValidatorFactory; public DefaultRequestBodyValidatorFactory( MediaTypeValidatorFactory mediaTypeValidatorFactory) { this.mediaTypeValidatorFactory = mediaTypeValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new RequestBodyContentValidator(mediaTypeValidatorFactory.create(options))); // concretes addRequestBodyDescriptionRequiredValidator(validators, options); return Collections.unmodifiableList(validators); } private void addRequestBodyDescriptionRequiredValidator(List validators, FactoryOptions options) { Boolean required = options.getBoolean(RequestBodyDescriptionRequiredValidator.CONFIG_KEY); if (Boolean.TRUE.equals(required)) { validators.add(new RequestBodyDescriptionRequiredValidator()); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultResponseValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.response.ResponseHeadersKeysCaseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponseValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.HeaderValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.MediaTypeValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.ResponseValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.response.ResponseContentValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.response.ResponseHeadersValuesValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultResponseValidatorFactory implements ResponseValidatorFactory { private final MediaTypeValidatorFactory mediaTypeValidatorFactory; private final HeaderValidatorFactory headerValidatorFactory; public DefaultResponseValidatorFactory( MediaTypeValidatorFactory mediaTypeValidatorFactory, HeaderValidatorFactory headerValidatorFactory) { this.mediaTypeValidatorFactory = mediaTypeValidatorFactory; this.headerValidatorFactory = headerValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new ResponseContentValidator(mediaTypeValidatorFactory.create(options))); validators.add(new ResponseHeadersValuesValidator(headerValidatorFactory.create(options))); // concretes addResponseHeadersKeysCaseValidator(validators, options); return Collections.unmodifiableList(validators); } private void addResponseHeadersKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(ResponseHeadersKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new ResponseHeadersKeysCaseValidator(expectedCase)); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultResponsesValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponsesValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.ResponseValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.factory.ResponsesValidatorFactory; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.responses.ResponsesResponsesValidator; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultResponsesValidatorFactory implements ResponsesValidatorFactory { private final ResponseValidatorFactory responseValidatorFactory; public DefaultResponsesValidatorFactory( ResponseValidatorFactory responseValidatorFactory) { this.responseValidatorFactory = responseValidatorFactory; } @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // skeletons validators.add(new ResponsesResponsesValidator(responseValidatorFactory.create(options))); return Collections.unmodifiableList(validators); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultSchemaValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.schema.SchemaPropertiesKeysCaseValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.schema.SchemaTitleRequiredValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.SchemaValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.SchemaValidatorFactory; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultSchemaValidatorFactory implements SchemaValidatorFactory { @Override public List create(FactoryOptions options) { ArrayList validators = new ArrayList<>(); // concretes addSchemaTitleRequiredValidator(validators, options); addSchemaPropertiesKeysCaseValidator(validators, options); return Collections.unmodifiableList(validators); } private void addSchemaTitleRequiredValidator(List validators, FactoryOptions options) { Boolean required = options.getBoolean(SchemaTitleRequiredValidator.CONFIG_KEY); if (Boolean.TRUE.equals(required)) { validators.add(new SchemaTitleRequiredValidator()); } } private void addSchemaPropertiesKeysCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(SchemaPropertiesKeysCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new SchemaPropertiesKeysCaseValidator(expectedCase)); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultSecuritySchemeValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.SecuritySchemeValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.SecuritySchemeValidatorFactory; import org.springframework.stereotype.Component; import java.util.Collections; import java.util.List; @Component public class DefaultSecuritySchemeValidatorFactory implements SecuritySchemeValidatorFactory { @Override public List create(FactoryOptions options) { return Collections.emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultServerValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.ServerValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.ServerValidatorFactory; import org.springframework.stereotype.Component; import java.util.Collections; import java.util.List; @Component public class DefaultServerValidatorFactory implements ServerValidatorFactory { @Override public List create(FactoryOptions options) { return Collections.emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultTagValidatorFactory.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.tag.TagDescriptionRequiredValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.tag.TagMustBeReferencedValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.tag.TagNameCaseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.TagValidator; import org.apache.servicecomb.toolkit.oasv.validation.factory.TagValidatorFactory; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Component public class DefaultTagValidatorFactory implements TagValidatorFactory { @Override public List create(FactoryOptions options) { List validators = new ArrayList<>(); // concretes addTagDescriptionRequiredValidator(validators, options); addTagMustBeReferencedValidator(validators, options); addTagNameCaseValidator(validators, options); return Collections.unmodifiableList(validators); } private void addTagDescriptionRequiredValidator(List validators, FactoryOptions options) { Boolean required = options.getBoolean(TagDescriptionRequiredValidator.CONFIG_KEY); if (Boolean.TRUE.equals(required)) { validators.add(new TagDescriptionRequiredValidator()); } } private void addTagMustBeReferencedValidator(List validators, FactoryOptions options) { Boolean required = options.getBoolean(TagMustBeReferencedValidator.CONFIG_KEY); if (Boolean.TRUE.equals(required)) { validators.add(new TagMustBeReferencedValidator()); } } private void addTagNameCaseValidator(List validators, FactoryOptions options) { String expectedCase = options.getString(TagNameCaseValidator.CONFIG_KEY); if (expectedCase != null) { validators.add(new TagNameCaseValidator(expectedCase)); } } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/factory/ValidatorFactoryComponents.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration @ComponentScan public interface ValidatorFactoryComponents { } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsCallbacksKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsCallbacksKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .callbacks property key case validator *

    *
  • config item: components.callbacks.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsCallbacksKeysCaseValidator extends ComponentsCallbacksKeysValidator { public static final String CONFIG_KEY = "components.callbacks.key.case"; public static final String ERROR = "Must be "; public ComponentsCallbacksKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsExamplesKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsExamplesKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .examples property key case validator *
    *
  • config item: components.examples.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsExamplesKeysCaseValidator extends ComponentsExamplesKeysValidator { public static final String CONFIG_KEY = "components.examples.key.case"; public static final String ERROR = "Must be "; public ComponentsExamplesKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsHeadersKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsHeadersKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .headers property key case validator *
    *
  • config item: components.headers.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsHeadersKeysCaseValidator extends ComponentsHeadersKeysValidator { public static final String CONFIG_KEY = "components.headers.key.case"; public static final String ERROR = "Must be "; public ComponentsHeadersKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsLinksKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsLinksKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .links property key case validator *
    *
  • config item: components.links.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsLinksKeysCaseValidator extends ComponentsLinksKeysValidator { public static final String CONFIG_KEY = "components.links.key.case"; public static final String ERROR = "Must be "; public ComponentsLinksKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsParametersKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsParametersKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .parameters property key case validator *
    *
  • config item: components.parameters.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsParametersKeysCaseValidator extends ComponentsParametersKeysValidator { public static final String CONFIG_KEY = "components.parameters.key.case"; public static final String ERROR = "Must be "; public ComponentsParametersKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsRequestBodiesKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsRequestBodiesKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .requestBodies property key case validator *
    *
  • config item: components.requestBodies.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsRequestBodiesKeysCaseValidator extends ComponentsRequestBodiesKeysValidator { public static final String CONFIG_KEY = "components.requestBodies.key.case"; public static final String ERROR = "Must be "; public ComponentsRequestBodiesKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsResponsesKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsResponsesKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .responses property key case validator *
    *
  • config item: components.responses.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsResponsesKeysCaseValidator extends ComponentsResponsesKeysValidator { public static final String CONFIG_KEY = "components.responses.key.case"; public static final String ERROR = "Must be "; public ComponentsResponsesKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsSchemasKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsSchemasKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .schemas property key case validator *
    *
  • config item: components.schemas.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsSchemasKeysCaseValidator extends ComponentsSchemasKeysValidator { public static final String CONFIG_KEY = "components.schemas.key.case"; public static final String ERROR = "Must be "; public ComponentsSchemasKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsSecuritySchemesKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.ComponentsSecuritySchemesKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Components Object * .securitySchemes property key case validator *
    *
  • config item: components.securitySchemes.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ComponentsSecuritySchemesKeysCaseValidator extends ComponentsSecuritySchemesKeysValidator { public static final String CONFIG_KEY = "components.securitySchemes.key.case"; public static final String ERROR = "Must be "; public ComponentsSecuritySchemesKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/encoding/EncodingHeadersKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.encoding; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.encoding.EncodingHeadersKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Encoding Object * .headers property key case validator *
    *
  • config item: encoding.headers.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class EncodingHeadersKeysCaseValidator extends EncodingHeadersKeysValidator { public static final String CONFIG_KEY = "encoding.headers.key.case"; public static final String ERROR = "Must be "; public EncodingHeadersKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/header/HeaderDescriptionRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.header; import org.apache.servicecomb.toolkit.oasv.validation.api.HeaderValidator; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyRequiredValidator; import io.swagger.v3.oas.models.headers.Header; /** * Header Object * .description property validator *
    *
  • config item: header.description.required=*boolean*
  • *
  • description must not be null
  • *
*/ public class HeaderDescriptionRequiredValidator extends ObjectPropertyRequiredValidator implements HeaderValidator { public static final String CONFIG_KEY = "header.description.required"; @Override protected String get$ref(Header oasObject) { return oasObject.get$ref(); } @Override protected String getPropertyObject(Header oasObject) { return oasObject.getDescription(); } @Override protected String getPropertyName() { return "description"; } @Override protected OasObjectType getPropertyType() { return null; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/info/InfoDescriptionRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.info; import io.swagger.v3.oas.models.info.Info; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.InfoValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyRequiredValidator; /** * Info Object * description property validator *
    *
  • config item: info.description.required=*boolean*
  • *
  • description must not be null
  • *
*/ public class InfoDescriptionRequiredValidator extends ObjectPropertyRequiredValidator implements InfoValidator { public static final String CONFIG_KEY = "info.description.required"; @Override protected String get$ref(Info oasObject) { return null; } @Override protected String getPropertyObject(Info oasObject) { return oasObject.getDescription(); } @Override protected String getPropertyName() { return "description"; } @Override protected OasObjectType getPropertyType() { return null; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/OpenApiSecuritySizeEqValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.openapi; import io.swagger.v3.oas.models.OpenAPI; import org.apache.commons.collections4.CollectionUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SECURITY_REQUIREMENT; /** * OpenAPI Object * .security property validator *
    *
  • config item: openAPI.security.size.eq=expected
  • *
  • size should be equals to *expected*
  • *
*/ public class OpenApiSecuritySizeEqValidator implements OpenApiValidator { public static final String CONFIG_KEY = "openAPI.security.size.eq"; public static final String ERROR = "size must be == "; private final int expectedSize; public OpenApiSecuritySizeEqValidator(int expectedSize) { this.expectedSize = expectedSize; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, OpenAPI openAPI) { int size = CollectionUtils.size(openAPI.getSecurity()); if (size != expectedSize) { return singletonList( new OasViolation(location.property("security", SECURITY_REQUIREMENT), ERROR + expectedSize)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/OpenApiTagsSizeGteValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.openapi; import io.swagger.v3.oas.models.OpenAPI; import org.apache.commons.collections4.CollectionUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * OpenAPI Object * .tags(List of Tag Object) * size validator *
    *
  • config item: openAPI.tags.size.gte=expected
  • *
  • size should be >= *expected*
  • *
*/ public class OpenApiTagsSizeGteValidator implements OpenApiValidator { public static final String CONFIG_KEY = "openAPI.tags.size.gte"; public static final String ERROR = "size must be >= "; private final int expectedSize; public OpenApiTagsSizeGteValidator(int expectedSize) { this.expectedSize = expectedSize; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, OpenAPI openAPI) { if (CollectionUtils.size(openAPI.getTags()) < expectedSize) { return singletonList(new OasViolation(location.property("tags", OasObjectType.TAG), ERROR + expectedSize)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/OpenApiVersionGteValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.openapi; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.*; import io.swagger.v3.oas.models.OpenAPI; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * OpenAPI Object * .openapi property validator
    *
  • config item: openAPI.openapi.gte=expected
  • *
  • version should be >= *expected*
  • *
*/ public class OpenApiVersionGteValidator implements OpenApiValidator { public static final String CONFIG_KEY = "openAPI.openapi.gte"; public static final String ERROR = "Must be >= "; private final String versionGte; public OpenApiVersionGteValidator(String versionGte) { this.versionGte = versionGte; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, OpenAPI openAPI) { if (openAPI.getOpenapi() == null) { return singletonList(new OasViolation(location.property("openapi"), ViolationMessages.REQUIRED)); } String[] semver = openAPI.getOpenapi().split("\\."); String[] expectedSemver = versionGte.split("\\."); boolean ok = semver[0].equals(expectedSemver[0]) && semver[1].equals(expectedSemver[1]) && Integer.parseInt(semver[2]) >= Integer.valueOf(expectedSemver[2]); if (ok) { return emptyList(); } return singletonList(new OasViolation(location.property("openapi"), ERROR + versionGte)); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationIdCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.Operation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Operation Object * .operationId case validator *
    *
  • config item: operation.operationId.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class OperationIdCaseValidator implements OperationValidator { public static final String CONFIG_KEY = "operation.operationId.case"; public static final String ERROR = "Must be "; private final String expectedCase; public OperationIdCaseValidator(String expectedCase) { this.expectedCase = expectedCase; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { if (!isMatchCase(expectedCase, oasObject.getOperationId())) { return singletonList(new OasViolation(location.property("operationId"), ERROR + expectedCase)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationServersSizeEqValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.Operation; import org.apache.commons.collections4.CollectionUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SERVER; /** * Operation Object * .servers size validator *
    *
  • config item: operations.servers.size.eq=*expected*
  • *
  • size should be equals to *expected*
  • *
*/ public class OperationServersSizeEqValidator implements OperationValidator { public static final String CONFIG_KEY = "operations.servers.size.eq"; public static final String ERROR = "size must be == "; private final int expectedSize; public OperationServersSizeEqValidator(int expectedSize) { this.expectedSize = expectedSize; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { if (CollectionUtils.size(oasObject.getServers()) != expectedSize) { return singletonList(new OasViolation(location.property("servers", SERVER), ERROR + expectedSize)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationSummaryRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyRequiredValidator; import io.swagger.v3.oas.models.Operation; /** * Operation Object * .summary required validator *
    *
  • config item: operation.summary.required=*boolean*
  • *
  • this field is required
  • *
*/ public class OperationSummaryRequiredValidator extends ObjectPropertyRequiredValidator implements OperationValidator { public static final String CONFIG_KEY = "operation.summary.required"; @Override protected String get$ref(Operation oasObject) { return null; } @Override protected String getPropertyObject(Operation oasObject) { return oasObject.getSummary(); } @Override protected String getPropertyName() { return "summary"; } @Override protected OasObjectType getPropertyType() { return null; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationTagsReferenceValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.tags.Tag; import org.apache.commons.collections4.CollectionUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import java.util.ArrayList; import java.util.List; import java.util.Set; import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; import static java.util.stream.Collectors.toSet; /** * Operation Object * .tags must reference root tags validator *
    *
  • config item: operation.tags.element.must_reference_root_tags=*boolean*
  • *
  • must reference tags defined in OpenAPI Object tags property
  • *
*/ public class OperationTagsReferenceValidator implements OperationValidator { public static final String CONFIG_KEY = "operation.tags.element.must_reference_root_tags"; public static final String ERROR = "is not defined in $.tags"; @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { List tags = oasObject.getTags(); if (CollectionUtils.isEmpty(tags)) { return emptyList(); } List violations = new ArrayList<>(); Set globalTagNames = getGlobalTagNames(context.getOpenAPI()); for (int i = 0; i < tags.size(); i++) { String tagName = tags.get(i); if (!globalTagNames.contains(tagName)) { violations.add( new OasViolation(location.property("tags[" + i + "]"), ERROR)); } } return violations; } public Set getGlobalTagNames(OpenAPI openAPI) { if (CollectionUtils.isEmpty(openAPI.getTags())) { return emptySet(); } return openAPI.getTags().stream().map(Tag::getName).collect(toSet()); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationTagsSizeEqValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.Operation; import org.apache.commons.collections4.CollectionUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; /** * Operation Object * .tags size validator *
    *
  • config item: operation.tags.size.eq=*expected*
  • *
  • size should be equals to *expected*
  • *
*/ public class OperationTagsSizeEqValidator implements OperationValidator { public static final String CONFIG_KEY = "operation.tags.size.eq"; public static final String ERROR = "size must be == "; private final int expectedSize; public OperationTagsSizeEqValidator(int expectedSize) { this.expectedSize = expectedSize; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { List tags = oasObject.getTags(); if (CollectionUtils.size(tags) != expectedSize) { return singletonList(new OasViolation(location.property("tags"), ERROR + expectedSize)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterDescriptionRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyRequiredValidator; import io.swagger.v3.oas.models.parameters.Parameter; /** * Parameter Object * .description property validator *
    *
  • config item: parameter.description.required=*boolean*
  • *
  • this field is required
  • *
*/ public class ParameterDescriptionRequiredValidator extends ObjectPropertyRequiredValidator implements ParameterValidator { public static final String CONFIG_KEY = "parameter.description.required"; @Override protected String get$ref(Parameter oasObject) { return oasObject.get$ref(); } @Override protected String getPropertyObject(Parameter oasObject) { return oasObject.getDescription(); } @Override protected String getPropertyName() { return "description"; } @Override protected OasObjectType getPropertyType() { return null; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterNameCookieCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.parameters.Parameter; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Parameter Object * .name case validator for cookie *
    *
  • config item: parameter.name.cookie.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ParameterNameCookieCaseValidator implements ParameterValidator { public static final String CONFIG_KEY = "parameter.name.cookie.case"; public static final String ERROR = "Must be "; private final String expectedCase; public ParameterNameCookieCaseValidator(String expectedCase) { this.expectedCase = expectedCase; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"cookie".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterNameHeaderCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.parameters.Parameter; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Parameter Object * .name case validator for header *
    *
  • config item: parameter.name.header.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ParameterNameHeaderCaseValidator implements ParameterValidator { public static final String CONFIG_KEY = "parameter.name.header.case"; public static final String ERROR = "Must be "; private final String expectedCase; public ParameterNameHeaderCaseValidator(String expectedCase) { this.expectedCase = expectedCase; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"header".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterNamePathCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.parameters.Parameter; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Parameter Object * .name case validator for path *
    *
  • config item: parameter.name.path.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ParameterNamePathCaseValidator implements ParameterValidator { public static final String CONFIG_KEY = "parameter.name.path.case"; public static final String ERROR = "Must be "; private final String expectedCase; public ParameterNamePathCaseValidator(String expectedCase) { this.expectedCase = expectedCase; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"path".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterNameQueryCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.parameters.Parameter; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Parameter Object * .name case validator for query *
    *
  • config item: parameter.name.query.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ParameterNameQueryCaseValidator implements ParameterValidator { public static final String CONFIG_KEY = "parameter.name.query.case"; public static final String ERROR = "Must be "; private final String expectedCase; public ParameterNameQueryCaseValidator(String expectedCase) { this.expectedCase = expectedCase; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"query".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/paths/PathsKeyCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.paths; import io.swagger.v3.oas.models.Paths; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.PathsValidator; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Paths Object * key case validator *
    *
  • config item: paths.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*

* Path Templating * variable must also match case *

*/ public class PathsKeyCaseValidator implements PathsValidator { public static final String CONFIG_KEY = "paths.key.case"; public static final String ERROR = "Must be "; private static final Pattern TEMPLATE_PATTERN = Pattern.compile("^\\{(.*)\\}$"); private final String expectedCase; public PathsKeyCaseValidator(String expectedCase) { this.expectedCase = expectedCase; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Paths oasObject) { List violations = new ArrayList<>(); Set paths = oasObject.keySet(); for (String path : paths) { if (!matchCamelCase(path)) { OasObjectPropertyLocation pathLoc = location.property(path, OasObjectType.PATH_ITEM); violations.add(new OasViolation(pathLoc, ERROR + expectedCase)); } } return violations; } private boolean matchCamelCase(String path) { String[] pathSegments = path.split("/"); for (String pathSegment : pathSegments) { if (StringUtils.isEmpty(pathSegment)) { continue; } String matchingPart = pathSegment; if (isTemplate(pathSegment)) { matchingPart = extractTemplateVariable(pathSegment); } if (!isMatchCase(expectedCase, matchingPart)) { return false; } } return true; } private boolean isTemplate(String pathSegment) { return TEMPLATE_PATTERN.matcher(pathSegment).matches(); } private String extractTemplateVariable(String pathSegment) { Matcher matcher = TEMPLATE_PATTERN.matcher(pathSegment); if (matcher.matches()) { return matcher.group(1); } return ""; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/requestbody/RequestBodyDescriptionRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.requestbody; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.RequestBodyValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyRequiredValidator; import io.swagger.v3.oas.models.parameters.RequestBody; /** * Request Object * .description property validator *
    *
  • config item: requestBody.description.required=*boolean*
  • *
  • this field is required
  • *
*/ public class RequestBodyDescriptionRequiredValidator extends ObjectPropertyRequiredValidator implements RequestBodyValidator { public static final String CONFIG_KEY = "requestBody.description.required"; @Override protected String get$ref(RequestBody oasObject) { return oasObject.get$ref(); } @Override protected String getPropertyObject(RequestBody oasObject) { return oasObject.getDescription(); } @Override protected String getPropertyName() { return "description"; } @Override protected OasObjectType getPropertyType() { return null; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/response/ResponseHeadersKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.response; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.response.ResponseHeadersKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * ApiResponse Object * .headers property key case validator *
    *
  • config item: response.headers.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class ResponseHeadersKeysCaseValidator extends ResponseHeadersKeysValidator { public static final String CONFIG_KEY = "response.headers.key.case"; public static final String ERROR = "Must be "; public ResponseHeadersKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/schema/SchemaPropertiesKeysCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.schema; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.schema.SchemaPropertiesKeysValidator; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Schema Object * .properties property key case validator *
    *
  • config item: schema.properties.key.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class SchemaPropertiesKeysCaseValidator extends SchemaPropertiesKeysValidator { public static final String CONFIG_KEY = "schema.properties.key.case"; public static final String ERROR = "Must be "; public SchemaPropertiesKeysCaseValidator(String expectedCase) { super( key -> isMatchCase(expectedCase, key), key -> ERROR + expectedCase ); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/schema/SchemaTitleRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.schema; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.common.OasObjectProperty; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ViolationMessages; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.schema.SchemaRecursiveValidatorTemplate; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; /** * Schema Object * .title property required validator *
    *
  • config item: schema.title.required=*boolean*
  • *
  • * if this Schema Object's parent is * Schema Object * / * Components Object * , then title property is required *
  • *
*/ public class SchemaTitleRequiredValidator extends SchemaRecursiveValidatorTemplate { public static final String CONFIG_KEY = "schema.title.required"; @Override protected List validateCurrentSchemaObject(OasValidationContext context, Schema oasObject, OasObjectPropertyLocation location) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } OasObjectProperty parentProperty = location.getParent(); if (SCHEMA == parentProperty.getObjectType() || COMPONENTS == parentProperty.getObjectType() ) { return check(oasObject, location); } return emptyList(); } private List check(Schema oasObject, OasObjectPropertyLocation location) { if (StringUtils.isNotBlank(oasObject.getTitle())) { return emptyList(); } return singletonList( new OasViolation(location.property("title", null), ViolationMessages.REQUIRED)); } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/tag/TagDescriptionRequiredValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.tag; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.TagValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ObjectPropertyRequiredValidator; import io.swagger.v3.oas.models.tags.Tag; /** * Tag Object * .description property validator *
    *
  • config item: tag.description.required=*boolean*
  • *
  • this field is required
  • *
*/ public class TagDescriptionRequiredValidator extends ObjectPropertyRequiredValidator implements TagValidator { public static final String CONFIG_KEY = "tag.description.required"; @Override protected String get$ref(Tag oasObject) { return null; } @Override protected String getPropertyObject(Tag oasObject) { return oasObject.getDescription(); } @Override protected String getPropertyName() { return "description"; } @Override protected OasObjectType getPropertyType() { return null; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/tag/TagMustBeReferencedValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.tag; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.TagValidator; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.Paths; import io.swagger.v3.oas.models.tags.Tag; import org.apache.commons.collections4.CollectionUtils; import java.util.*; import static java.util.Collections.emptySet; /** * Tag Object * referencing validator *
    *
  • config item: tag.name.must_be_referenced=*boolean*
  • *
  • * tag object must be referenced by Operation Object *
  • *
*/ public class TagMustBeReferencedValidator implements TagValidator { public static final String CONFIG_KEY = "tag.name.must_be_referenced"; public static final String ERROR = "Must be referenced by at least one Operation object"; private static final String CACHE_KEY = TagMustBeReferencedValidator.class.getName() + ".allOperationsTags"; @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag) { Set allOperationsTags = getAllOperationsTags(context); List violations = new ArrayList<>(); if (!allOperationsTags.contains(tag.getName())) { violations.add(new OasViolation(location, ERROR)); } return violations; } private Set getAllOperationsTags(OasValidationContext context) { Set allTags = context.getAttribute(CACHE_KEY); if (allTags != null) { return allTags; } allTags = new HashSet<>(); OpenAPI openAPI = context.getOpenAPI(); Paths paths = openAPI.getPaths(); if (paths == null) { return emptySet(); } for (Map.Entry entry : paths.entrySet()) { PathItem pathItem = entry.getValue(); List operations = pathItem.readOperations(); for (Operation operation : operations) { List tags = operation.getTags(); if (CollectionUtils.isEmpty(tags)) { continue; } allTags.addAll(tags); } } context.setAttribute(CACHE_KEY, allTags); return allTags; } } ================================================ FILE: oas-validator/oas-validator-style/src/main/java/org/apache/servicecomb/toolkit/oasv/style/validator/tag/TagNameCaseValidator.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.tag; import io.swagger.v3.oas.models.tags.Tag; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.TagValidator; import java.util.List; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.servicecomb.toolkit.oasv.util.StringCaseUtils.isMatchCase; /** * Tag Object * .name case validator *
    *
  • config item: tag.name.case=upper-camel-case/lower-camel-case/upper-hyphen-case
  • *
  • must match case
  • *
*/ public class TagNameCaseValidator implements TagValidator { public static final String CONFIG_KEY = "tag.name.case"; public static final String ERROR = "Must be "; private final String expectedCase; public TagNameCaseValidator(String expectedCase) { this.expectedCase = expectedCase; } @Override public List validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag) { if (!isMatchCase(expectedCase, tag.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/StyleCheckParserTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import io.swagger.v3.parser.core.models.SwaggerParseResult; import io.swagger.v3.parser.util.ClasspathHelper; public class StyleCheckParserTest { @Test public void parseYaml() { String yaml = loadRelative("parser-test.yaml"); SwaggerParseResult swaggerParseResult = StyleCheckParser.parseYaml(yaml); assertThat(swaggerParseResult).isNotNull(); assertThat(swaggerParseResult.getOpenAPI()).isNotNull(); assertThat(swaggerParseResult.getMessages()).isEmpty(); } private String loadRelative(String filename) { String basePath = getClass().getPackage().getName().replaceAll("\\.", "/"); return ClasspathHelper.loadFileFromClasspath(basePath + "/" + filename); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultComponentsValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.components.*; import org.apache.servicecomb.toolkit.oasv.validation.api.ComponentsValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.components.*; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultComponentsValidatorFactoryTest { @Autowired private DefaultComponentsValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(6); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsCallbacksKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsCallbacksKeysCaseValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsExamplesKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsExamplesKeysCaseValidator.class ); } @Test public void create3() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsHeadersKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsHeadersKeysCaseValidator.class ); } @Test public void create4() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsLinksKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsLinksKeysCaseValidator.class ); } @Test public void create5() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsParametersKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsParametersKeysCaseValidator.class ); } @Test public void create6() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsRequestBodiesKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsRequestBodiesKeysCaseValidator.class ); } @Test public void create7() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsResponsesKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsResponsesKeysCaseValidator.class ); } @Test public void create8() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsSchemasKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsSchemasKeysCaseValidator.class ); } @Test public void create9() { FactoryOptions options = new FactoryOptions( singletonMap(ComponentsSecuritySchemesKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(7); assertThat(validators).hasOnlyElementsOfTypes( ComponentsHeadersValuesValidator.class, ComponentsParametersValuesValidator.class, ComponentsRequestBodiesValuesValidator.class, ComponentsResponsesValuesValidator.class, ComponentsSchemasValuesValidator.class, ComponentsSecuritySchemesValuesValidator.class, ComponentsSecuritySchemesKeysCaseValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultEncodingValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.encoding.EncodingHeadersKeysCaseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.EncodingValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.encoding.EncodingHeadersValuesValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultEncodingValidatorFactoryTest { @Autowired private DefaultEncodingValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( EncodingHeadersValuesValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions( singletonMap(EncodingHeadersKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( EncodingHeadersValuesValidator.class, EncodingHeadersKeysCaseValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultHeaderValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.header.HeaderDescriptionRequiredValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.HeaderValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.header.HeaderSchemaValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultHeaderValidatorFactoryTest { @Autowired private DefaultHeaderValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( HeaderSchemaValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions( singletonMap(HeaderDescriptionRequiredValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( HeaderSchemaValidator.class, HeaderDescriptionRequiredValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions( singletonMap(HeaderDescriptionRequiredValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( HeaderSchemaValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultInfoValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.info.InfoDescriptionRequiredValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.InfoValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultInfoValidatorFactoryTest { @Autowired private DefaultInfoValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(0); } @Test public void create1() { FactoryOptions options = new FactoryOptions(singletonMap(InfoDescriptionRequiredValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( InfoDescriptionRequiredValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions(singletonMap(InfoDescriptionRequiredValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(0); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultMediaTypeValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.MediaTypeValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.mediatype.MediaTypeEncodingValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.mediatype.MediaTypeSchemaValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultMediaTypeValidatorFactoryTest { @Autowired private DefaultMediaTypeValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( MediaTypeSchemaValidator.class, MediaTypeEncodingValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultOasSpecValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import static java.util.Collections.emptyMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultOasSpecValidatorFactoryTest { @Autowired private DefaultOasSpecValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); OasSpecValidator validator = validatorFactory.create(options); assertThat(validator).isNotNull(); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultOpenApiValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.openapi.OpenApiSecuritySizeEqValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.openapi.OpenApiTagsSizeGteValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.openapi.OpenApiVersionGteValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OpenApiValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.openapi.*; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultOpenApiValidatorFactoryTest { @Autowired private DefaultOpenApiValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(5); assertThat(validators).hasOnlyElementsOfTypes( OpenApiTagsValidator.class, OpenApiInfoValidator.class, OpenApiPathsValidator.class, OpenApiComponentsValidator.class, OpenApiServersValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions(singletonMap(OpenApiSecuritySizeEqValidator.CONFIG_KEY, "0")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(6); assertThat(validators).hasOnlyElementsOfTypes( OpenApiTagsValidator.class, OpenApiInfoValidator.class, OpenApiPathsValidator.class, OpenApiComponentsValidator.class, OpenApiServersValidator.class, OpenApiSecuritySizeEqValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions(singletonMap(OpenApiTagsSizeGteValidator.CONFIG_KEY, "0")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(6); assertThat(validators).hasOnlyElementsOfTypes( OpenApiTagsValidator.class, OpenApiInfoValidator.class, OpenApiPathsValidator.class, OpenApiComponentsValidator.class, OpenApiServersValidator.class, OpenApiTagsSizeGteValidator.class ); } @Test public void create3() { FactoryOptions options = new FactoryOptions(singletonMap(OpenApiVersionGteValidator.CONFIG_KEY, "0")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(6); assertThat(validators).hasOnlyElementsOfTypes( OpenApiTagsValidator.class, OpenApiInfoValidator.class, OpenApiPathsValidator.class, OpenApiComponentsValidator.class, OpenApiServersValidator.class, OpenApiVersionGteValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultOperationValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.operation.*; import org.apache.servicecomb.toolkit.oasv.validation.api.OperationValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation.OperationParametersValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation.OperationRequestBodyValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.operation.OperationResponsesValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultOperationValidatorFactoryTest { @Autowired private DefaultOperationValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( OperationParametersValidator.class, OperationResponsesValidator.class, OperationRequestBodyValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions(singletonMap(OperationSummaryRequiredValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(4); assertThat(validators).hasOnlyElementsOfTypes( OperationParametersValidator.class, OperationResponsesValidator.class, OperationRequestBodyValidator.class, OperationSummaryRequiredValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions(singletonMap(OperationSummaryRequiredValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( OperationParametersValidator.class, OperationResponsesValidator.class, OperationRequestBodyValidator.class ); } @Test public void creat3() { FactoryOptions options = new FactoryOptions(singletonMap(OperationIdCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(4); assertThat(validators).hasOnlyElementsOfTypes( OperationParametersValidator.class, OperationResponsesValidator.class, OperationRequestBodyValidator.class, OperationIdCaseValidator.class ); } @Test public void creat4() { FactoryOptions options = new FactoryOptions(singletonMap(OperationTagsSizeEqValidator.CONFIG_KEY, "1")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(4); assertThat(validators).hasOnlyElementsOfTypes( OperationParametersValidator.class, OperationResponsesValidator.class, OperationRequestBodyValidator.class, OperationTagsSizeEqValidator.class ); } @Test public void create5() { FactoryOptions options = new FactoryOptions(singletonMap(OperationServersSizeEqValidator.CONFIG_KEY, "1")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(4); assertThat(validators).hasOnlyElementsOfTypes( OperationParametersValidator.class, OperationResponsesValidator.class, OperationRequestBodyValidator.class, OperationServersSizeEqValidator.class ); } @Test public void create6() { FactoryOptions options = new FactoryOptions(singletonMap(OperationTagsReferenceValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(4); assertThat(validators).hasOnlyElementsOfTypes( OperationParametersValidator.class, OperationResponsesValidator.class, OperationRequestBodyValidator.class, OperationTagsReferenceValidator.class ); } @Test public void create7() { FactoryOptions options = new FactoryOptions(singletonMap(OperationTagsReferenceValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( OperationParametersValidator.class, OperationResponsesValidator.class, OperationRequestBodyValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultParameterValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.parameter.*; import org.apache.servicecomb.toolkit.oasv.validation.api.ParameterValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.parameter.ParameterContentValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.parameter.ParameterSchemaValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultParameterValidatorFactoryTest { @Autowired private DefaultParameterValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( ParameterSchemaValidator.class, ParameterContentValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions( singletonMap(ParameterNameCookieCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( ParameterSchemaValidator.class, ParameterContentValidator.class, ParameterNameCookieCaseValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions( singletonMap(ParameterNameHeaderCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( ParameterSchemaValidator.class, ParameterContentValidator.class, ParameterNameHeaderCaseValidator.class ); } @Test public void create3() { FactoryOptions options = new FactoryOptions( singletonMap(ParameterNamePathCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( ParameterSchemaValidator.class, ParameterContentValidator.class, ParameterNamePathCaseValidator.class ); } @Test public void create4() { FactoryOptions options = new FactoryOptions( singletonMap(ParameterNameQueryCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( ParameterSchemaValidator.class, ParameterContentValidator.class, ParameterNameQueryCaseValidator.class ); } @Test public void create5() { FactoryOptions options = new FactoryOptions( singletonMap(ParameterDescriptionRequiredValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( ParameterSchemaValidator.class, ParameterContentValidator.class, ParameterDescriptionRequiredValidator.class ); } @Test public void create6() { FactoryOptions options = new FactoryOptions( singletonMap(ParameterDescriptionRequiredValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( ParameterSchemaValidator.class, ParameterContentValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultPathItemValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.PathItemValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.pathitem.PathItemOperationsValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.pathitem.PathItemParametersValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultPathItemValidatorFactoryTest { @Autowired private DefaultPathItemValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( PathItemOperationsValidator.class, PathItemParametersValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultPathsValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.paths.PathsKeyCaseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.PathsValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.paths.PathsPathItemsValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultPathsValidatorFactoryTest { @Autowired private DefaultPathsValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( PathsPathItemsValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions(singletonMap(PathsKeyCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( PathsPathItemsValidator.class, PathsKeyCaseValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultRequestBodyValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.requestbody.RequestBodyDescriptionRequiredValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.RequestBodyValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.requestbody.RequestBodyContentValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultRequestBodyValidatorFactoryTest { @Autowired private DefaultRequestBodyValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( RequestBodyContentValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions( singletonMap(RequestBodyDescriptionRequiredValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( RequestBodyContentValidator.class, RequestBodyDescriptionRequiredValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions( singletonMap(RequestBodyDescriptionRequiredValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( RequestBodyContentValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultResponseValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.response.ResponseHeadersKeysCaseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponseValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.response.ResponseContentValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.response.ResponseHeadersValuesValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultResponseValidatorFactoryTest { @Autowired private DefaultResponseValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(2); assertThat(validators).hasOnlyElementsOfTypes( ResponseContentValidator.class, ResponseHeadersValuesValidator.class ); } @Test public void create1() { FactoryOptions options = new FactoryOptions( singletonMap(ResponseHeadersKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(3); assertThat(validators).hasOnlyElementsOfTypes( ResponseContentValidator.class, ResponseHeadersValuesValidator.class, ResponseHeadersKeysCaseValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultResponsesValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.ResponsesValidator; import org.apache.servicecomb.toolkit.oasv.validation.skeleton.responses.ResponsesResponsesValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultResponsesValidatorFactoryTest { @Autowired private DefaultResponsesValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( ResponsesResponsesValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultSchemaValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.schema.SchemaPropertiesKeysCaseValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.schema.SchemaTitleRequiredValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.SchemaValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultSchemaValidatorFactoryTest { @Autowired private DefaultSchemaValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(0); } @Test public void create1() { FactoryOptions options = new FactoryOptions(singletonMap(SchemaTitleRequiredValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( SchemaTitleRequiredValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions(singletonMap(SchemaTitleRequiredValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(0); } @Test public void create3() { FactoryOptions options = new FactoryOptions( singletonMap(SchemaPropertiesKeysCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( SchemaPropertiesKeysCaseValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultSecuritySchemeValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.SecuritySchemeValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultSecuritySchemeValidatorFactoryTest { @Autowired private DefaultSecuritySchemeValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultServerValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.validation.api.ServerValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultServerValidatorFactoryTest { @Autowired private DefaultServerValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/factory/DefaultTagValidatorFactoryTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.factory; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.validator.tag.TagDescriptionRequiredValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.tag.TagMustBeReferencedValidator; import org.apache.servicecomb.toolkit.oasv.style.validator.tag.TagNameCaseValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.TagValidator; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class DefaultTagValidatorFactoryTest { @Autowired private DefaultTagValidatorFactory validatorFactory; @Test public void create() { FactoryOptions options = new FactoryOptions(emptyMap()); List validators = validatorFactory.create(options); assertThat(validators).hasSize(0); } @Test public void create1() { FactoryOptions options = new FactoryOptions(singletonMap(TagDescriptionRequiredValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( TagDescriptionRequiredValidator.class ); } @Test public void create2() { FactoryOptions options = new FactoryOptions(singletonMap(TagDescriptionRequiredValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(0); } @Test public void create3() { FactoryOptions options = new FactoryOptions(singletonMap(TagMustBeReferencedValidator.CONFIG_KEY, "true")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( TagMustBeReferencedValidator.class ); } @Test public void create4() { FactoryOptions options = new FactoryOptions(singletonMap(TagMustBeReferencedValidator.CONFIG_KEY, "false")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(0); } @Test public void create5() { FactoryOptions options = new FactoryOptions(singletonMap(TagNameCaseValidator.CONFIG_KEY, "upper-camel-case")); List validators = validatorFactory.create(options); assertThat(validators).hasSize(1); assertThat(validators).hasOnlyElementsOfTypes( TagNameCaseValidator.class ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/OasStyleCheckTestBase.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator; import io.swagger.v3.parser.core.models.SwaggerParseResult; import io.swagger.v3.parser.util.ClasspathHelper; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.StyleCheckParser; import org.apache.servicecomb.toolkit.oasv.validation.test.OasValidatorTestBase; import java.util.Collections; public class OasStyleCheckTestBase extends OasValidatorTestBase { @Override protected SwaggerParseResult parseAbsolute(String classpath) { String content = ClasspathHelper.loadFileFromClasspath(classpath); return StyleCheckParser.parseYaml(content); } protected FactoryOptions singleOption(String key, String value) { return new FactoryOptions(Collections.singletonMap(key, value)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsCallbacksKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsCallbacksKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-callbacks-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsCallbacksKeysCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsCallbacksKeysCaseValidator.ERROR + "upper-camel-case", "components", COMPONENTS, "callbacks.'onData'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsExamplesKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsExamplesKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-examples-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsExamplesKeysCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsExamplesKeysCaseValidator.ERROR + "upper-camel-case", "components", COMPONENTS, "examples.'foo'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsHeadersKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsHeadersKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-headers-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsHeadersKeysCaseValidator.CONFIG_KEY, "upper-hyphen-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsHeadersKeysCaseValidator.ERROR + "upper-hyphen-case", "components", COMPONENTS, "headers.'foo'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsLinksKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsLinksKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-links-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsLinksKeysCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsLinksKeysCaseValidator.ERROR + "upper-camel-case", "components", COMPONENTS, "links.'foo'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsParametersKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsParametersKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-parameters-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsParametersKeysCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsParametersKeysCaseValidator.ERROR + "upper-camel-case", "components", COMPONENTS, "parameters.'foo'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsRequestBodiesKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsRequestBodiesKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-request-bodies-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsRequestBodiesKeysCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsRequestBodiesKeysCaseValidator.ERROR + "upper-camel-case", "components", COMPONENTS, "requestBodies.'foo'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsResponsesKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsResponsesKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-responses-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsResponsesKeysCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsResponsesKeysCaseValidator.ERROR + "upper-camel-case", "components", COMPONENTS, "responses.'foo'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsSchemasKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsSchemasKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-schemas-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsSchemasKeysCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsSchemasKeysCaseValidator.ERROR + "upper-camel-case", "components", COMPONENTS, "schemas.'foo'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/components/ComponentsSecuritySchemesKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.components; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ComponentsSecuritySchemesKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testUpperCamelCase() { OpenAPI openAPI = loadRelative("petstore-security-schemes-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ComponentsSecuritySchemesKeysCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ComponentsSecuritySchemesKeysCaseValidator.ERROR + "upper-camel-case", "components", COMPONENTS, "securitySchemes.'foo'", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/encoding/EncodingHeadersKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.encoding; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class EncodingHeadersKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate1() { OpenAPI openAPI = loadRelative("petstore-encoding-headers-key-case-1.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( EncodingHeadersKeysCaseValidator.ERROR + "upper-hyphen-case", "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/json'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "headers.'foo-bar'", null ) ); } @Test public void testValidate2() { OpenAPI openAPI = loadRelative("petstore-encoding-headers-key-case-2.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( EncodingHeadersKeysCaseValidator.ERROR + "upper-hyphen-case", "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "responses", RESPONSES, "default", RESPONSE, "content.'application/json'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "headers.'foo-bar'", null ) ); } @Test public void testValidate3() { OpenAPI openAPI = loadRelative("petstore-encoding-headers-key-case-3.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( EncodingHeadersKeysCaseValidator.ERROR + "upper-hyphen-case", "components", COMPONENTS, "requestBodies.'foo'", REQUEST_BODY, "content.'application/json'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "headers.'foo-bar'", null ) ); } @Test public void testValidate4() { OpenAPI openAPI = loadRelative("petstore-encoding-headers-key-case-4.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( EncodingHeadersKeysCaseValidator.ERROR + "upper-hyphen-case", "components", COMPONENTS, "responses.'foo'", RESPONSE, "content.'application/json'", MEDIA_TYPE, "encoding.'foo'", ENCODING, "headers.'foo-bar'", null ) ); } private OasSpecValidator oasSpecValidator() { OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(EncodingHeadersKeysCaseValidator.CONFIG_KEY, "upper-hyphen-case") ); return oasSpecValidator; } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/header/HeaderDescriptionRequiredValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.header; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ViolationMessages; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class HeaderDescriptionRequiredValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-header-no-desc.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(HeaderDescriptionRequiredValidator.CONFIG_KEY, "true") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactlyInAnyOrder( createViolation(ViolationMessages.REQUIRED, "components", COMPONENTS, "headers.'X-Pet-Foo'", HEADER, "description", null), createViolation(ViolationMessages.REQUIRED, "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "headers.'x-next'", HEADER, "description", null), createViolation(ViolationMessages.REQUIRED, "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "201", RESPONSE, "content.'application/*'", MEDIA_TYPE, "encoding.'abc'", ENCODING, "headers.'X-Pet-Foo'", HEADER, "description", null) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/info/InfoDescriptionRequiredValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.info; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ViolationMessages; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.INFO; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class InfoDescriptionRequiredValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-info-no-desc.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(InfoDescriptionRequiredValidator.CONFIG_KEY, "true") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).hasSize(1); assertThat(violations).containsExactly(createViolation(ViolationMessages.REQUIRED, "info", INFO, "description", null)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/OpenApiSecuritySizeEqValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.openapi; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SECURITY_REQUIREMENT; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class OpenApiSecuritySizeEqValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-security-empty.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OpenApiSecuritySizeEqValidator.CONFIG_KEY, "0") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactly( createViolation(OpenApiSecuritySizeEqValidator.ERROR + "0", "security", SECURITY_REQUIREMENT)); } @Test public void testValidateGood() { OpenAPI openAPI = loadRelative("petstore-security-empty-good.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OpenApiSecuritySizeEqValidator.CONFIG_KEY, "0") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).isEmpty(); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/OpenApiTagsSizeGteValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.openapi; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.TAG; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class OpenApiTagsSizeGteValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-tag-not-provided.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OpenApiTagsSizeGteValidator.CONFIG_KEY, "1") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).hasSize(1); assertThat(violations).containsExactly(createViolation(OpenApiTagsSizeGteValidator.ERROR + "1", "tags", TAG)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/OpenApiVersionGteValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.openapi; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class OpenApiVersionGteValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-openapi-wrong.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OpenApiVersionGteValidator.CONFIG_KEY, "3.0.2") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).hasSize(1); assertThat(violations) .containsExactly(createViolation(OpenApiVersionGteValidator.ERROR + "3.0.2", "openapi", null)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationIdCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class OperationIdCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-operation-id-lower-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OperationIdCaseValidator.CONFIG_KEY, "lower-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactly( createViolation(OperationIdCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "operationId", null)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationServersSizeEqValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class OperationServersSizeEqValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-operation-servers-empty.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OperationServersSizeEqValidator.CONFIG_KEY, "0") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactly( createViolation(OperationServersSizeEqValidator.ERROR + "0", "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "servers", SERVER)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationSummaryRequiredValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ViolationMessages; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class OperationSummaryRequiredValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-operation-summary-required.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OperationSummaryRequiredValidator.CONFIG_KEY, "true") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactly( createViolation(ViolationMessages.REQUIRED, "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "summary", null)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationTagsReferenceValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class OperationTagsReferenceValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-operation-tags-reference.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OperationTagsReferenceValidator.CONFIG_KEY, "true") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactly( createViolation(OperationTagsReferenceValidator.ERROR, "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "tags[0]", null)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/operation/OperationTagsSizeEqValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.operation; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class OperationTagsSizeEqValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-operation-tags-only-one.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OperationTagsSizeEqValidator.CONFIG_KEY, "1") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactly( createViolation(OperationTagsSizeEqValidator.ERROR + "1", "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "tags", null)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterDescriptionRequiredValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ViolationMessages; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ParameterDescriptionRequiredValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-parameter-desc-none.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ParameterDescriptionRequiredValidator.CONFIG_KEY, "true") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ViolationMessages.REQUIRED, "paths", PATHS, "/pets/{petId}", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "description", null ), createViolation( ViolationMessages.REQUIRED, "components", COMPONENTS, "parameters.'Bar'", PARAMETER, "description", null ) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterNameCookieCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ParameterNameCookieCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-parameter-cookie-lower-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ParameterNameCookieCaseValidator.CONFIG_KEY, "lower-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ParameterNameCookieCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/pets/{petId}", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "name", null ), createViolation( ParameterNameCookieCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "parameters.'Bar'", PARAMETER, "name", null ) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterNameHeaderCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ParameterNameHeaderCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-parameter-header-upper-hyphen-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ParameterNameHeaderCaseValidator.CONFIG_KEY, "upper-hyphen-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ParameterNameHeaderCaseValidator.ERROR + "upper-hyphen-case", "paths", PATHS, "/pets/{petId}", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "name", null ), createViolation( ParameterNameHeaderCaseValidator.ERROR + "upper-hyphen-case", "components", COMPONENTS, "parameters.'Bar'", PARAMETER, "name", null ) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterNamePathCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ParameterNamePathCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-parameter-path-lower-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ParameterNamePathCaseValidator.CONFIG_KEY, "lower-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ParameterNamePathCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/pets/{PetId}", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "name", null ), createViolation( ParameterNamePathCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "parameters.'Bar'", PARAMETER, "name", null ) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/ParameterNameQueryCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.parameter; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ParameterNameQueryCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-parameter-query-lower-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ParameterNameQueryCaseValidator.CONFIG_KEY, "lower-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ParameterNameQueryCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/pets/{petId}", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "name", null ), createViolation( ParameterNameQueryCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "parameters.'Bar'", PARAMETER, "name", null ) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/paths/PathsKeyCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.paths; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATHS; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.PATH_ITEM; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class PathsKeyCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-paths-lower-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(PathsKeyCaseValidator.CONFIG_KEY, "lower-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( PathsKeyCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/pets/{PetId}", PATH_ITEM ), createViolation( PathsKeyCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/Pets", PATH_ITEM ) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/requestbody/RequestBodyDescriptionRequiredValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.requestbody; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ViolationMessages; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class RequestBodyDescriptionRequiredValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-request-body-desc-required.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(RequestBodyDescriptionRequiredValidator.CONFIG_KEY, "true") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ViolationMessages.REQUIRED, "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "description", null ), createViolation( ViolationMessages.REQUIRED, "components", COMPONENTS, "requestBodies.'Foo'", REQUEST_BODY, "description", null ) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/response/ResponseHeadersKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.response; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class ResponseHeadersKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-response-headers-key-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ResponseHeadersKeysCaseValidator.CONFIG_KEY, "upper-hyphen-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ResponseHeadersKeysCaseValidator.ERROR + "upper-hyphen-case", "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "responses", RESPONSES, "default", RESPONSE, "headers.'foo-bar'", null ), createViolation( ResponseHeadersKeysCaseValidator.ERROR + "upper-hyphen-case", "components", COMPONENTS, "responses.'foo'", RESPONSE, "headers.'foo-bar'", null ) ); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/schema/SchemaPropertiesKeysCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.schema; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.*; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class SchemaPropertiesKeysCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidateParameter1() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-param-1.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "parameters[0]", PARAMETER, "schema", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testValidateParameter2() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-param-2.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "parameters.'Foo'", PARAMETER, "schema", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testResponse1() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-resp-1.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "responses", RESPONSES, "200", RESPONSE, "content.'application/json'", MEDIA_TYPE, "schema", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testResponse2() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-resp-2.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "responses.'Foo'", RESPONSE, "content.'application/json'", MEDIA_TYPE, "schema", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testRequestBody1() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-req-1.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "paths", PATHS, "/pets", PATH_ITEM, "post", OPERATION, "requestBody", REQUEST_BODY, "content.'application/json'", MEDIA_TYPE, "schema", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testRequestBody2() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-req-2.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "requestBodies.'Foo'", REQUEST_BODY, "content.'application/json'", MEDIA_TYPE, "schema", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testComponent() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-comp.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testNested() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-nested.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "properties.'Foo'", null ), createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "properties.'Foo'", SCHEMA, "properties.'Bar'", null ) ); } @Test public void testAllOf() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-all-of.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "allOf[0]", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testAnyOf() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-any-of.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "anyOf[0]", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testOneOf() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-one-of.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "oneOf[0]", SCHEMA, "properties.'Foo'", null ) ); } @Test public void testArray() { OpenAPI openAPI = loadRelative("petstore-schema-p-keys-lower-camel-case-array.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( SchemaPropertiesKeysCaseValidator.ERROR + "lower-camel-case", "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "items", SCHEMA, "properties.'Foo'", null ) ); } private OasSpecValidator createOasSpecValidator() { OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(SchemaPropertiesKeysCaseValidator.CONFIG_KEY, "lower-camel-case") ); return oasSpecValidator; } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/schema/SchemaTitleRequiredValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.schema; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ViolationMessages; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.COMPONENTS; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.SCHEMA; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class SchemaTitleRequiredValidatorTest extends OasStyleCheckTestBase { @Test public void testValidateComponents() { OpenAPI openAPI = loadRelative("petstore-schema-title-comp.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ViolationMessages.REQUIRED, "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "title", null ) ); } @Test public void testValidateNested() { OpenAPI openAPI = loadRelative("petstore-schema-title-nested.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ViolationMessages.REQUIRED, "components", COMPONENTS, "schemas.'Foo'", SCHEMA, "properties.'Foo'", SCHEMA, "title", null ) ); } @Test public void testValidateParameter() { OpenAPI openAPI = loadRelative("petstore-schema-title-param.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).isEmpty(); } @Test public void testValidateRequestBody() { OpenAPI openAPI = loadRelative("petstore-schema-title-req.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).isEmpty(); } @Test public void testValidateResponse() { OpenAPI openAPI = loadRelative("petstore-schema-title-resp.yaml"); OasSpecValidator oasSpecValidator = createOasSpecValidator(); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).isEmpty(); } private OasSpecValidator createOasSpecValidator() { OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(SchemaTitleRequiredValidator.CONFIG_KEY, "true") ); return oasSpecValidator; } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/tag/TagDescriptionRequiredValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.tag; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.ViolationMessages; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.TAG; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class TagDescriptionRequiredValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-tag-no-desc.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(TagDescriptionRequiredValidator.CONFIG_KEY, "true") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).hasSize(1); assertThat(violations) .containsExactly(createViolation(ViolationMessages.REQUIRED, "tags[0]", TAG, "description", null)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/tag/TagMustBeReferencedValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.tag; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.TAG; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class TagMustBeReferencedValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-tag-redundant.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(TagMustBeReferencedValidator.CONFIG_KEY, "true") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).hasSize(1); assertThat(violations) .containsExactly(createViolation(TagMustBeReferencedValidator.ERROR, "tags[1]", TAG)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/java/org/apache/servicecomb/toolkit/oasv/style/validator/tag/TagNameCaseValidatorTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.style.validator.tag; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.apache.servicecomb.toolkit.oasv.style.validator.OasStyleCheckTestBase; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.apache.servicecomb.toolkit.oasv.common.OasObjectType.TAG; import static org.assertj.core.api.Assertions.assertThat; @ContextConfiguration(classes = ValidatorFactoryComponents.class) public class TagNameCaseValidatorTest extends OasStyleCheckTestBase { @Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-tag-name-not-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(TagNameCaseValidator.CONFIG_KEY, "upper-camel-case") ); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).hasSize(1); assertThat(violations) .containsExactly( createViolation(TagNameCaseValidator.ERROR + "upper-camel-case", "tags[0]", TAG, "name", null)); } } ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/logback-test.xml ================================================ ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/parser-test.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Pet petstore paths: /pets: get: summary: List all pets operationId: listpets responses: '200': description: A paged array of pets post: summary: List all pets operationId: foo requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: foo: type: string bar: type: string encoding: foo: contentType: 'application/octet-stream' responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-callbacks-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string callbacks: onData: '{$request.query.callbackUrl}/data': post: requestBody: description: subscription payload content: application/json: schema: properties: timestamp: type: string format: date-time userData: type: string responses: '202': description: | Your server implementation should return this HTTP status code if the data was received successfully OnData: '{$request.query.callbackUrl}/data': post: requestBody: description: subscription payload content: application/json: schema: properties: timestamp: type: string format: date-time userData: type: string responses: '202': description: | Your server implementation should return this HTTP status code if the data was received successfully ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-examples-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string examples: foo: description: abc Foo: description: xyz ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-headers-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string headers: foo: description: blah blah X-Foo: description: blah blah ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-links-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string links: foo: description: abc Foo: description: abc ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-parameters-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string parameters: foo: in: query name: foo schema: type: string Foo: in: query name: foo schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-request-bodies-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string foo: required: - code properties: code: type: string requestBodies: foo: description: blah content: text/plain: schema: type: string Foo: description: blah content: text/plain: schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-responses-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string responses: foo: description: blah blah Foo: description: blah blah ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-schemas-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string foo: required: - code properties: code: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/components/petstore-security-schemes-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string components: securitySchemes: foo: type: http scheme: http ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/encoding/petstore-encoding-headers-key-case-1.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: Create a pet operationId: createPets requestBody: content: application/json: schema: type: string encoding: foo: contentType: application/json headers: foo-bar: schema: type: string responses: default: description: unexpected error headers: foo: schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/encoding/petstore-encoding-headers-key-case-2.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: Create a pet operationId: createPets responses: default: description: unexpected error content: application/json: schema: type: string encoding: foo: contentType: application/json headers: foo-bar: schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/encoding/petstore-encoding-headers-key-case-3.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: Create a pet operationId: createPets responses: default: description: unexpected error headers: foo: schema: type: string components: requestBodies: foo: content: application/json: schema: type: string encoding: foo: contentType: application/json headers: foo-bar: schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/encoding/petstore-encoding-headers-key-case-4.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: Create a pet operationId: createPets responses: default: description: unexpected error headers: foo: schema: type: string components: responses: foo: description: unexpected error content: application/json: schema: type: string encoding: foo: contentType: application/json headers: foo-bar: schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/header/petstore-header-no-desc.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: schema: type: string X-Pet-Bar: $ref: '#/components/headers/X-Pet-Foo' content: application/json: schema: $ref: "#/components/schemas/Pets" '201': description: A paged array of pets content: application/*: encoding: abc: contentType: application/json headers: X-Pet-Foo: schema: type: string X-Pet-Bar: $ref: '#/components/headers/X-Pet-Foo' default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: headers: X-Pet-Foo: schema: type: string schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/info/petstore-info-no-desc.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/petstore-openapi-wrong.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/petstore-security-empty-good.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/petstore-security-empty.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets security: - oauth2: - foo ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/openapi/petstore-tag-not-provided.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/operation/petstore-operation-id-lower-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: ListPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/operation/petstore-operation-servers-empty.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: operationId: listPets responses: '200': description: A paged array of pets servers: - url: http://localhost:8080 post: operationId: showPetById responses: '200': description: Expected response to a valid request ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/operation/petstore-operation-summary-required.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/operation/petstore-operation-tags-only-one.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets - dogs parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/operation/petstore-operation-tags-reference.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 tags: - name: pets description: blah blah paths: /pets: get: summary: List all pets operationId: listPets tags: - dogs parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/petstore-parameter-cookie-lower-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true schema: type: string - name: Bar in: cookie schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string parameters: Bar: in: cookie name: Bar schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/petstore-parameter-desc-none.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string parameters: Bar: in: query name: bar schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/petstore-parameter-header-upper-hyphen-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true schema: type: string - name: x-bar in: header schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string parameters: Bar: in: header name: x-bar schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/petstore-parameter-path-lower-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets/{PetId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: PetId in: path required: true schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string parameters: Bar: in: path name: Bar schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/parameter/petstore-parameter-query-lower-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true schema: type: string - name: Bar in: query schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string parameters: Bar: in: query name: Bar schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/paths/petstore-paths-lower-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /Pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets: get: operationId: listPets2 tags: - pets parameters: - name: limit in: query required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets /pets/{PetId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: PetId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/requestbody/petstore-request-body-desc-required.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: Create a pet operationId: createPets tags: - pets requestBody: content: text/plain: schema: type: string responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string requestBodies: Foo: content: application/json: schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/response/petstore-response-headers-key-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: Create a pet operationId: createPets responses: default: description: unexpected error headers: foo-bar: schema: type: string components: responses: foo: description: unexpected error headers: foo-bar: schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-all-of.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: schemas: Foo: allOf: - type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-any-of.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: schemas: Foo: anyOf: - type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-array.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: schemas: Foo: type: array items: type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-comp.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: schemas: Foo: type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-nested.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: schemas: Foo: type: object properties: Foo: type: object properties: Bar: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-one-of.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: schemas: Foo: oneOf: - type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-param-1.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: operationId: listPets parameters: - name: foo in: query schema: type: object properties: Foo: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-param-2.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: operationId: listPets responses: '200': description: A paged array of pets components: parameters: Foo: in: query name: Foo schema: type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-req-1.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: Create a pet operationId: createPets requestBody: content: application/json: schema: type: object properties: Foo: type: string responses: '201': description: Null response ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-req-2.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: Create a pet operationId: createPets responses: '201': description: Null response components: requestBodies: Foo: content: application/json: schema: type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-resp-1.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets content: application/json: schema: type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-p-keys-lower-camel-case-resp-2.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: responses: Foo: description: A paged array of pets content: application/json: schema: type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-title-comp.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: schemas: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-title-nested.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets components: schemas: Foo: title: blah blah type: object properties: Foo: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-title-param.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listPets parameters: - name: foo in: query schema: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-title-req.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listPets requestBody: content: application/json: schema: type: string responses: '200': description: A paged array of pets ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/schema/petstore-schema-title-resp.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: post: summary: List all pets operationId: listPets responses: '200': description: A paged array of pets content: application/json: schema: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/tag/petstore-tag-name-not-upper-camel-case.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 tags: - name: pets paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/tag/petstore-tag-no-desc.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 tags: - name: pets paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-style/src/test/resources/org/apache/servicecomb/toolkit/oasv/style/validator/tag/petstore-tag-redundant.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 tags: - name: pets - name: foo paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-test/pom.xml ================================================ org.apache.servicecomb.toolkit oas-validator-parent 0.3.0-SNAPSHOT ../pom.xml 4.0.0 oas-validator-test org.apache.servicecomb.toolkit oas-validator-core org.springframework.boot spring-boot-starter-test org.apache.maven.plugins maven-surefire-plugin org.apache.maven.plugins maven-surefire-report-plugin ================================================ FILE: oas-validator/oas-validator-test/src/main/java/org/apache/servicecomb/toolkit/oasv/OasSpecLoader.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.parser.core.models.SwaggerParseResult; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; public abstract class OasSpecLoader { /** * Parse file at absolute path * * @param classpath * @return */ protected abstract SwaggerParseResult parseAbsolute(String classpath); /** * Load file at absolute path * * @param classpath * @return */ protected final OpenAPI loadAbsolute(String classpath) { SwaggerParseResult parseResult = parseAbsolute(classpath); if (CollectionUtils.isNotEmpty(parseResult.getMessages())) { throw new RuntimeException(StringUtils.join(parseResult.getMessages(), ",")); } return parseResult.getOpenAPI(); } /** * Load file at relative path * * @param fileName * @return */ protected final OpenAPI loadRelative(String fileName) { String basePath = getClass().getPackage().getName().replaceAll("\\.", "/"); return loadAbsolute(basePath + "/" + fileName); } } ================================================ FILE: oas-validator/oas-validator-test/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/test/OasDiffValidatorTestBase.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.diffvalidation.test; import org.apache.servicecomb.toolkit.oasv.OasSpecLoader; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasSpecDiffValidator; import io.swagger.v3.oas.models.OpenAPI; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) public abstract class OasDiffValidatorTestBase extends OasSpecLoader { @Autowired protected OasSpecDiffValidator oasSpecDiffValidator; protected final OasDiffValidationContext createContext(OpenAPI leftOpenAPI, OpenAPI rightOpenAPI) { OasDiffValidationContext context = new OasDiffValidationContext(leftOpenAPI, rightOpenAPI); return context; } protected void initContext(OasDiffValidationContext context) { } /** * create violation with location swhich are same on both side * * @param error * @param path * @return */ protected final OasDiffViolation createViolationBoth(String error, Object[] path) { OasObjectPropertyLocation location = createLocation(path); return new OasDiffViolation(location, location, error); } protected final OasDiffViolation createViolationLeft(String error, Object[] leftPath) { return new OasDiffViolation(createLocation(leftPath), null, error); } protected final OasDiffViolation createViolationRight(String error, Object[] rightPath) { return new OasDiffViolation(null, createLocation(rightPath), error); } protected final OasDiffViolation createViolation(String error, Object[] leftPath, Object[] rightPath) { return new OasDiffViolation(createLocation(leftPath), createLocation(rightPath), error); } private final OasObjectPropertyLocation createLocation(Object[] path) { if (path == null) { return null; } OasObjectPropertyLocation loc = OasObjectPropertyLocation.root(); for (int i = 0; i < path.length; i = i + 2) { loc = loc.property((String) path[i], (OasObjectType) path[i + 1]); } return loc; } } ================================================ FILE: oas-validator/oas-validator-test/src/main/java/org/apache/servicecomb/toolkit/oasv/validation/test/OasValidatorTestBase.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.validation.test; import io.swagger.v3.oas.models.OpenAPI; import org.apache.servicecomb.toolkit.oasv.OasSpecLoader; import org.apache.servicecomb.toolkit.oasv.common.OasObjectPropertyLocation; import org.apache.servicecomb.toolkit.oasv.common.OasObjectType; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.factory.OasSpecValidatorFactory; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) public abstract class OasValidatorTestBase extends OasSpecLoader { @Autowired protected OasSpecValidatorFactory oasSpecValidatorFactory; final protected OasValidationContext createContext(OpenAPI openAPI) { OasValidationContext oasValidationContext = new OasValidationContext(openAPI); initContext(oasValidationContext); return oasValidationContext; } protected void initContext(OasValidationContext context) { } final protected OasViolation createViolation(String error, Object... path) { OasObjectPropertyLocation loc = OasObjectPropertyLocation.root(); for (int i = 0; i < path.length; i = i + 2) { loc = loc.property((String) path[i], (OasObjectType) path[i + 1]); } return new OasViolation(loc, error); } } ================================================ FILE: oas-validator/oas-validator-web/pom.xml ================================================ org.apache.servicecomb.toolkit oas-validator-parent 0.3.0-SNAPSHOT ../pom.xml 4.0.0 oas-validator-web org.apache.servicecomb.toolkit.oasv.web.Application org.projectlombok lombok provided org.apache.servicecomb.toolkit oas-validator-core-spring org.apache.servicecomb.toolkit oas-validator-compatibility-spring org.apache.servicecomb.toolkit oas-validator-style org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-thymeleaf org.webjars bootstrap org.springframework.boot spring-boot-starter-test test org.apache.maven.plugins maven-surefire-plugin org.apache.maven.plugins maven-surefire-report-plugin org.springframework.boot spring-boot-maven-plugin boot-repackage package repackage exec ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/Application.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Bean public CorsFilter corsFilter() { final CorsConfiguration config = new CorsConfiguration(); //config.setAllowCredentials(true); config.addAllowedOrigin("*"); config.addAllowedHeader("*"); config.addAllowedMethod("*"); final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/api/**", config); return new CorsFilter(source); } } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/api/controller/CompatibilityController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.api.controller; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.compatibility.CompatibilityCheckParser; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffValidationContext; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasSpecDiffValidator; import org.apache.servicecomb.toolkit.oasv.util.SyntaxChecker; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.util.MimeTypeUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.parser.core.models.SwaggerParseResult; @RestController @RequestMapping("/api/compatibility") public class CompatibilityController { @Autowired private OasSpecDiffValidator oasSpecDiffValidator; @PostMapping(consumes = MimeTypeUtils.TEXT_PLAIN_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.OK) public Map validateOpenAPI(@RequestBody String yaml) { Map json = new HashMap<>(); json.put("acknowleged", true); json.put("data", doValidate(yaml)); return json; } private ImportError2 doValidate(String yaml) { ImportError2 importError = new ImportError2(); String leftYaml = yaml.split("---\n")[0]; String rightYaml = yaml.split("---\n")[1]; importError.addLeftParseErrors(SyntaxChecker.check(leftYaml)); importError.addRightParseErrors(SyntaxChecker.check(rightYaml)); if (importError.isNotEmpty()) { return importError; } OpenAPI leftOpenAPI = loadByYaml(leftYaml); OpenAPI rightOpenAPI = loadByYaml(rightYaml); List violations = oasSpecDiffValidator .validate(createContext(leftOpenAPI, rightOpenAPI), leftOpenAPI, rightOpenAPI); if (CollectionUtils.isNotEmpty(violations)) { importError.addViolations(violations); } return importError; } private OpenAPI loadByYaml(String yaml) { SwaggerParseResult parseResult = CompatibilityCheckParser.parseYaml(yaml); if (CollectionUtils.isNotEmpty(parseResult.getMessages())) { throw new RuntimeException(StringUtils.join(parseResult.getMessages(), ",")); } return parseResult.getOpenAPI(); } private OasDiffValidationContext createContext(OpenAPI leftOpenAPI, OpenAPI rightOpenAPI) { OasDiffValidationContext context = new OasDiffValidationContext(leftOpenAPI, rightOpenAPI); initContext(context); return context; } private void initContext(OasDiffValidationContext context) { } } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/api/controller/ImportError.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.api.controller; import java.util.ArrayList; import java.util.List; import org.apache.commons.collections4.CollectionUtils; import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; public class ImportError { private final List parseErrors = new ArrayList<>(); private final List violations = new ArrayList<>(); private final List diffViolations = new ArrayList<>(); @JsonIgnore public boolean isNotEmpty() { return CollectionUtils.isNotEmpty(parseErrors) || CollectionUtils.isNotEmpty(violations) || CollectionUtils.isNotEmpty(diffViolations); } /** * OAS Spec Yaml parse error * * @return */ public List getParseErrors() { return parseErrors; } /** * check style violations * * @return */ public List getViolations() { return violations; } /** * compatibility violations * * @return */ public List getDiffViolations() { return diffViolations; } public void addParseErrors(List syntaxErrors) { this.parseErrors.addAll(syntaxErrors); } public void addViolations(List violations) { this.violations.addAll(violations); } public void addDiffViolations(List diffViolations) { this.diffViolations.addAll(diffViolations); } } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/api/controller/ImportError2.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.api.controller; import java.util.ArrayList; import java.util.List; import org.apache.commons.collections4.CollectionUtils; import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.servicecomb.toolkit.oasv.diffvalidation.api.OasDiffViolation; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; public class ImportError2 { private final List leftParseErrors = new ArrayList<>(); private final List rightParseErrors = new ArrayList<>(); private final List violations = new ArrayList<>(); @JsonIgnore public boolean isNotEmpty() { return CollectionUtils.isNotEmpty(leftParseErrors) || CollectionUtils.isNotEmpty(rightParseErrors) || CollectionUtils.isNotEmpty(violations); } public List getLeftParseErrors() { return leftParseErrors; } public List getRightParseErrors() { return rightParseErrors; } /** * compatibility violations * * @return */ public List getViolations() { return violations; } public void addLeftParseErrors(List syntaxErrors) { this.leftParseErrors.addAll(syntaxErrors); } public void addRightParseErrors(List syntaxErrors) { this.rightParseErrors.addAll(syntaxErrors); } public void addViolations(List diffViolations) { this.violations.addAll(diffViolations); } } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/api/controller/StyleController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.api.controller; import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.servicecomb.toolkit.oasv.FactoryOptions; import org.apache.servicecomb.toolkit.oasv.style.StyleCheckParser; import org.apache.servicecomb.toolkit.oasv.util.SyntaxChecker; import org.apache.servicecomb.toolkit.oasv.validation.api.OasSpecValidator; import org.apache.servicecomb.toolkit.oasv.validation.api.OasValidationContext; import org.apache.servicecomb.toolkit.oasv.validation.api.OasViolation; import org.apache.servicecomb.toolkit.oasv.validation.factory.OasSpecValidatorFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.http.HttpStatus; import org.springframework.util.MimeTypeUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.parser.core.models.SwaggerParseResult; @RestController @RequestMapping("/api/style") public class StyleController implements InitializingBean { @Autowired private OasSpecValidatorFactory oasSpecValidatorFactory; private FactoryOptions factoryOptions; @PostMapping(consumes = MimeTypeUtils.TEXT_PLAIN_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.OK) public Map validateOpenAPI(@RequestBody String yaml) { ImportError importError = doValidate(yaml); Map json = new HashMap<>(); json.put("acknowleged", true); json.put("data", importError); return json; } private ImportError doValidate(String yaml) { ImportError importError = new ImportError(); importError.addParseErrors(SyntaxChecker.check(yaml)); if (importError.isNotEmpty()) { return importError; } SwaggerParseResult parseResult = StyleCheckParser.parseYaml(yaml); if (CollectionUtils.isNotEmpty(parseResult.getMessages())) { throw new RuntimeException(StringUtils.join(parseResult.getMessages(), ",")); } OpenAPI openAPI = loadByYaml(yaml); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create(factoryOptions); List violations = oasSpecValidator.validate(createContext(openAPI), openAPI); if (CollectionUtils.isNotEmpty(violations)) { importError.addViolations(violations); } return importError; } private OpenAPI loadByYaml(String yaml) { SwaggerParseResult parseResult = StyleCheckParser.parseYaml(yaml); if (CollectionUtils.isNotEmpty(parseResult.getMessages())) { throw new RuntimeException(StringUtils.join(parseResult.getMessages(), ",")); } return parseResult.getOpenAPI(); } private OasValidationContext createContext(OpenAPI openAPI) { OasValidationContext oasValidationContext = new OasValidationContext(openAPI); initContext(oasValidationContext); return oasValidationContext; } private void initContext(OasValidationContext context) { } @Override public void afterPropertiesSet() throws Exception { PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); try (InputStream inputStream = resourceResolver.getResource("classpath:style-check-rules.properties").getInputStream()) { Properties properties = new Properties(); properties.load(inputStream); this.factoryOptions = new FactoryOptions(properties); } } } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/config/StyleCheckValidatorsConfiguration.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.config; import org.apache.servicecomb.toolkit.oasv.style.factory.ValidatorFactoryComponents; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @Configuration @Import(ValidatorFactoryComponents.class) public class StyleCheckValidatorsConfiguration { } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/page/controller/EditorController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.page.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/editor") public class EditorController { @GetMapping() public String index() { return "editor/index"; } } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/page/controller/IndexController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.page.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/") public class IndexController { @GetMapping public String index() { return "index"; } } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/page/controller/ValidatorController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.page.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/validator") public class ValidatorController { @GetMapping() public String index() { return "validator/index"; } @GetMapping(path = "/style") public String complianceValidator() { return "validator/style"; } @GetMapping(path = "/compatibility") public String compatibilityValidator() { return "validator/compatibility"; } } ================================================ FILE: oas-validator/oas-validator-web/src/main/java/org/apache/servicecomb/toolkit/oasv/web/page/controller/ViewerController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.oasv.web.page.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/viewer") public class ViewerController { @GetMapping() public String index() { return "viewer/index"; } } ================================================ FILE: oas-validator/oas-validator-web/src/main/resources/application.properties ================================================ # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # server.port=8080 server.context-path= #thymeleaf spring.thymeleaf.cache=false #spring.thymeleaf.prefix=classpath:/templates/ #spring.thymeleaf.suffix=.html #spring.thymeleaf.check-template-location=true #spring.thymeleaf.encoding=UTF-8 #spring.thymeleaf.mode=HTML5 ================================================ FILE: oas-validator/oas-validator-web/src/main/resources/samples/petstore-openapi-wrong.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- openapi: "3.0.0" info: version: 1.0.0 title: Swagger Petstore license: name: MIT servers: - url: http://petstore.swagger.io/v1 paths: /pets: get: summary: List all pets operationId: listPets tags: - pets parameters: - name: limit in: query description: How many items to return at one time (max 100) required: false schema: type: integer format: int32 responses: '200': description: A paged array of pets headers: x-next: description: A link to the next page of responses schema: type: string content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" post: summary: Create a pet operationId: createPets tags: - pets responses: '201': description: Null response default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" /pets/{petId}: get: summary: Info for a specific pet operationId: showPetById tags: - pets parameters: - name: petId in: path required: true description: The id of the pet to retrieve schema: type: string responses: '200': description: Expected response to a valid request content: application/json: schema: $ref: "#/components/schemas/Pets" default: description: unexpected error content: application/json: schema: $ref: "#/components/schemas/Error" components: schemas: Pet: required: - id - name properties: id: type: integer format: int64 name: type: string tag: type: string Pets: type: array items: $ref: "#/components/schemas/Pet" Error: required: - code - message properties: code: type: integer format: int32 message: type: string ================================================ FILE: oas-validator/oas-validator-web/src/main/resources/style-check-rules.properties ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- # OpenAPI Object openAPI.openapi.gte=3.0.2 openAPI.tags.size.gte=1 openAPI.security.size.eq=0 # Info Object info.description.required=true # Tag Object tag.name.case=upper-camel-case tag.name.must_be_referenced=true tag.description.required=true # Paths Object paths.key.case=lower-camel-case # Operation Object operation.summary.required=true operation.operationId.case=lower-camel-case operation.tags.size.eq=1 operation.tags.element.must_reference_root_tags=true operations.servers.size.eq=0 # Parameter Object parameter.description.required=true parameter.name.header.case=upper-hyphen-case parameter.name.cookie.case=lower-camel-case parameter.name.path.case=lower-camel-case parameter.name.query.case=lower-camel-case # RequestBody Object requestBody.description.required=true # Response Object response.headers.key.case=upper-hyphen-case # Schema Object schema.title.required=true schema.properties.key.case=lower-camel-case # Encoding Object encoding.headers.key.case=upper-hyphen-case # Header Object header.description.required=true # Components Object components.schemas.key.case=upper-camel-case components.responses.key.case=upper-camel-case components.parameters.key.case=upper-camel-case components.examples.key.case=upper-camel-case components.requestBodies.key.case=upper-camel-case components.headers.key.case=upper-hyphen-case components.links.key.case=upper-hyphen-case components.callbacks.key.case=upper-camel-case components.headers.key.case=upper-camel-case ================================================ FILE: oas-validator/oas-validator-web/src/main/resources/templates/index.html ================================================ The OpenAPI Specification Tools - Validator
风格校验     [文档]

对OAS Yaml文档的内容做风格校验

进入
兼容性检查     [文档]

对新旧两个版本的OAS做兼容性检查。

进入
================================================ FILE: oas-validator/oas-validator-web/src/main/resources/templates/validator/compatibility.html ================================================ The OpenAPI Specification Tools - Compatibility Validator

兼容性检查     [文档]

================================================ FILE: oas-validator/oas-validator-web/src/main/resources/templates/validator/style.html ================================================ The OpenAPI Specification Tools - Style Check Validator

风格校验     [文档]

================================================ FILE: oas-validator/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 oas-validator-parent pom oas-validator-core oas-validator-core-spring oas-validator-test oas-validator-style oas-validator-compatibility oas-validator-compatibility-spring oas-validator-web ================================================ FILE: pom.xml ================================================ 4.0.0 org.apache apache 18 org.apache.servicecomb.toolkit toolkit 0.3.0-SNAPSHOT pom Apache ServiceComb Toolkit https://github.com/apache/servicecomb-toolkit UTF-8 1.8 ${java.version} ${java.version} 2.1 2.0.10 2.4.3 4.12 7.2 1.6.2 1.2.0 0.7 2.3 5.3.0.201903130848-r 2.25.0 3.6.0 4.1.2 3.4 3.2.2 2.0.15 4.3 2.6 2.1.4.RELEASE 0.28.0 3.2.2 4.3.1 3.0.0-M3 3.5 2.8.2 3.3 3.0.0 3.3.0 4.3.0 2.5.3 2.9.1 2.2.1 1.6 0.7.8 1.6.0 0.13 1.19 0.7.8 1.19.0 Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo Development List dev-subscribe@servicecomb.apache.org dev-unsubscribe@servicecomb.apache.org dev@servicecomb.apache.org Commits List commits-subscribe@servicecomb.apache.org commits-unsubscribe@servicecomb.apache.org commits@servicecomb.apache.org The ServiceComb Developer Team dev@servicecomb.apache.org jira https://issues.apache.org/jira/browse/SCB The Apache Software Foundation http://www.apache.org/ 2019 https://github.com/apache/servicecomb-toolkit scm:git:https://github.com/apache/servicecomb-toolkit.git scm:git:https://github.com/apache/servicecomb-toolkit.git v${project.version} apache.releases.https Apache Release Distribution Repository https://repository.apache.org/service/local/staging/deploy/maven2 apache.snapshots.https Apache Development Snapshot Repository https://repository.apache.org/content/repositories/snapshots codegen cli docgen common toolkit-maven-plugin core integration-tests contractgen oas-validator oas-generator org.apache.servicecomb.toolkit cli ${project.version} org.apache.servicecomb.toolkit codegen ${project.version} org.apache.servicecomb.toolkit common ${project.version} org.apache.servicecomb.toolkit core ${project.version} org.apache.servicecomb.toolkit docgen ${project.version} org.apache.servicecomb.toolkit contractgen ${project.version} org.apache.servicecomb.toolkit toolkit-maven-plugin ${project.version} org.apache.servicecomb.toolkit oas-validator-core ${project.version} org.apache.servicecomb.toolkit oas-validator-core-spring ${project.version} org.apache.servicecomb.toolkit oas-validator-test ${project.version} org.apache.servicecomb.toolkit oas-validator-style ${project.version} org.apache.servicecomb.toolkit oas-validator-compatibility ${project.version} org.apache.servicecomb.toolkit oas-validator-compatibility-spring ${project.version} org.apache.servicecomb.toolkit oas-generator-core ${project.version} org.apache.servicecomb.toolkit oas-generator-servicecomb ${project.version} org.apache.servicecomb.toolkit oas-generator-jaxrs ${project.version} org.apache.servicecomb.toolkit oas-generator-spring ${project.version} javax.ws.rs javax.ws.rs-api ${javax.ws.rs-api.version} io.swagger.core.v3 swagger-models ${swagger.version} io.swagger.core.v3 swagger-annotations ${swagger.version} io.swagger.core.v3 swagger-core ${swagger.version} junit junit ${junit.version} org.ow2.asm asm ${asm.version} org.apache.servicecomb provider-rest-common ${javachassis.version} org.apache.servicecomb provider-pojo ${javachassis.version} org.powermock powermock-module-junit4 ${powermock.version} org.powermock powermock-api-mockito ${powermock.version} io.airlift airline ${airline.version} org.apache.logging.log4j log4j-slf4j-impl ${log4j2.version} org.apache.logging.log4j log4j-api ${log4j2.version} org.apache.logging.log4j log4j-core ${log4j2.version} org.apache.logging.log4j log4j-jcl ${log4j2.version} io.swagger swagger-codegen ${swagger-codegen.version} org.eclipse.jgit org.eclipse.jgit ${org.eclipse.jgit.version} org.mockito mockito-core ${mockito-core.version} org.apache.maven maven-core ${maven-core.version} org.apache.maven.plugin-testing maven-plugin-testing-harness ${maven-plugin-testing-harness.version} org.openapitools openapi-generator ${openapi-generator.version} org.apache.servicecomb swagger-generator-core ${javachassis.version} org.apache.commons commons-lang3 ${commons-lang3.version} org.apache.maven maven-plugin-api ${maven-core.version} org.apache.maven.plugin-tools maven-plugin-annotations ${maven-core.version} org.apache.maven.plugin-tools maven-plugin-tools-annotations ${maven-core.version} org.apache.maven maven-aether-provider ${maven-aether-provider.version} org.apache.maven maven-compat ${maven-compat.version} org.springframework.boot spring-boot-dependencies ${spring-boot.version} pom import org.apache.commons commons-collections4 ${commons-collections4.version} io.swagger.parser.v3 swagger-parser ${swagger-parser.version} commons-io commons-io ${commons-io.version} org.webjars bootstrap ${webjars.version} com.github.stefanbirkner system-rules ${system-rules.version} test org.eluder.coveralls coveralls-maven-plugin ${coveralls-maven-plugin.version} ${project.basedir}/integration-tests/coverage-aggregate/target/site/jacoco-aggregate/jacoco.xml org.jacoco jacoco-maven-plugin ${jacoco-maven-plugin.version} default-prepare-agent prepare-agent ${project.build.directory}/jacoco.exec default-prepare-agent-integration pre-integration-test prepare-agent-integration ${project.build.directory}/jacoco-it.exec jacoco.failsafe.argLine default-report report default-report-integration report-integration org.apache.maven.plugins maven-compiler-plugin ${maven-compiler-plugin.version} org.apache.maven.plugins maven-resources-plugin ${maven-resources-plugin.version} UTF-8 org.springframework.boot spring-boot-maven-plugin ${spring-boot.version} org.apache.maven.plugins maven-deploy-plugin ${maven-deploy-plugin.version} org.apache.maven.plugins maven-plugin-plugin ${maven-plugin-plugin.version} org.apache.maven.plugins maven-surefire-plugin ${maven.surefire.version} org.apache.maven.plugins maven-surefire-report-plugin ${maven.surefire.version} report post-integration-test report-only org.codehaus.mojo license-maven-plugin ${license-maven-plugin.version} default-cli true /org/codehaus/mojo/license/third-party-file-groupByMultiLicense.ftl The Apache Software License, Version 2.0|The Apache License, Version 2.0 The Apache Software License, Version 2.0|Apache License, Version 2.0 The Apache Software License, Version 2.0|Apache Public License 2.0 The Apache Software License, Version 2.0|Apache 2 The Apache Software License, Version 2.0|Apache 2.0 The Apache Software License, Version 2.0|Apache-2.0 The Apache Software License, Version 2.0|Apache License 2.0 The Apache Software License, Version 2.0|Apache License, version 2.0 3-Clause BSD License|BSD 3-clause 3-Clause BSD License|BSD 3-Clause Eclipse Public License v1.0|Eclipse Public License 1.0 Eclipse Public License v1.0|Eclipse Public License - v 1.0 The MIT License|MIT License org.apache.rat apache-rat-plugin ${apache-rat-plugin.version} DISCLAIMER .travis.yml **/*.md **/*.MD **/target/* **/target/**/* **/etc/eclipse-java-google-style.xml **/etc/intellij-java-google-style.xml **/resources/ssl/** **/release/licenses/** **/logs/**.log **/**.log **/**.iml **/images/*.png **/images/*.jpg **/**.mustache **/src/test/resources/**/*.yaml **/src/test/resources/**/*.json org.apache.maven.plugins maven-remote-resources-plugin ${maven-remote-resources-plugin.version} process-resource-bundles process org.apache:apache-jar-resource-bundle:1.4 Apache ServiceComb jacoco org.jacoco jacoco-maven-plugin release toolkit-distribution org.apache.maven.plugins maven-deploy-plugin org.apache.maven.plugins maven-gpg-plugin ${maven-gpg-plugin.version} sign-artifacts verify sign org.apache.maven.plugins maven-source-plugin ${maven-source-plugin.version} attach-sources jar-no-fork org.apache.maven.plugins maven-javadoc-plugin ${maven-javadoc-plugin.version} attach-javadocs jar org.apache.maven.plugins maven-release-plugin ${maven-release-plugin.version} true false release deploy ================================================ FILE: samples/README-ZH.md ================================================ # samples | [English](./README.md) 以下是ServiceComb Toolkit的一些使用案例 1. 基于SpringMvc实现的遗留应用自动转换为基于ServiceComb的微服务工程。请参考以下示例 [generate-from-code-sample](./generate-from-code-sample/README-ZH.md) 2. 基于OpenAPI契约文件自动生成基于ServiceComb的微服务工程。请参考以下示例 [generate-from-contract-sample](./generate-from-contract-sample/README-ZH.md) 3. 校验当前项目的API实现代码与契约文件描述是否一致。请参考以下示例 [verify-with-code-sample](./verify-with-code-sample/README-ZH.md) ================================================ FILE: samples/README.md ================================================ # samples | [中文](./README-ZH.md) It's the samples of ServiceComb Toolkit 1. Legacy applications based on SpringMvc are automatically converted to ServiceComb-based microservice engineering. Please refer to the following sample [generate-from-code-sample](./generate-from-code-sample) 2. Automatic generation of ServiceComb-based microservice engineering based on OpenAPI contract file. Please refer to the following sample [generate-from-contract-sample](./generate-from-contract-sample) 3. Verify that the current project's API implementation code is consistent with the contract file description. Please refer to the following sample [verify-with-code-sample](./verify-with-code-sample) ================================================ FILE: samples/generate-from-code-sample/GoodbyeService/pom.xml ================================================ generate-from-code-sample org.apache.servicecom.toolkit 0.3.0-SNAPSHOT 4.0.0 GoodbyeService org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-dependencies 1.5.12.RELEASE pom import ================================================ FILE: samples/generate-from-code-sample/GoodbyeService/src/main/java/org/apache/servicecomb/toolkit/goodbye/GoodbyeApplication.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.goodbye; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class GoodbyeApplication { public static void main(String[] args) { SpringApplication.run(GoodbyeApplication.class,args); } } ================================================ FILE: samples/generate-from-code-sample/GoodbyeService/src/main/java/org/apache/servicecomb/toolkit/goodbye/GoodbyeController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.goodbye; import javax.servlet.http.Part; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @RestController public class GoodbyeController { @GetMapping("/goodbye/{name}") public String sayGoodbye(@PathVariable("name") String name, @RequestPart MultipartFile file, @RequestPart Part part) { return "Goodbye," + name; } } ================================================ FILE: samples/generate-from-code-sample/GoodbyeService/src/main/resources/application.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- server: port: 8080 ================================================ FILE: samples/generate-from-code-sample/HelloService/pom.xml ================================================ generate-from-code-sample org.apache.servicecom.toolkit 0.3.0-SNAPSHOT 4.0.0 HelloService org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-dependencies 1.5.12.RELEASE pom import ================================================ FILE: samples/generate-from-code-sample/HelloService/src/main/java/org/apache/servicecomb/toolkit/hello/HelloApplication.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.hello; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class HelloApplication { public static void main(String[] args) { SpringApplication.run(HelloApplication.class,args); } } ================================================ FILE: samples/generate-from-code-sample/HelloService/src/main/java/org/apache/servicecomb/toolkit/hello/HelloController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.hello; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @GetMapping("/hello/{name}") public String sayHello(@PathVariable("name") String name) { return "Hello," + name; } } ================================================ FILE: samples/generate-from-code-sample/HelloService/src/main/resources/application.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- server: port: 8081 ================================================ FILE: samples/generate-from-code-sample/README-ZH.md ================================================ ### Generate From Code Sample 本案例模拟一个多模块项目,包括以下两个服务: * HelloService * GoodbyeService HelloService和GoodbyeService各提供一个接口,本案例将分别将其转换成对应的基于ServiceComb java-chassis的微服务项目 ### 运行环境 1. [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 2. [Maven 3.x](https://maven.apache.org/install.html) ### 步骤1: 配置插件 在示例项目根目录的pom.xml文件中,新增toolkit-maven-plugin插件的配置,如下 ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./target all org.apache.servicecom.toolkit generate-from-code-sample ``` ### 步骤2:执行插件 在命令行中执行如下的maven命令: ``` mvn toolkit:generate ``` ### 步骤3:输出结果 转换的结果在generate-from-code-sample的target目录下,分别输出契约,文档和基于ServiceComb java-chassis的微服务项目 ``` target/ ├── contract │   ├── GoodbyeService │   │   └── GoodbyeController.yaml │   └── HelloService │   └── HelloController.yaml ├── document │   ├── GoodbyeService │   │   └── GoodbyeController.html │   └── HelloService │   └── HelloController.html └── project ├── GoodbyeService-consumer │   ├── pom.xml │   └── src ├── GoodbyeService-model │   └── pom.xml ├── GoodbyeService-provider │   ├── pom.xml │   └── src ├── HelloService-consumer │   ├── pom.xml │   └── src ├── HelloService-model │   └── pom.xml ├── HelloService-provider │   ├── pom.xml │   └── src └── pom.xml ``` ================================================ FILE: samples/generate-from-code-sample/README.md ================================================ ### Generate From Code Sample This case simulates a multi-module project that includes the following two services: * HelloService * GoodbyeService HelloService and GoodbyeService each provide an API interface. This case will convert them into corresponding microservices based on ServiceComb java-chassis. ### Prerequisites You will need: 1. [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 2. [Maven 3.x](https://maven.apache.org/install.html) ### Step1: Configure plugin In the pom.xml file in the root directory of the current sample project, add the configuration of the toolkit-maven-plugin plugin as follows. ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./target all org.apache.servicecom.toolkit generate-from-code-sample ``` ### Step2: Running Demo Execute the following maven command on the command line ``` mvn toolkit:generate ``` ### Step3: Output Result The result of the conversion is in the target directory of generate-from-code-sample, which respectively outputs the contract, the document and the microservice project based on ServiceComb java-chassis. ``` target/ ├── contract │   ├── GoodbyeService │   │   └── GoodbyeController.yaml │   └── HelloService │   └── HelloController.yaml ├── document │   ├── GoodbyeService │   │   └── GoodbyeController.html │   └── HelloService │   └── HelloController.html └── project ├── GoodbyeService-consumer │   ├── pom.xml │   └── src ├── GoodbyeService-model │   └── pom.xml ├── GoodbyeService-provider │   ├── pom.xml │   └── src ├── HelloService-consumer │   ├── pom.xml │   └── src ├── HelloService-model │   └── pom.xml ├── HelloService-provider │   ├── pom.xml │   └── src └── pom.xml ``` ================================================ FILE: samples/generate-from-code-sample/pom.xml ================================================ 4.0.0 org.apache.servicecom.toolkit generate-from-code-sample 0.3.0-SNAPSHOT HelloService GoodbyeService pom org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./target all org.apache.servicecom.toolkit generate-from-code-sample ================================================ FILE: samples/generate-from-contract-sample/README-ZH.md ================================================ ### Generate From Contract Sample 本案例模拟一个空项目,在该项目根目录的contract目录放置了契约 本案例将根据contract目录的契约生成对应的基于ServiceComb java-chassis的微服务项目 ### 运行环境 1. [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 2. [Maven 3.x](https://maven.apache.org/install.html) ### 步骤1: 配置插件 在示例项目根目录的pom.xml文件中,新增toolkit-maven-plugin插件的配置,如下 ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT contract ./contract ./target provider ``` ### 步骤2:执行插件 在命令行中执行如下的maven命令: ``` mvn toolkit:generate ``` ### 步骤3:输出结果 生成的内容在generate-from-code-sample的target目录下,分别输出文档和基于ServiceComb java-chassis的微服务项目 ``` target/ ├── document │   ├── GoodByeService │   │   └── GoodbyeController.html │   └── HelloService │   └── HelloController.html └── project ├── GoodByeService-model │   └── pom.xml ├── GoodByeService-provider │   ├── pom.xml │   └── src ├── HelloService-model │   └── pom.xml ├── HelloService-provider │   ├── pom.xml │   └── src └── pom.xml ``` ================================================ FILE: samples/generate-from-contract-sample/README.md ================================================ ### Generate From Contract Sample This case simulates an empty project, and the contracts are placed in the contract directory of the project root directory. This case will generate a ServiceComb java-chassis based microservice project based on the contracts in the contract directory. ### Prerequisites You will need: 1. [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 2. [Maven 3.x](https://maven.apache.org/install.html) ### Step1: Configure plugin In the pom.xml file in the root directory of the current sample project, add the configuration of the toolkit-maven-plugin plugin as follows. ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT contract ./target ./contract provider ``` ### Step2: Running Demo Execute the following maven command on the command line ``` mvn toolkit:generate ``` ### Step3: Output Result The generated content is in the target directory of generate-from-code-sample, including the document and the ServiceComb java-chassis-based microservice project. ``` target/ ├── document │   ├── GoodByeService │   │   └── GoodbyeController.html │   └── HelloService │   └── HelloController.html └── project ├── GoodByeService-model │   └── pom.xml ├── GoodByeService-provider │   ├── pom.xml │   └── src ├── HelloService-model │   └── pom.xml ├── HelloService-provider │   ├── pom.xml │   └── src └── pom.xml ``` ================================================ FILE: samples/generate-from-contract-sample/contract/GoodByeService/GoodbyeController.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for org.apache.servicecomb.toolkit.goodbye.GoodbyeController" x-java-interface: "gen.swagger.GoodbyeControllerIntf" basePath: "/" consumes: - "application/json" produces: - "application/json" paths: /goodbye/{name}: get: operationId: "sayGoodbye" parameters: - name: "name" in: "path" required: true type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: samples/generate-from-contract-sample/contract/HelloService/HelloController.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for org.apache.servicecomb.toolkit.hello.HelloController" x-java-interface: "gen.swagger.HelloControllerIntf" basePath: "/" consumes: - "application/json" produces: - "application/json" paths: /hello/{name}: get: operationId: "sayHello" parameters: - name: "name" in: "path" required: true type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: samples/generate-from-contract-sample/pom.xml ================================================ samples org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 pom generate-from-contract-sample org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT contract ./target ./contract provider ================================================ FILE: samples/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 samples pom generate-from-code-sample generate-from-contract-sample verify-with-code-sample org.apache.maven.plugins maven-deploy-plugin 2.8.2 true ================================================ FILE: samples/verify-with-code-sample/GreetingService/pom.xml ================================================ verify-with-code-sample org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 GreetingService org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-dependencies 1.5.12.RELEASE pom import ================================================ FILE: samples/verify-with-code-sample/GreetingService/src/main/java/org/apache/servicecomb/toolkit/goodbye/GreetingController.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.goodbye; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; @RestController public class GreetingController { @GetMapping("/hello/{name}") public String sayHello(@PathVariable("name") String name) { return "Hello," + name; } } ================================================ FILE: samples/verify-with-code-sample/GreetingService/src/main/java/org/apache/servicecomb/toolkit/goodbye/GreetingService.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.goodbye; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class GreetingService { public static void main(String[] args) { SpringApplication.run(GreetingService.class,args); } } ================================================ FILE: samples/verify-with-code-sample/README-ZH.md ================================================ ### Verify With Code Sample 本案例包括以下服务和一个存放标准契约的contract目录 * GreetingService 本案例将使用标准契约校验当前项目的契约并输出校验结果到控制台 ### 运行环境 1. [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 2. [Maven 3.x](https://maven.apache.org/install.html) ### 步骤1: 配置插件 在示例项目根目录的pom.xml文件中,新增toolkit-maven-plugin插件的配置,如下 ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./contract ``` ### 步骤2:执行插件 在命令行中执行如下的maven命令: ``` mvn toolkit:verify ``` ### 步骤3:输出结果 校验的结果直接在控制台上输出 ``` [INFO] Contract is not matched, difference is as follows [INFO] ./contract/GreetingController.yaml vs /opt/sunlisen/workspace/servicecomb-toolkit/samples/verify-with-code-sample/target/tmp-contract/2244468406394280775/GreetingController.yaml @@ -1,20 +1,3 @@ 1 -## --------------------------------------------------------------------------- 2 -## Licensed to the Apache Software Foundation (ASF) under one or more 3 -## contributor license agreements. See the NOTICE file distributed with 4 -## this work for additional information regarding copyright ownership. 5 -## The ASF licenses this file to You under the Apache License, Version 2.0 6 -## (the "License"); you may not use this file except in compliance with 7 -## the License. You may obtain a copy of the License at 8 -## 9 -## http://www.apache.org/licenses/LICENSE-2.0 10 -## 11 -## Unless required by applicable law or agreed to in writing, software 12 -## distributed under the License is distributed on an "AS IS" BASIS, 13 -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 -## See the License for the specific language governing permissions and 15 -## limitations under the License. 16 -## --------------------------------------------------------------------------- 17 - 18 --- 1 --- 19 swagger: "2.0" 2 swagger: "2.0" 20 info: 3 info: this is end of compare ``` ================================================ FILE: samples/verify-with-code-sample/README.md ================================================ ### Verify With Code Sample This case simulates a multi-module project that includes one of the following services and a contract directory that holds standard contracts. This case will use the standard contract to verify the contract of the current project and output the verification result to the console ### Prerequisites You will need: 1. [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 2. [Maven 3.x](https://maven.apache.org/install.html) ### Step1: Configure plugin In the pom.xml file in the root directory of the current sample project, add the configuration of the toolkit-maven-plugin plugin as follows. ```xml org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./contract ``` ### Step2: Running Demo Execute the following maven command on the command line ``` mvn toolkit:verify ``` ### Step3: Output Result The result of the verification is output directly on the console ``` [INFO] Contract is not matched, difference is as follows [INFO] ./contract/GreetingController.yaml vs /opt/sunlisen/workspace/servicecomb-toolkit/samples/verify-with-code-sample/target/tmp-contract/2244468406394280775/GreetingController.yaml @@ -1,20 +1,3 @@ 1 -## --------------------------------------------------------------------------- 2 -## Licensed to the Apache Software Foundation (ASF) under one or more 3 -## contributor license agreements. See the NOTICE file distributed with 4 -## this work for additional information regarding copyright ownership. 5 -## The ASF licenses this file to You under the Apache License, Version 2.0 6 -## (the "License"); you may not use this file except in compliance with 7 -## the License. You may obtain a copy of the License at 8 -## 9 -## http://www.apache.org/licenses/LICENSE-2.0 10 -## 11 -## Unless required by applicable law or agreed to in writing, software 12 -## distributed under the License is distributed on an "AS IS" BASIS, 13 -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 -## See the License for the specific language governing permissions and 15 -## limitations under the License. 16 -## --------------------------------------------------------------------------- 17 - 18 --- 1 --- 19 swagger: "2.0" 2 swagger: "2.0" 20 info: 3 info: this is end of compare ``` ================================================ FILE: samples/verify-with-code-sample/contract/GreetingService/GreetingController.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for org.apache.servicecomb.toolkit.goodbye.GreetingController" x-java-interface: "gen.swagger.GreetingControllerIntf" basePath: "/" consumes: - "application/json" produces: - "application/json" paths: /hello/{name}: get: operationId: "sayHello" parameters: - name: "name" in: "path" required: true type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: samples/verify-with-code-sample/pom.xml ================================================ samples org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 verify-with-code-sample pom GreetingService org.apache.servicecomb.toolkit toolkit-maven-plugin 0.3.0-SNAPSHOT code ./contract ================================================ FILE: scripts/cliTest.sh ================================================ #!/usr/bin/env bash ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- #bin/sh projectDir=$(pwd) # get an binary package mvn clean install -DskipTests -Prelease -Dgpg.skip=true cd toolkit-distribution/target/ unzip apache-servicecomb-toolkit-distribution-*-bin.zip cd apache-servicecomb-toolkit-distribution-*-bin function checkFail { if [ $? -ne 0 ]; then echo "run $1 failed" exit 1 fi } function helpTest { # help ./cli.sh help checkFail helpTest echo "./cli.sh help test success" } function codegenerateTest { # codegenerate for programingModel in "SpringMVC" "POJO" "JAX-RS" "SpringBoot" do ./cli.sh codegenerate \ -m ServiceComb \ -i ${projectDir}/cli/src/test/resources/swagger.yaml \ -o ${projectDir}/target \ -p ${programingModel} 2>&1 \ | grep "Success to generate code" checkFail codegenerateTest echo "generate ${programingModel} is ok" done echo "./cli.sh codegenerate test success" } function docgenerateTest { # docgenerate ./cli.sh docgenerate \ -i ${projectDir}/cli/src/test/resources/swagger.yaml \ -o ${projectDir}/target 2>&1 checkFail docgenerateTest echo "./cli.sh docgenerate test success" } function checkstyleTest { # checkstyle ./cli.sh checkstyle \ -r ${projectDir}/cli/src/test/resources/oas/style-rules.properties \ -f ${projectDir}/cli/src/test/resources/oas/style.yaml 2>&1 \ | grep "check not passed" checkFail checkstyleTest ./cli.sh cs \ -r ${projectDir}/cli/src/test/resources/oas/style-rules.properties \ -f ${projectDir}/cli/src/test/resources/oas/style.yaml 2>&1 \ | grep "check not passed" checkFail checkstyleTest echo "./cli.sh checkstyle test success" } function checkcompatibilityTest { # checkcompatibility ./cli.sh checkcompatibility \ ${projectDir}/cli/src/test/resources/oas/compatibility-left.yaml \ ${projectDir}/cli/src/test/resources/oas/compatibility-right.yaml 2>&1 \ | grep "adding is not allowed on right side" checkFail checkcompatibilityTest ./cli.sh cc \ ${projectDir}/cli/src/test/resources/oas/compatibility-left.yaml \ ${projectDir}/cli/src/test/resources/oas/compatibility-right.yaml 2>&1 \ | grep "adding is not allowed on right side" checkFail checkcompatibilityTest echo "./cli.sh checkcompatibility test success" } helpTest codegenerateTest docgenerateTest checkstyleTest checkcompatibilityTest ================================================ FILE: scripts/deploy.sh ================================================ #!/usr/bin/env bash ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- #bin/sh VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) if [[ ! $VERSION =~ "SNAPSHOT" ]]; then echo "${green}[SCRIPT] Not Snapshot Version,Skipping Deployment.${reset}" else echo "Deploy a Non-Signed Staging Release" mvn deploy -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B -DskipTests --settings .travis.settings.xml if [ $? == 0 ]; then echo "${green}Snapshot Deployment is Success, please log on to Nexus Repo to see the snapshot release..${reset}" else echo "${red}Snapshot deployment failed.${reset}" fi echo "Deployment Completed" fi ================================================ FILE: scripts/test.sh ================================================ #!/usr/bin/env bash ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- #bin/sh ##Check if the commit is tagged commit or not TAGGEDCOMMIT=$(git tag -l --contains HEAD) if [ "$TAGGEDCOMMIT" == "" ]; then TAGGEDCOMMIT=false else TAGGEDCOMMIT=true fi echo "${green}[SCRIPT] TAGGEDCOMMIT=$TAGGEDCOMMIT${reset}" if [ "$TAGGEDCOMMIT" == "true" ]; then echo "${green}[SCRIPT] Skipping the installation as it is tagged commit.${reset}" else mvn apache-rat:check if [ $? != 0 ]; then echo "${red}[SCRIPT] Rat check failed.${reset}" exit 1 fi MVN_CMD="clean install -Pjacoco" if [ -n "$TRAVIS_JOB_ID" ]; then echo "${green}[SCRIPT] It's a travis job.${reset}" MVN_CMD="$MVN_CMD coveralls:report" else echo "${green}[SCRIPT] It's not a travis job.${reset}" fi echo "${green}[SCRIPT] TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST${reset}" if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo "${green}[SCRIPT] It's not a PR build, enable sonar.${reset}" MVN_CMD="$MVN_CMD sonar:sonar -Dsonar.projectKey=servicecomb-toolkit" else echo "${green}[SCRIPT] It's a PR build or local build.${reset}" fi; echo "${green}[SCRIPT] Running unit and integration tests.${reset}" mvn $MVN_CMD if [ $? == 0 ]; then echo "${green}[SCRIPT] Build success.${reset}" else echo "${red}[SCRIPT] Build or tests failed, please check the logs for more details.${reset}" exit 1 fi fi ================================================ FILE: toolkit-distribution/pom.xml ================================================ 4.0.0 org.apache.servicecomb.toolkit toolkit 0.3.0-SNAPSHOT apache-servicecomb-toolkit-distribution Toolkit::Distribution pom org.apache.servicecomb.toolkit cli ${project.version} org.apache.servicecomb.toolkit codegen ${project.version} org.apache.servicecomb.toolkit contractgen ${project.version} org.apache.servicecomb.toolkit common ${project.version} org.apache.servicecomb.toolkit core ${project.version} org.apache.servicecomb.toolkit docgen ${project.version} org.apache.servicecomb.toolkit oas-validator-core ${project.version} org.apache.servicecomb.toolkit oas-validator-core-spring ${project.version} org.apache.servicecomb.toolkit oas-validator-style ${project.version} org.apache.servicecomb.toolkit oas-validator-compatibility ${project.version} org.apache.servicecomb.toolkit oas-validator-compatibility-spring ${project.version} org.apache.servicecomb.toolkit oas-generator-core ${project.version} org.apache.servicecomb.toolkit oas-generator-servicecomb ${project.version} org.apache.servicecomb.toolkit oas-generator-jaxrs ${project.version} org.apache.servicecomb.toolkit oas-generator-spring ${project.version} release maven-assembly-plugin 3.2.0 src package single src/assembly/src.xml bin package single src/assembly/bin.xml ================================================ FILE: toolkit-distribution/src/assembly/bin.xml ================================================ true ${project.build.finalName}-bin bin zip ../ / DISCLAIMER README.md src/release / NOTICE LICENSE licenses/** ../cli/scripts / cli.sh cli.cmd true false /libs runtime ================================================ FILE: toolkit-distribution/src/assembly/src.xml ================================================ src zip true ${project.build.finalName}-src .. **/* mvnw* .mvn/** **/eclipse-classes/** **/target/** **/build/** **/eclipse-classes/** **/.* **/.*/** *.enc *.gpg random_seed **/surefire* **/svn-commit* **/.idea/** **/*.iml **/*.ipr **/*.iws **/cobertura.ser **/node_modules/** ================================================ FILE: toolkit-distribution/src/release/LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ======================================================================= Apache ServiceComb Toolkit Subcomponents: The Apache ServiceComb Toolkit project contains subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the following licenses. ================================================================ This product bundles libraries which are licensed under the Mozilla Public License, Version 2.0 You can find a copy of the License at licenses/LICENSE-mozilla-v20 * Mozilla Rhino (org.mozilla:rhino:1.7R4 - https://developer.mozilla.org/en/Rhino) ================================================================ This product bundles library which is licensed under the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1. You can find a copy of the License at licenses/LICENSE-cddl * JavaMail API jar (javax.mail:mailapi:1.4.3 - http://java.sun.com/projects/javamail/mailapi) * Java Servlet API (javax.servlet:javax.servlet-api:4.0.1 - http://servlet-spec.java.net) * JavaBeans(TM) Activation Framework (javax.activation:activation:1.1 - http://java.sun.com/products/javabeans/jaf/index.jsp) * javax.annotation API (javax.annotation:javax.annotation-api:1.3.2 - http://jcp.org/en/jsr/detail?id=250) * javax.ws.rs-api (javax.ws.rs:javax.ws.rs-api:2.0.1 - http://jax-rs-spec.java.net) * jaxb-api (javax.xml.bind:jaxb-api:2.3.0 - https://github.com/javaee/jaxb-spec/jaxb-api) ================================================================ This product bundles jopt libraries which is licensed under the MIT license. You can find a copy of the License at licenses/LICENSE-jopt * JOpt Simple (net.sf.jopt-simple:jopt-simple:5.0.3 - http://pholser.github.io/jopt-simple) ================================================================ This product bundles slf4j libraries which is licensed under the MIT license. For details, see http://www.slf4j.org You can find a copy of the License at licenses/LICENSE-slf4j * JUL to SLF4J bridge (org.slf4j:jul-to-slf4j:1.7.26 - http://www.slf4j.org) * SLF4J API Module (org.slf4j:slf4j-api:1.6.3 - http://www.slf4j.org) * SLF4J API Module (org.slf4j:slf4j-api:1.7.12 - http://www.slf4j.org) * SLF4J API Module (org.slf4j:slf4j-api:1.7.25 - http://www.slf4j.org) * SLF4J Extensions Module (org.slf4j:slf4j-ext:1.7.12 - http://www.slf4j.org) * SLF4J Simple Binding (org.slf4j:slf4j-simple:1.7.12 - http://www.slf4j.org) =========================================================================== This product bundles of Hamcrest which is licensed under BSD 3-Clause License For details, see https://github.com/hamcrest/JavaHamcrest/blob/master/LICENSE.txt You can find a copy of the License at licenses/LICENSE-hamcrest * Hamcrest Core (org.hamcrest:hamcrest-core:1.3 - https://github.com/hamcrest/JavaHamcrest/hamcrest-core) * Hamcrest library (org.hamcrest:hamcrest-library:1.3 - https://github.com/hamcrest/JavaHamcrest/hamcrest-library) =========================================================================== This product bundles of Hamcrest which is licensed under BSD 3-Clause License For details, see https://www.threeten.org/threetenbp You can find a copy of the License at licenses/LICENSE-threetenbp * ThreeTen backport (org.threeten:threetenbp:1.3.1 - https://www.threeten.org/threetenbp) =========================================================================== This product bundles of Hamcrest which is licensed under BSD License For details, see http://www.brics.dk/automaton/ You can find a copy of the License at licenses/LICENSE-automaton * Automaton (dk.brics.automaton:automaton:1.11-8 - http://www.brics.dk/automaton/) ================================================================ This product bundles files from stax2 which is licensed under the 2-Clause BSD license. For details, see http://wiki.fasterxml.com/WoodstoxStax2 You can find a copy of the License at licenses/LICENSE-woodstox-stax2-api * Stax2 API (org.codehaus.woodstox:stax2-api:3.1.4 - http://wiki.fasterxml.com/WoodstoxStax2) ================================================================ This product bundles commonmark which is licensed under the 2-Clause BSD license. For details, see https://github.com/atlassian/commonmark-java You can find a copy of the License at licenses/LICENSE-commonmark * CommonMark Java Core (com.atlassian.commonmark:commonmark:0.9.0 - https://github.com/atlassian/commonmark-java) ================================================================ This product bundles aopalliance which is licensed under the public domain. For details, see http://aopalliance.sourceforge.net/ * AOP alliance (aopalliance:aopalliance:1.0 - http://aopalliance.sourceforge.net) ================================================================ This product bundles Compiler assisted localization library (CAL10N) which is licensed under the MIT license. You can find a copy of the License at licenses/LICENSE-cal10n * Compiler assisted localization library (CAL10N) - API (ch.qos.cal10n:cal10n-api:0.8.1 - http://cal10n.qos.ch/cal10n-api) * Compiler assisted localization library (CAL10N) - API (ch.qos.cal10n:cal10n-api:0.7.4 - http://cal10n.qos.ch/cal10n-api) =========================================================================== This product bundles of asm which is licensed under BSD 3-Clause License For details, see https://asm.ow2.io/license.html You can find a copy of the License at licenses/LICENSE-asm * asm (org.ow2.asm:asm:7.2 - http://asm.ow2.io/) ================================================================ This product bundles the following libraries which are licensed under the Apache License v2. For details, see their respective project links. * A Jackson 2.x helper (com.github.jknack:handlebars-jackson2:4.1.2 - https://github.com/jknack/handlebars.java/handlebars-jackson2) * ASM based accessors helper used by json-smart (net.minidev:accessors-smart:1.2 - http://www.minidev.net/) * Apache Commons Codec (commons-codec:commons-codec:1.9 - http://commons.apache.org/proper/commons-codec/) * Apache Commons Collections (org.apache.commons:commons-collections4:4.3 - http://commons.apache.org/proper/commons-collections/) * Apache Commons Compress (org.apache.commons:commons-compress:1.16.1 - http://commons.apache.org/proper/commons-compress/) * Apache Commons Configuration (commons-configuration:commons-configuration:1.10 - http://commons.apache.org/configuration/) * Apache Commons Lang (org.apache.commons:commons-lang3:3.4 - http://commons.apache.org/proper/commons-lang/) * Apache Commons Lang (org.apache.commons:commons-lang3:3.8.1 - http://commons.apache.org/proper/commons-lang/) * Apache Commons Logging (commons-logging:commons-logging:1.2 - http://commons.apache.org/proper/commons-logging/) * Apache HttpClient (org.apache.httpcomponents:httpclient:4.5.2 - http://hc.apache.org/httpcomponents-client) * Apache HttpCore (org.apache.httpcomponents:httpcore:4.4.4 - http://hc.apache.org/httpcomponents-core-ga) * Apache Log4j (log4j:log4j:1.2.17 - http://logging.apache.org/log4j/1.2/) * Apache Log4j API (org.apache.logging.log4j:log4j-api:2.11.0 - https://logging.apache.org/log4j/2.x/log4j-api/) * Apache Log4j API (org.apache.logging.log4j:log4j-api:2.11.2 - https://logging.apache.org/log4j/2.x/log4j-api/) * Apache Log4j Core (org.apache.logging.log4j:log4j-core:2.11.0 - https://logging.apache.org/log4j/2.x/log4j-core/) * Apache Log4j SLF4J Binding (org.apache.logging.log4j:log4j-slf4j-impl:2.11.0 - https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/) * Apache Log4j to SLF4J Adapter (org.apache.logging.log4j:log4j-to-slf4j:2.11.2 - https://logging.apache.org/log4j/2.x/log4j-to-slf4j/) * AssertJ fluent assertions (org.assertj:assertj-core:3.11.1 - http://assertj.org/assertj-core) * Bean Validation API (javax.validation:validation-api:2.0.1.Final - http://beanvalidation.org) * Bootstrap (org.webjars:bootstrap:4.3.1 - http://webjars.org) * Byte Buddy (without dependencies) (net.bytebuddy:byte-buddy:1.9.3 - http://bytebuddy.net/byte-buddy) * Byte Buddy Java agent (net.bytebuddy:byte-buddy-agent:1.9.3 - http://bytebuddy.net/byte-buddy-agent) * ClassMate (com.fasterxml:classmate:1.3.4 - http://github.com/FasterXML/java-classmate) * Commons CLI (commons-cli:commons-cli:1.2 - http://commons.apache.org/cli/) * Commons IO (commons-io:commons-io:2.4 - http://commons.apache.org/io/) * FindBugs-jsr305 (com.google.code.findbugs:jsr305:3.0.1 - http://findbugs.sourceforge.net/) * Generex (com.github.mifmif:generex:1.0.2 - https://github.com/mifmif/Generex/tree/master) * Google Guice - Core Library (com.google.inject:guice:4.1.0 - https://github.com/google/guice/guice) * Guava InternalFutureFailureAccess and InternalFutures (com.google.guava:failureaccess:1.0.1 - https://github.com/google/guava/failureaccess) * Guava ListenableFuture only (com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava - https://github.com/google/guava/listenablefuture) * Guava: Google Core Libraries for Java (com.google.guava:guava:18.0 - http://code.google.com/p/guava-libraries/guava) * Guava: Google Core Libraries for Java (com.google.guava:guava:27.0.1-android - https://github.com/google/guava/guava) * Handlebars (com.github.jknack:handlebars:4.1.2 - https://github.com/jknack/handlebars.java/handlebars) * Hibernate Validator Engine (org.hibernate.validator:hibernate-validator:6.0.16.Final - http://hibernate.org/validator/hibernate-validator) * J2ObjC Annotations (com.google.j2objc:j2objc-annotations:1.1 - https://github.com/google/j2objc/) * JBoss Logging 3 (org.jboss.logging:jboss-logging:3.3.2.Final - http://www.jboss.org) * JSON Small and Fast Parser (net.minidev:json-smart:2.3 - http://www.minidev.net/) * JSON library from Android SDK (com.vaadin.external.google:android-json:0.0.20131108.vaadin1 - http://developer.android.com/sdk) * JSONassert (org.skyscreamer:jsonassert:1.5.0 - https://github.com/skyscreamer/JSONassert) * Jackson datatype: Guava (com.fasterxml.jackson.datatype:jackson-datatype-guava:2.9.5 - https://github.com/FasterXML/jackson-datatypes-collections) * Jackson datatype: JSR310 (com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.5 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jsr310) * Jackson datatype: JSR310 (com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jsr310) * Jackson datatype: jdk8 (com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.8 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jdk8) * Jackson module: JAXB Annotations (com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.9.8 - https://github.com/FasterXML/jackson-modules-base) * Jackson-Datatype-ThreeTenBackport (com.github.joschi.jackson:jackson-datatype-threetenbp:2.6.4 - https://github.com/joschi/jackson-datatype-threetenbp) * Jackson-annotations (com.fasterxml.jackson.core:jackson-annotations:2.9.0 - http://github.com/FasterXML/jackson) * Jackson-annotations (com.fasterxml.jackson.core:jackson-annotations:2.9.8 - http://github.com/FasterXML/jackson) * Jackson-core (com.fasterxml.jackson.core:jackson-core:2.9.5 - https://github.com/FasterXML/jackson-core) * Jackson-core (com.fasterxml.jackson.core:jackson-core:2.9.8 - https://github.com/FasterXML/jackson-core) * Jackson-dataformat-XML (com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.8 - http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding) * Jackson-dataformat-YAML (com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8 - https://github.com/FasterXML/jackson-dataformats-text) * Jackson-datatype-Joda (com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.5 - http://wiki.fasterxml.com/JacksonModuleJoda) * Jackson-module-parameter-names (com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.8 - https://github.com/FasterXML/jackson-modules-java8/jackson-module-parameter-names) * Java Chassis::Common::Javassist (org.apache.servicecomb:common-javassist:1.2.0 - https://github.com/apache/servicecomb-java-chassis/common/common-javassist) * Java Chassis::Foundations::Common (org.apache.servicecomb:foundation-common:1.2.0 - https://github.com/apache/servicecomb-java-chassis/foundations/foundation-common) * Java Chassis::Swagger::Generator::Core (org.apache.servicecomb:swagger-generator-core:1.2.0 - https://github.com/apache/servicecomb-java-chassis/swagger/swagger-generator/swagger-generator-core) * Joda-Time (joda-time:joda-time:2.7 - http://www.joda.org/joda-time/) * Joda-Time (joda-time:joda-time:2.9.7 - http://www.joda.org/joda-time/) * Objenesis (org.objenesis:objenesis:2.6 - http://objenesis.org) * SnakeYAML (org.yaml:snakeyaml:1.23 - http://www.snakeyaml.org) * Spring AOP (org.springframework:spring-aop:4.3.20.RELEASE - https://github.com/spring-projects/spring-framework) * Spring AOP (org.springframework:spring-aop:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Beans (org.springframework:spring-beans:4.3.20.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Beans (org.springframework:spring-beans:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Boot (org.springframework.boot:spring-boot:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot) * Spring Boot Actuator (org.springframework.boot:spring-boot-actuator:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator) * Spring Boot Actuator AutoConfigure (org.springframework.boot:spring-boot-actuator-autoconfigure:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator-autoconfigure) * Spring Boot Actuator Starter (org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-actuator) * Spring Boot AutoConfigure (org.springframework.boot:spring-boot-autoconfigure:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-autoconfigure) * Spring Boot Json Starter (org.springframework.boot:spring-boot-starter-json:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-json) * Spring Boot Logging Starter (org.springframework.boot:spring-boot-starter-logging:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-logging) * Spring Boot Starter (org.springframework.boot:spring-boot-starter:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter) * Spring Boot Test (org.springframework.boot:spring-boot-test:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-test) * Spring Boot Test Auto-Configure (org.springframework.boot:spring-boot-test-autoconfigure:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-test-autoconfigure) * Spring Boot Test Starter (org.springframework.boot:spring-boot-starter-test:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-test) * Spring Boot Thymeleaf Starter (org.springframework.boot:spring-boot-starter-thymeleaf:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-thymeleaf) * Spring Boot Tomcat Starter (org.springframework.boot:spring-boot-starter-tomcat:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-tomcat) * Spring Boot Web Starter (org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-web) * Spring Commons Logging Bridge (org.springframework:spring-jcl:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Context (org.springframework:spring-context:4.3.20.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Context (org.springframework:spring-context:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Core (org.springframework:spring-core:4.3.20.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Core (org.springframework:spring-core:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Expression Language (SpEL) (org.springframework:spring-expression:4.3.20.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Expression Language (SpEL) (org.springframework:spring-expression:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Spring TestContext Framework (org.springframework:spring-test:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Web (org.springframework:spring-web:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Spring Web MVC (org.springframework:spring-webmvc:5.1.6.RELEASE - https://github.com/spring-projects/spring-framework) * Woodstox (com.fasterxml.woodstox:woodstox-core:5.0.3 - https://github.com/FasterXML/woodstox) * airline (io.airlift:airline:0.7 - https://github.com/airlift/airline) * attoparser (org.attoparser:attoparser:2.0.5.RELEASE - http://www.attoparser.org) * codegen (org.apache.servicecomb.toolkit:codegen:0.2.0-SNAPSHOT - https://github.com/apache/servicecomb-toolkit/codegen) * com.github.fge:btf (com.github.fge:btf:1.2 - https://github.com/fge/btf) * com.github.fge:jackson-coreutils (com.github.fge:jackson-coreutils:1.6 - https://github.com/fge/jackson-coreutils) * com.github.fge:json-patch (com.github.fge:json-patch:1.6 - https://github.com/fge/json-patch) * com.github.fge:msg-simple (com.github.fge:msg-simple:1.1 - https://github.com/fge/msg-simple) * com.github.fge:uri-template (com.github.fge:uri-template:0.9 - https://github.com/fge/uri-template) * core (org.apache.servicecomb.toolkit:core:0.2.0-SNAPSHOT - https://github.com/apache/servicecomb-toolkit/core) * docgen (org.apache.servicecomb.toolkit:docgen:0.2.0-SNAPSHOT - https://github.com/apache/servicecomb-toolkit/docgen) * error-prone annotations (com.google.errorprone:error_prone_annotations:2.2.0 - http://nexus.sonatype.org/oss-repository-hosting.html/error_prone_parent/error_prone_annotations) * jackson-databind (com.fasterxml.jackson.core:jackson-databind:2.9.8 - http://github.com/FasterXML/jackson) * javax.inject (javax.inject:javax.inject:1 - http://code.google.com/p/atinject/) * json-schema-core (com.github.java-json-tools:json-schema-core:1.2.8 - https://github.com/java-json-tools/json-schema-core) * json-schema-validator (com.github.java-json-tools:json-schema-validator:2.2.8 - https://github.com/box-metadata/json-schema-validator) * libphonenumber (com.googlecode.libphonenumber:libphonenumber:8.0.0 - https://github.com/googlei18n/libphonenumber/) * micrometer-core (io.micrometer:micrometer-core:1.1.4 - https://github.com/micrometer-metrics/micrometer) * oas-validator-compatibility (org.apache.servicecomb.toolkit:oas-validator-compatibility:0.2.0-SNAPSHOT - no url defined) * oas-validator-compatibility-spring (org.apache.servicecomb.toolkit:oas-validator-compatibility-spring:0.2.0-SNAPSHOT - no url defined) * oas-validator-style (org.apache.servicecomb.toolkit:oas-validator-style:0.2.0-SNAPSHOT - no url defined) * oas-validator-core (org.apache.servicecomb.toolkit:oas-validator-core:0.2.0-SNAPSHOT - no url defined) * oas-validator-core-spring (org.apache.servicecomb.toolkit:oas-validator-core-spring:0.2.0-SNAPSHOT - no url defined) * oas-validator-test (org.apache.servicecomb.toolkit:oas-validator-test:0.2.0-SNAPSHOT - no url defined) * openapi-generator (core library) (org.openapitools:openapi-generator:4.1.2 - https://github.com/openapitools/openapi-generator/modules/openapi-generator) * openapi-generator-core (org.openapitools:openapi-generator-core:4.1.2 - https://github.com/openapitools/openapi-generator) * org.xmlunit:xmlunit-core (org.xmlunit:xmlunit-core:2.6.2 - https://www.xmlunit.org/) * project ':json-path' (com.jayway.jsonpath:json-path:2.4.0 - https://github.com/jayway/JsonPath) * swagger-annotations (io.swagger.core.v3:swagger-annotations:2.0.8 - https://github.com/swagger-api/swagger-core/modules/swagger-annotations) * Spring Web (org.springframework:spring-web:5.2.0.RELEASE - https://github.com/spring-projects/spring-framework) * swagger-annotations (io.swagger:swagger-annotations:1.5.22 - https://github.com/swagger-api/swagger-core/modules/swagger-annotations) * swagger-annotations (io.swagger.core.v3:swagger-annotations:2.0.9 - https://github.com/swagger-api/swagger-core/modules/swagger-annotations) * swagger-annotations (io.swagger:swagger-annotations:1.5.22 - https://github.com/swagger-api/swagger-core/modules/swagger-annotations) * swagger-codegen (core library) (io.swagger:swagger-codegen:2.4.3 - https://github.com/swagger-api/swagger-codegen/modules/swagger-codegen) * swagger-compat-spec-parser (io.swagger:swagger-compat-spec-parser:1.0.43 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-compat-spec-parser) * swagger-compat-spec-parser (io.swagger:swagger-compat-spec-parser:1.0.44 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-compat-spec-parser) * swagger-core (io.swagger.core.v3:swagger-core:2.0.8 - https://github.com/swagger-api/swagger-core/modules/swagger-core) * swagger-core (io.swagger.core.v3:swagger-core:2.0.9 - https://github.com/swagger-api/swagger-core/modules/swagger-core) * swagger-core (io.swagger:swagger-core:1.5.22 - https://github.com/swagger-api/swagger-core/modules/swagger-core) * swagger-models (io.swagger.core.v3:swagger-models:2.0.8 - https://github.com/swagger-api/swagger-core/modules/swagger-models) * swagger-models (io.swagger.core.v3:swagger-models:2.0.9 - https://github.com/swagger-api/swagger-core/modules/swagger-models) * swagger-models (io.swagger:swagger-models:1.5.22 - https://github.com/swagger-api/swagger-core/modules/swagger-models) * swagger-parser (io.swagger.parser.v3:swagger-parser-core:2.0.12 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser-core) * swagger-parser (io.swagger.parser.v3:swagger-parser:2.0.12 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser) * swagger-parser (io.swagger:swagger-parser:1.0.43 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser) * swagger-parser (io.swagger:swagger-parser:1.0.44 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser) * swagger-parser (org.openapitools.swagger.parser:swagger-parser-core:2.0.14-OpenAPITools.org-1 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser-core) * swagger-parser (org.openapitools.swagger.parser:swagger-parser:2.0.14-OpenAPITools.org-1 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser) * swagger-parser-v2-converter (io.swagger.parser.v3:swagger-parser-v2-converter:2.0.12 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser-v2-converter) * swagger-parser-v2-converter (org.openapitools.swagger.parser:swagger-parser-v2-converter:2.0.14-OpenAPITools.org-1 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser-v2-converter) * swagger-parser-v3 (io.swagger.parser.v3:swagger-parser-v3:2.0.12 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser-v3) * swagger-parser-v3 (org.openapitools.swagger.parser:swagger-parser-v3:2.0.14-OpenAPITools.org-1 - http://nexus.sonatype.org/oss-repository-hosting.html/swagger-parser-project/modules/swagger-parser-v3) * thymeleaf (org.thymeleaf:thymeleaf:3.0.11.RELEASE - http://www.thymeleaf.org) * thymeleaf-extras-java8time (org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.4.RELEASE - http://www.thymeleaf.org) * thymeleaf-spring5 (org.thymeleaf:thymeleaf-spring5:3.0.11.RELEASE - http://www.thymeleaf.org) * tomcat-embed-core (org.apache.tomcat.embed:tomcat-embed-core:9.0.17 - https://tomcat.apache.org/) * tomcat-embed-el (org.apache.tomcat.embed:tomcat-embed-el:9.0.17 - https://tomcat.apache.org/) * tomcat-embed-websocket (org.apache.tomcat.embed:tomcat-embed-websocket:9.0.17 - https://tomcat.apache.org/) * unbescape (org.unbescape:unbescape:1.1.6.RELEASE - http://www.unbescape.org) * archaius-core (com.netflix.archaius:archaius-core:0.7.3 - https://github.com/Netflix/archaius) =========================================================================== This product bundles Webjars which is licensed under the MIT License. For details, see their respective project links. You can find a copy of the License at licenses/LICENSE-webjars * Popper.js (org.webjars:popper.js:1.14.3 - http://webjars.org) * jquery (org.webjars:jquery:3.0.0 - http://webjars.org) =========================================================================== This product bundles Animal Sniffer Annotations which is licensed under the MIT License. For details, see http://www.mojohaus.org/animal-sniffer/animal-sniffer-annotations You can find a copy of the License at licenses/LICENSE-mit * Animal Sniffer Annotations (org.codehaus.mojo:animal-sniffer-annotations:1.17 - http://www.mojohaus.org/animal-sniffer/animal-sniffer-annotations) =========================================================================== This product bundles Checker Qual which is licensed under the MIT License. For details, see https://checkerframework.org You can find a copy of the License at licenses/LICENSE-mit * Checker Qual (org.checkerframework:checker-compat-qual:2.5.2 - https://checkerframework.org) =========================================================================== This product bundles Mockito which is licensed under the MIT License. For details, see https://github.com/mockito/mockito You can find a copy of the License at licenses/LICENSE-mockito * mockito-core (org.mockito:mockito-core:2.23.4 - https://github.com/mockito/mockito) =========================================================================== This product bundles Project Lombok which is licensed under the MIT License. For details, see https://projectlombok.org You can find a copy of the License at licenses/LICENSE-lombok * Project Lombok (org.projectlombok:lombok:1.18.6 - https://projectlombok.org) =========================================================================== This product bundles following libraries which is licensed under the Public Domain, per Creative Commons CC0. For details, see their respective project links. You can find a copy of the License at licenses/LICENSE-cc0 * HdrHistogram (org.hdrhistogram:HdrHistogram:2.1.9 - http://hdrhistogram.github.io/HdrHistogram/) * LatencyUtils (org.latencyutils:LatencyUtils:2.0.3 - http://latencyutils.github.io/LatencyUtils/) =========================================================================== This product bundles following libraries which is licensed under the Eclipse Public License v1.0. For details, see their respective project links. You can find a copy of the License at licenses/LICENSE-epl-v10 * Logback Classic Module (ch.qos.logback:logback-classic:1.2.3 - http://logback.qos.ch/logback-classic) * Logback Core Module (ch.qos.logback:logback-core:1.2.3 - http://logback.qos.ch/logback-core) =========================================================================== This product bundles ASM Core which is licensed under the 3-Clause BSD. For details, see http://asm.objectweb.org/asm/ You can find a copy of the License at licenses/LICENSE-asm * ASM Core (org.ow2.asm:asm:5.0.4 - http://asm.objectweb.org/asm/) =========================================================================== This product bundles jmustache which is licensed under The (New) BSD License. For details, see http://github.com/samskivert/jmustache You can find a copy of the License at licenses/LICENSE-jmustache * jmustache (com.samskivert:jmustache:1.14 - http://github.com/samskivert/jmustache) =========================================================================== This product bundles JSch which is licensed under Revised BSD. For details, see http://www.jcraft.com/jsch/LICENSE.txt You can find a copy of the License at licenses/LICENSE-jsch * JSch (com.jcraft:jsch:0.1.54 - http://www.jcraft.com/jsch/) =========================================================================== This product bundles JZlib which is licensed under Revised BSD. For details, see http://www.jcraft.com/jzlib/LICENSE.txt You can find a copy of the License at licenses/LICENSE-jzlib * JZlib (com.jcraft:jzlib:1.1.1 - http://www.jcraft.com/jzlib/) ================================================ FILE: toolkit-distribution/src/release/NOTICE ================================================ Apache ServiceComb Toolkit Copyright 2019-present The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). ================================================================ Notice for Apache Commons Codec See licenses/NOTICE-apache-commons-codec ================================================================ Notice for Apache Commons Lang(Version 3) Apache Commons Lang Copyright 2001-2014 The Apache Software Foundation This product includes software from the Spring Framework, under the Apache License 2.0 (see: StringUtils.containsWhitespace()) ================================================================ Notice for Airline See licenses/NOTICE-airline ================================================================ Notice for Apache Commons CLI See licenses/NOTICE-apache-commons-cli ================================================================ Notice for Apache ServiceComb Java Chassis See licenses/NOTICE-servicecomb-java-chassis ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-asm ================================================ ASM: a very small and fast Java bytecode manipulation framework Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-automaton ================================================ Note: This license has also been called the "Simplified BSD License" and the "FreeBSD License". See also the 3-clause BSD License. Copyright Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-cal10n ================================================ Copyright (c) 2009 QOS.ch All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-cc0 ================================================ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; moral rights retained by the original author(s) and/or performer(s); publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; rights protecting the extraction, dissemination, use and reuse of data in a Work; database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 4. Limitations and Disclaimers. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-cddl ================================================ COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1 1. Definitions. 1.1. "Contributor" means each individual or entity that creates or contributes to the creation of Modifications. 1.2. "Contributor Version" means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor. 1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof. 1.4. "Executable" means the Covered Software in any form other than Source Code. 1.5. "Initial Developer" means the individual or entity that first makes Original Software available under this License. 1.6. "Larger Work" means a work which combines Covered Software or portions thereof with code not governed by the terms of this License. 1.7. "License" means this document. 1.8. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. 1.9. "Modifications" means the Source Code and Executable form of any of the following: A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; B. Any new file that contains any part of the Original Software or previous Modification; or C. Any new file that is contributed or otherwise made available under the terms of this License. 1.10. "Original Software" means the Source Code and Executable form of computer software code that is originally released under this License. 1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. 1.12. "Source Code" means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code. 1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants. 2.1. The Initial Developer Grant. Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof). (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License. (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices. 2.2. Contributor Grant. Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party. (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor. 3. Distribution Obligations. 3.1. Availability of Source Code. Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange. 3.2. Modifications. The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License. 3.3. Required Notices. You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer. 3.4. Application of Additional Terms. You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients' rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. 3.5. Distribution of Executable Versions. You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient's rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. 3.6. Larger Works. You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software. 4. Versions of the License. 4.1. New Versions. Oracle is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License. 4.2. Effect of New Versions. You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward. 4.3. Modified Versions. When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License. 5. DISCLAIMER OF WARRANTY. COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 6. TERMINATION. 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as "Participant") alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant. 6.3. If You assert a patent infringement claim against Participant alleging that the Participant Software directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. 6.4. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination. 7. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 8. U.S. GOVERNMENT END USERS. The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and "commercial computer software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License. 9. MISCELLANEOUS. This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction's conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software. 10. RESPONSIBILITY FOR CLAIMS. As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. ------------------------------------------------------------------------ NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. # Certain source files distributed by Oracle America, Inc. and/or its affiliates are subject to the following clarification and special exception to the GPLv2, based on the GNU Project exception for its Classpath libraries, known as the GNU Classpath Exception, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." You should also note that Oracle includes multiple, independent programs in this software package. Some of those programs are provided under licenses deemed incompatible with the GPLv2 by the Free Software Foundation and others. For example, the package includes programs licensed under the Apache License, Version 2.0. Such programs are licensed to you under their original licenses. Oracle facilitates your further distribution of this package by adding the Classpath Exception to the necessary parts of its GPLv2 code, which permits you to use that code in combination with other independent modules not licensed under the GPLv2. However, note that this would not permit you to commingle code under an incompatible license with Oracle's GPLv2 licensed code by, for example, cutting and pasting such code into a file also containing Oracle's GPLv2 licensed code and then distributing the result. Additionally, if you were to remove the Classpath Exception from any of the files to which it applies and distribute the result, you would likely be required to license some or all of the other code in that distribution under the GPLv2 as well, and since the GPLv2 is incompatible with the license terms of some items included in the distribution by Oracle, removing the Classpath Exception could therefore effectively compromise your ability to further distribute the package. Proceed with caution and we recommend that you obtain the advice of a lawyer skilled in open source matters before removing the Classpath Exception or making modifications to this package which may subsequently be redistributed and/or involve the use of third party software. CLASSPATH EXCEPTION Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License version 2 cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-commonmark ================================================ Copyright (c) 2015-2016, Atlassian Pty Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-epl-v10 ================================================ Eclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 1. DEFINITIONS "Contribution" means: a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and b) in the case of each subsequent Contributor: i) changes to the Program, and ii) additions to the Program; where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. "Contributor" means any person or entity that distributes the Program. "Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. "Program" means the Contributions distributed in accordance with this Agreement. "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. 2. GRANT OF RIGHTS a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 3. REQUIREMENTS A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: a) it complies with the terms and conditions of this Agreement; and b) its license agreement: i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. When the Program is made available in source code form: a) it must be made available under this Agreement; and b) a copy of this Agreement must be included with each copy of the Program. Contributors may not remove or alter any copyright notices contained within the Program. Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 4. COMMERCIAL DISTRIBUTION Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 5. NO WARRANTY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 6. DISCLAIMER OF LIABILITY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. GENERAL If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-hamcrest ================================================ BSD License Copyright (c) 2000-2015 www.hamcrest.org All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Hamcrest nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-jmustache ================================================ Copyright (c) 2010, Michael Bayne All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The name Michael Bayne may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-jopt ================================================ The MIT License Copyright (c) 2004-2016 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-jsch ================================================ JSch 0.0.* was released under the GNU LGPL license. Later, we have switched over to a BSD-style license. ------------------------------------------------------------------------------ Copyright (c) 2002-2015 Atsuhiko Yamanaka, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-jzlib ================================================ JZlib 0.0.* were released under the GNU LGPL license. Later, we have switched over to a BSD-style license. ------------------------------------------------------------------------------ Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-lombok ================================================ Copyright (C) 2009-2015 The Project Lombok Authors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-mit ================================================ MIT License Copyright (c) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-mockito ================================================ The MIT License Copyright (c) 2007 Mockito contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-mozilla-v20 ================================================ Mozilla Public License Version 2.0 1. Definitions 1.1. “Contributor” means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. “Contributor Version” means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution. 1.3. “Contribution” means Covered Software of a particular Contributor. 1.4. “Covered Software” means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. “Incompatible With Secondary Licenses” means that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. “Executable Form” means any form of the work other than Source Code Form. 1.7. “Larger Work” means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. “License” means this document. 1.9. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. “Modifications” means any of the following: any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or any new file in Source Code Form that contains any Covered Software. 1.11. “Patent Claims” of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. “Secondary License” means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. “Source Code Form” means the form of the work preferred for making modifications. 1.14. “You” (or “Your”) means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: for any code that a Contributor has removed from Covered Software; or for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. 6. Disclaimer of Warranty Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer. 7. Limitation of Liability Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You. 8. Litigation Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims. 9. Miscellaneous This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - “Incompatible With Secondary Licenses” Notice This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-slf4j ================================================ Copyright (c) 2004-2017 QOS.ch All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-threetenbp ================================================ /* * Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of JSR-310 nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-webjars ================================================ MIT License Copyright (c) 2017 James Ward Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: toolkit-distribution/src/release/licenses/LICENSE-woodstox-stax2-api ================================================ This copy of Stax2 API is licensed under the Simplified BSF License (also known as "2-clause BSD", or "FreeBSD License") See the License for details about distribution rights, and the specific rights regarding derivate works. You may obtain a copy of the License at: http://www.opensource.org/licenses/bsd-license.php with details of: = FasterXML.com = 2010- ================================================ FILE: toolkit-distribution/src/release/licenses/NOTICE-airline ================================================ Copyright Notices Copyright 2011 Dain Sundstrom dain@iq80.com Copyright 2010 Cedric Beust cedric@beust.com ================================================ FILE: toolkit-distribution/src/release/licenses/NOTICE-apache-commons-cli ================================================ Apache Commons CLI Copyright 2001-2019 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). ================================================ FILE: toolkit-distribution/src/release/licenses/NOTICE-apache-commons-codec ================================================ Apache Commons Codec Copyright 2002-2017 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java contains test data from http://aspell.net/test/orig/batch0.tab. Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org) =============================================================================== The content of package org.apache.commons.codec.language.bm has been translated from the original php source code available at http://stevemorse.org/phoneticinfo.htm with permission from the original authors. Original source copyright: Copyright (c) 2008 Alexander Beider & Stephen P. Morse. ================================================ FILE: toolkit-distribution/src/release/licenses/NOTICE-servicecomb-java-chassis ================================================ Apache ServiceComb Java Chassis Copyright 2017-2019 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). ================================================ FILE: toolkit-maven-plugin/pom.xml ================================================ toolkit org.apache.servicecomb.toolkit 0.3.0-SNAPSHOT 4.0.0 maven-plugin toolkit-maven-plugin org.apache.servicecomb.toolkit docgen org.apache.servicecomb.toolkit contractgen org.apache.servicecomb.toolkit codegen org.apache.maven maven-plugin-api org.apache.maven.plugin-tools maven-plugin-annotations org.apache.maven.plugin-tools maven-plugin-tools-annotations org.apache.maven maven-core org.checkerframework checker-compat-qual org.apache.servicecomb.toolkit common junit junit test org.apache.maven.plugin-testing maven-plugin-testing-harness test org.apache.maven maven-aether-provider test org.apache.maven maven-compat test org.powermock powermock-module-junit4 test org.powermock powermock-api-mockito test org.apache.maven.plugins maven-compiler-plugin org.apache.maven.plugins maven-plugin-plugin toolkit true generate-descriptor descriptor ================================================ FILE: toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/GenerateMojo.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; import org.apache.servicecomb.toolkit.codegen.GeneratorExternalConfigConstant; import org.apache.servicecomb.toolkit.codegen.ServiceType; import org.apache.servicecomb.toolkit.common.FileUtils; import org.apache.servicecomb.toolkit.common.SourceType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Mojo(name = "generate", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE, aggregator = true) @Execute(goal = "generate", phase = LifecyclePhase.COMPILE) public class GenerateMojo extends AbstractMojo { private static Logger LOGGER = LoggerFactory.getLogger(GenerateMojo.class); private String providerProjectNameSuffix = "-provider"; private String consumerProjectNameSuffix = "-consumer"; private String modelProjectNameSuffix = "-model"; @Parameter(defaultValue = "${project}") private MavenProject project; @Parameter(defaultValue = "code") private String sourceType; @Parameter(defaultValue = "yaml") private String contractFileType; @Parameter(defaultValue = "html") private String documentType; @Parameter private String contractLocation; @Parameter(defaultValue = "./target") private String outputDirectory; @Parameter private ServiceConfig service; /** * A map of additional properties that can be referenced by the mustache templates * * value * value * ... * */ @Parameter private Map additionalProperties; @Override public void execute() { checkConfig(); if (MavenPluginUtil.isParentProject(project)) { for (MavenProject subProject : project.getCollectedProjects()) { generateContract(subProject); generateDocument(subProject); } generateContract(project); generateDocument(project); generateCode(project); } else { generateContract(project); generateDocument(project); generateCode(project); } } private void checkConfig() { Optional.ofNullable(service).ifPresent(service -> { if (service.getServiceType().equalsIgnoreCase(ServiceType.CONSUMER.name())) { if (StringUtils.isEmpty(service.getProviderServiceId())) { throw new IllegalArgumentException("In consumer type, providerServiceId is required"); } } }); } private void generateContract(MavenProject project) { switch (SourceType.valueOf(sourceType.toUpperCase())) { case CODE: // generate contract file String contractOutput = outputDirectory + File.separator + "contract" + File.separator + project.getBasedir().getName(); try { FileUtils.createDirectory(contractOutput); } catch (IOException e) { throw new RuntimeException("Failed to generate contract", e); } GenerateUtil.generateContract(project, contractOutput, contractFileType, "default"); contractLocation = outputDirectory + File.separator + "contract"; if (Objects.requireNonNull(new File(contractOutput).listFiles()).length == 0) { //noinspection ResultOfMethodCallIgnored new File(contractOutput).delete(); LOGGER.info("No contract in the code"); return; } break; case CONTRACT: if (contractLocation == null) { throw new RuntimeException("Invalid or not config contract location"); } if (!new File(contractLocation).exists()) { throw new RuntimeException("Contract path " + contractLocation + " is not exists"); } break; default: throw new RuntimeException("Not support source type " + sourceType); } } private void generateCode(MavenProject project) { //generate microservice project if (service == null) { LOGGER.info("Cannot generate code without service configuration"); } else { String codeOutput = outputDirectory + File.separator + "project" + File.separator; try { FileUtils.createDirectory(codeOutput); Map externalConfig = Optional.ofNullable(additionalProperties).orElse(new HashMap<>()); externalConfig.put(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, project.getBasedir().getName() + providerProjectNameSuffix); externalConfig.put(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME, project.getBasedir().getName() + consumerProjectNameSuffix); externalConfig.put(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME, project.getBasedir().getName() + modelProjectNameSuffix); GenerateUtil.generateCode(service, contractLocation, codeOutput, externalConfig, "default"); } catch (RuntimeException | IOException e) { throw new RuntimeException("Failed to generate code", e); } } } private void generateDocument(MavenProject project) { //generate document String documentOutput = outputDirectory + File.separator + "document"; try { FileUtils.createDirectory(documentOutput); GenerateUtil.generateDocument(contractLocation, documentOutput, "default"); } catch (RuntimeException | IOException e) { throw new RuntimeException("Failed to generate document", e); } } } ================================================ FILE: toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/GenerateUtil.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import java.io.File; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.project.MavenProject; import org.apache.servicecomb.toolkit.CodeGenerator; import org.apache.servicecomb.toolkit.ContractsGenerator; import org.apache.servicecomb.toolkit.DocGenerator; import org.apache.servicecomb.toolkit.GeneratorFactory; import org.apache.servicecomb.toolkit.codegen.GeneratorExternalConfigConstant; import org.apache.servicecomb.toolkit.codegen.MicroServiceFramework; import org.apache.servicecomb.toolkit.codegen.ProjectMetaConstant; import org.openapitools.codegen.config.CodegenConfigurator; import io.swagger.parser.OpenAPIParser; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.parser.core.models.SwaggerParseResult; class GenerateUtil { private static String providerProjectNameSuffix = "-provider"; private static String consumerProjectNameSuffix = "-consumer"; private static String modelProjectNameSuffix = "-model"; public static void generateContract(MavenProject project, String contractOutput, String contractFileType, String type) { Map contractConfig = new HashMap<>(); try { contractConfig.put("classpathUrls", project.getRuntimeClasspathElements()); } catch (DependencyResolutionRequiredException e) { throw new RuntimeException("Failed to get runtime class elements", e); } contractConfig.put("outputDir", contractOutput); contractConfig.put("contractFileType", contractFileType); // TODO: support users to addParamCtx other getGenerator type soon ContractsGenerator contractGenerator = GeneratorFactory.getGenerator(ContractsGenerator.class, type); Objects.requireNonNull(contractGenerator).configure(contractConfig); contractGenerator.generate(); } static void generateDocument(String contractLocation, String documentOutput, String type) throws IOException { // TODO: support users to addParamCtx other getGenerator type soon DocGenerator docGenerator = GeneratorFactory.getGenerator(DocGenerator.class, type); if (docGenerator == null) { throw new RuntimeException("Cannot found document generator's implementation"); } Files.walkFileTree(Paths.get(contractLocation), new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (Files.isDirectory(file)) { return super.visitFile(file, attrs); } Map docGeneratorConfig = new HashMap<>(); SwaggerParseResult swaggerParseResult = new OpenAPIParser() .readLocation(file.toUri().toURL().toString(), null, null); OpenAPI openAPI = swaggerParseResult.getOpenAPI(); if (openAPI == null) { return super.visitFile(file, attrs); } docGeneratorConfig.put("contractContent", openAPI); docGeneratorConfig.put("outputPath", documentOutput + File.separator + file.getParent().toFile().getName() + File.separator + file.toFile() .getName() .substring(0, file.toFile().getName().indexOf("."))); docGenerator.configure(docGeneratorConfig); docGenerator.generate(); return super.visitFile(file, attrs); } }); } static void generateCode(ServiceConfig service, String contractLocation, String codeOutput, Map externalConfig, String type) throws IOException { CodeGenerator codeGenerator = GeneratorFactory.getGenerator(CodeGenerator.class, type); if (codeGenerator == null) { throw new RuntimeException("Cannot found code generator's implementation"); } File contractFile = new File(contractLocation); if (contractFile.isDirectory()) { List configurators = new ArrayList<>(); Files.walkFileTree(Paths.get(contractFile.toURI()), new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (Files.isDirectory(file)) { return super.visitFile(file, attrs); } CodegenConfigurator configurator = new CodegenConfigurator(); commonConfig(configurator, service); configurator.setOutputDir(codeOutput) .addAdditionalProperty(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, file.getParent().getFileName() + providerProjectNameSuffix) .addAdditionalProperty(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME, file.getParent().getFileName() + consumerProjectNameSuffix) .addAdditionalProperty(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME, file.getParent().getFileName() + modelProjectNameSuffix) .addAdditionalProperty("apiName", file.toFile().getName().split("\\.")[0]) .addAdditionalProperty("microserviceName", file.getParent().getFileName().toString()); configurator.setInputSpec(file.toFile().getCanonicalPath()); configurators.add(configurator); return super.visitFile(file, attrs); } }); Objects.requireNonNull(codeGenerator).configure(Collections.singletonMap("configurators", configurators)); codeGenerator.generate(); } else { CodegenConfigurator configurator = new CodegenConfigurator(); commonConfig(configurator, service); configurator.setOutputDir(codeOutput) .addAdditionalProperty(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, contractFile.getParentFile().getName() + providerProjectNameSuffix) .addAdditionalProperty(GeneratorExternalConfigConstant.CONSUMER_PROJECT_NAME, contractFile.getParentFile().getName() + consumerProjectNameSuffix) .addAdditionalProperty(GeneratorExternalConfigConstant.MODEL_PROJECT_NAME, contractFile.getParentFile().getName() + modelProjectNameSuffix) .addAdditionalProperty("apiName", contractFile.getName().split("\\.")[0]) .addAdditionalProperty("microserviceName", contractFile.getParentFile().getName()); configurator.setInputSpec(contractLocation); Objects.requireNonNull(codeGenerator) .configure(Collections.singletonMap("configurators", Collections.singletonList(configurator))); codeGenerator.generate(); } } private static void commonConfig(CodegenConfigurator configurator, ServiceConfig service) { configurator .setGeneratorName(service.getMicroServiceFramework()) .setGroupId(service.getGroupId()) .setArtifactId(service.getArtifactId()) .setModelPackage(service.getPackageName()) .addAdditionalProperty("mainClassPackage", Optional.ofNullable(service.getPackageName()).orElse("")) .setArtifactVersion(service.getArtifactVersion()) .addAdditionalProperty(ProjectMetaConstant.SERVICE_TYPE, Optional.ofNullable(service.getServiceType()).orElse("all")) .addAdditionalProperty(ProjectMetaConstant.SERVICE_ID, service.getServiceId()); Optional.ofNullable(service.getProviderServiceId()).ifPresent(providerServiceId -> configurator .addAdditionalProperty(ProjectMetaConstant.PROVIDER_SERVICE_ID, service.getProviderServiceId())); if (MicroServiceFramework.SERVICECOMB.name().equalsIgnoreCase(service.getMicroServiceFramework())) { configurator.setLibrary(service.getProgrammingModel()); } configurator.setApiPackage( Optional.ofNullable(service.getApiPackage()).orElse(String.format("%s.api", service.getPackageName()))); configurator.setModelPackage( Optional.ofNullable(service.getModelPackage()).orElse(String.format("%s.model", service.getPackageName()))); } } ================================================ FILE: toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/MavenPluginUtil.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import org.apache.maven.project.MavenProject; public class MavenPluginUtil { private static final String PARENT_PROJECT_PACKAGING = "pom"; public static boolean isParentProject(MavenProject project){ return PARENT_PROJECT_PACKAGING.equals(project.getPackaging()); } } ================================================ FILE: toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/ServiceConfig.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import org.apache.commons.lang3.StringUtils; public class ServiceConfig { private String serviceType = "all"; private String groupId = "domain.orgnization.project"; private String artifactId = "sample"; private String artifactVersion = "0.1.0-SNAPSHOT"; private String packageName = "domain.orgnization.project.sample"; private String programmingModel = "SpringMVC"; private String microServiceFramework = "ServiceComb"; // only for consumer private String providerServiceId; private String serviceId; private String apiPackage; private String modelPackage; public String getServiceType() { return serviceType; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } public String getArtifactVersion() { return artifactVersion; } public String getPackageName() { return packageName; } public String getProgrammingModel() { return programmingModel; } public String getMicroServiceFramework() { return microServiceFramework; } public String getProviderServiceId() { return providerServiceId; } public String getServiceId() { // Default, serviceId equals artifactId if (StringUtils.isEmpty(serviceId) && StringUtils.isNotEmpty(artifactId)) { serviceId = artifactId; } return serviceId; } public String getApiPackage() { return apiPackage; } public String getModelPackage() { return modelPackage; } } ================================================ FILE: toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/VerifyMojo.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import java.io.IOException; import java.util.Map; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; import org.apache.servicecomb.toolkit.common.ContractComparator; import org.apache.servicecomb.toolkit.common.FileUtils; import org.apache.servicecomb.toolkit.common.SourceType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Mojo(name = "verify", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE) @Execute(goal = "verify", phase = LifecyclePhase.COMPILE) public class VerifyMojo extends AbstractMojo { private final static Logger LOGGER = LoggerFactory.getLogger(VerifyMojo.class); @Parameter(defaultValue = "${project}", required = true, readonly = true) private MavenProject project; @Parameter(defaultValue = "code") private String sourceType; @Parameter private String sourceContractPath; @Parameter private String destinationContractPath; @Override public void execute() { String contractFileType = "yaml"; switch (SourceType.valueOf(sourceType.toUpperCase())) { case CODE: try { sourceContractPath = FileUtils.createTempDirectory("target/tmp-contract").toFile().getCanonicalPath(); GenerateUtil.generateContract(project, sourceContractPath, contractFileType, "default"); } catch (RuntimeException | IOException e) { throw new RuntimeException("Failed to generate contract from code", e); } break; case CONTRACT: break; default: throw new RuntimeException("Not support source type " + sourceType); } try { Map sourceContractGroup = FileUtils.getFilesGroupByFilename(sourceContractPath); Map destinationContractGroup = FileUtils.getFilesGroupByFilename(destinationContractPath); sourceContractGroup.forEach((contractName, swagger) -> { byte[] sourceSwagger = destinationContractGroup.get(contractName); ContractComparator contractComparator = new ContractComparator(new String(sourceSwagger), new String(swagger)); if (!contractComparator.equals()) { LOGGER.info("Contract is not matched, difference is as follows"); LOGGER.info(destinationContractPath + "/" + contractName + " vs " + sourceContractPath + "/" + contractName); contractComparator.splitPrintToScreen(); } else { LOGGER.info("Succee, contract verification passed"); } }); } catch (IOException e) { throw new RuntimeException("Failed to verify contract ", e); } } } ================================================ FILE: toolkit-maven-plugin/src/test/java/org/apache/servicecomb/toolkit/plugin/GenerateMojoTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import java.io.File; import java.util.Collections; import java.util.HashMap; import java.util.Objects; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.MojoRule; import org.apache.maven.plugin.testing.resources.TestResources; import org.apache.maven.project.MavenProject; import org.apache.servicecomb.toolkit.common.FileUtils; import org.junit.Rule; import org.junit.Test; public class GenerateMojoTest { @Rule public MojoRule rule = new MojoRule(); @Rule public TestResources resources = new TestResources(); @Test public void testGenerateMojo() throws Exception { TestResourcesEx testResourcesEx = new TestResourcesEx(resources); String testDirWithContract = testResourcesEx.getBasedirWithContract(); String testDirWithoutContract = testResourcesEx.getBasedirWithoutContract(); String testDirMultiModule = testResourcesEx.getBasedirMultiModule(); String outputDirectory = null; String contractOutput = null; String projectOutput = null; String documentOutput = null; final MavenProject project = mock(MavenProject.class); given(project.getBasedir()).willReturn(new File("mockProject")); // code has no contract testResourcesEx.createMojo(rule, "generate"); testResourcesEx.setVariableValueToObject("project", project); given(project.getRuntimeClasspathElements()).willReturn(testResourcesEx.getRuntimeUrlPath(testDirWithoutContract)); try { outputDirectory = "target/GenerateMojoTest"; FileUtils.deleteDirectory(outputDirectory); testResourcesEx.setVariableValueToObject("sourceType", "code"); testResourcesEx.setVariableValueToObject("outputDirectory", outputDirectory); testResourcesEx.execute(); assertFalse(new File(testResourcesEx.getVariableValueFromObject("contractLocation")).listFiles().length != 0); } catch (MojoFailureException e) { fail("Run 'testGenerateMojo' failed, unexpected to catch MojoFailureException: " + e.getMessage()); } // code has contract testResourcesEx.createMojo(rule, "generate"); testResourcesEx.setVariableValueToObject("project", project); given(project.getRuntimeClasspathElements()).willReturn(testResourcesEx.getRuntimeUrlPath(testDirWithContract)); try { outputDirectory = "target/GenerateMojoTest"; contractOutput = outputDirectory + File.separator + "contract"; projectOutput = outputDirectory + File.separator + "project"; documentOutput = outputDirectory + File.separator + "document"; testResourcesEx.setVariableValueToObject("sourceType", "code"); testResourcesEx.setVariableValueToObject("outputDirectory", outputDirectory); testResourcesEx.setVariableValueToObject("contractFileType", "yaml"); testResourcesEx.setVariableValueToObject("documentType", "html"); testResourcesEx.setVariableValueToObject("service", new ServiceConfig()); testResourcesEx.setVariableValueToObject("additionalProperties", new HashMap<>()); testResourcesEx.execute(); assertNotEquals(0, Objects.requireNonNull(new File(contractOutput).listFiles()).length); assertNotEquals(0, Objects.requireNonNull(new File(projectOutput).listFiles()).length); assertNotEquals(0, Objects.requireNonNull(new File(documentOutput).listFiles()).length); } catch (RuntimeException e) { e.printStackTrace(); fail("Run 'testGenerateMojo' failed, unexpected to catch RuntimeException: " + e.getMessage()); } try { testResourcesEx.setVariableValueToObject("sourceType", "contract"); testResourcesEx.setVariableValueToObject("contractLocation", null); testResourcesEx.execute(); fail("Run 'testGenerateMojo' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Invalid or not config contract location", e.getMessage()); } try { testResourcesEx.setVariableValueToObject("sourceType", "contract"); testResourcesEx.setVariableValueToObject("contractLocation", ""); testResourcesEx.execute(); fail("Run 'testGenerateMojo' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertThat(e.getMessage(), containsString("is not exists")); } try { outputDirectory = "target/GenerateMojoTest"; projectOutput = outputDirectory + File.separator + "project"; documentOutput = outputDirectory + File.separator + "document"; testResourcesEx.setVariableValueToObject("sourceType", "contract"); testResourcesEx.setVariableValueToObject("contractLocation", testResourcesEx.getContractLocation()); testResourcesEx.setVariableValueToObject("outputDirectory", outputDirectory); testResourcesEx.setVariableValueToObject("service", new ServiceConfig()); testResourcesEx.execute(); assertNotEquals(0, Objects.requireNonNull(new File(projectOutput).listFiles()).length); assertNotEquals(0, Objects.requireNonNull(new File(documentOutput).listFiles()).length); } catch (RuntimeException e) { fail("Run 'testGenerateMojo' failed, unexpected to catch RuntimeException: " + e.getMessage()); } outputDirectory = "target/GenerateMojoTest"; projectOutput = outputDirectory + File.separator + "project"; ServiceConfig service = new ServiceConfig(); testResourcesEx.setVariableValueToObject("sourceType", "code"); testResourcesEx.setVariableValueToObject("outputDirectory", outputDirectory); FileUtils.deleteDirectory(projectOutput); FileUtils.createDirectory(projectOutput); testResourcesEx.setVariableValueToObject("service", null); testResourcesEx.execute(); assertEquals(0, Objects.requireNonNull(new File(projectOutput).listFiles()).length); testResourcesEx.setVariableValueToObject("sourceType", "code"); testResourcesEx.setVariableValueToObject("outputDirectory", outputDirectory); testResourcesEx.setVariableValueToObject("service", service); testResourcesEx.execute(); assertNotEquals(0, Objects.requireNonNull(new File(projectOutput).listFiles()).length); // test multi module given(project.getRuntimeClasspathElements()).willReturn(testResourcesEx.getRuntimeUrlPath(testDirMultiModule)); MavenProject subModuleProject = mock(MavenProject.class); given(subModuleProject.getRuntimeClasspathElements()) .willReturn(testResourcesEx.getRuntimeUrlPath(testDirMultiModule + File.separator + "first-module")); given(subModuleProject.getBasedir()).willReturn(new File("mockSubModuleProject")); given(project.getPackaging()).willReturn("pom"); given(project.getCollectedProjects()).willReturn(Collections.singletonList(subModuleProject)); try { outputDirectory = "target/GenerateMojoTest"; FileUtils.deleteDirectory(outputDirectory); testResourcesEx.setVariableValueToObject("sourceType", "code"); testResourcesEx.setVariableValueToObject("outputDirectory", outputDirectory); testResourcesEx.setVariableValueToObject("contractFileType", "yaml"); testResourcesEx.setVariableValueToObject("documentType", "html"); testResourcesEx.setVariableValueToObject("service", new ServiceConfig()); testResourcesEx.execute(); assertFalse(new File(testResourcesEx.getVariableValueFromObject("contractLocation")).listFiles().length != 0); } catch (RuntimeException e) { fail("Run 'testGenerateMojo' failed, unexpected to catch RuntimeException: " + e.getMessage()); } } } ================================================ FILE: toolkit-maven-plugin/src/test/java/org/apache/servicecomb/toolkit/plugin/GenerateUtilTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import static org.apache.servicecomb.toolkit.plugin.GenerateUtil.generateCode; import static org.apache.servicecomb.toolkit.plugin.GenerateUtil.generateContract; import static org.apache.servicecomb.toolkit.plugin.GenerateUtil.generateDocument; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.File; import java.util.Collections; import java.util.Objects; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.testing.resources.TestResources; import org.apache.maven.project.MavenProject; import org.junit.Before; import org.junit.Rule; import org.junit.Test; public class GenerateUtilTest { @Rule public TestResources resources = new TestResources(); private TestResourcesEx testResourcesEx; @Before public void setUp() throws Exception { this.testResourcesEx = new TestResourcesEx(resources); } @SuppressWarnings("unchecked") @Test public void testGenerateContract() throws DependencyResolutionRequiredException { MavenProject project = mock(MavenProject.class); String contractOutput = "target/GenerateUtilTest/contract"; when(project.getRuntimeClasspathElements()).thenThrow(DependencyResolutionRequiredException.class); try { generateContract(project, contractOutput, "yaml", "default"); fail("Run 'testGenerateContract' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to get runtime class elements", e.getMessage()); } } @SuppressWarnings("unchecked") @Test public void testGenerateCode() throws Exception { String contractLocation = this.testResourcesEx.getContractLocation(); String projectOutput = "target/GenerateUtilTest/project"; ServiceConfig service = new ServiceConfig(); generateCode(service, contractLocation, projectOutput, Collections.EMPTY_MAP, "default"); assertNotEquals(0, Objects.requireNonNull(new File(projectOutput).listFiles()).length); try { generateCode(service, contractLocation, projectOutput, Collections.EMPTY_MAP, "invalidType"); fail("Run 'testGenerateCode' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Cannot found code generator's implementation", e.getMessage()); } // Test the scenario where the configuration property contractLocation is specified as a file generateCode(service, contractLocation + File.separator + "HelloEndPoint.yaml", projectOutput, Collections.EMPTY_MAP, "default"); assertNotEquals(0, Objects.requireNonNull(new File(projectOutput).listFiles()).length); } @Test public void testGenerateDocument() throws Exception { String contractLocation = this.testResourcesEx.getContractLocation(); String codeOutput = "target/GenerateUtilTest/document"; generateDocument(contractLocation, codeOutput, "default"); assertNotEquals(0, Objects.requireNonNull(new File(codeOutput).listFiles()).length); try { generateDocument(contractLocation, codeOutput, "invalidType"); fail("Run 'testGenerateDocument' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Cannot found document generator's implementation", e.getMessage()); } } } ================================================ FILE: toolkit-maven-plugin/src/test/java/org/apache/servicecomb/toolkit/plugin/InvokeStaticMethodTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import java.io.File; import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.MojoRule; import org.apache.maven.plugin.testing.resources.TestResources; import org.apache.maven.project.MavenProject; import org.apache.servicecomb.toolkit.common.FileUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) @PrepareForTest({FileUtils.class, GenerateUtil.class}) @PowerMockIgnore({"javax.management.*"}) public class InvokeStaticMethodTest { @Rule public MojoRule rule = new MojoRule(); @Rule public TestResources resources = new TestResources(); private TestResourcesEx testGenerateMojoResources; private TestResourcesEx testVerifyMojoResources; @Before public void setUp() throws Exception { testGenerateMojoResources = new TestResourcesEx(resources); testVerifyMojoResources = new TestResourcesEx(resources); testGenerateMojoResources.createMojo(rule, "generate"); testVerifyMojoResources.createMojo(rule, "verify"); MavenProject project = mock(MavenProject.class); given(project.getBasedir()).willReturn(new File("mockProject")); testGenerateMojoResources.setVariableValueToObject("project", project); testVerifyMojoResources.setVariableValueToObject("project", project); } @Test public void testVerifyMojoInvokeGenerateUtilGenerateContract() throws MojoFailureException, MojoExecutionException, IllegalAccessException { PowerMockito.mockStatic(GenerateUtil.class); PowerMockito.doThrow(new RuntimeException()).when(GenerateUtil.class); // Powermockito limit: use argument matchers to specify method which would be mock GenerateUtil.generateContract(anyObject(), anyString(), anyString(), anyString()); testVerifyMojoResources.setVariableValueToObject("sourceType", "code"); try { testVerifyMojoResources.execute(); fail("Run 'testVerifyMojoInvokeGenerateUtilGenerateContract' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to generate contract from code", e.getMessage()); assertThat(e.getCause().toString(), containsString("RuntimeException")); } } @Test public void testVerifyMojoInvokeFileUtilsCreateTempDirectory() throws MojoFailureException, MojoExecutionException, IllegalAccessException, IOException { PowerMockito.mockStatic(FileUtils.class); PowerMockito.doThrow(new IOException()).when(FileUtils.class); // Powermockito limit: use argument matchers to specify method which would be mock FileUtils.createTempDirectory(anyString()); testVerifyMojoResources.setVariableValueToObject("sourceType", "code"); try { testVerifyMojoResources.execute(); fail("Run 'testVerifyMojoInvokeFileUtilsCreateTempDirectory' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to generate contract from code", e.getMessage()); assertThat(e.getCause().toString(), containsString("IOException")); } } @Test public void testGenerateMojoInvokeFileUtilsCreateDirectory() throws IllegalAccessException, MojoFailureException, MojoExecutionException, IOException { PowerMockito.mockStatic(FileUtils.class); PowerMockito.doThrow(new IOException()).when(FileUtils.class); // Powermockito limit: use argument matchers to specify method which would be mock FileUtils.createDirectory(anyString()); testGenerateMojoResources.setVariableValueToObject("sourceType", "code"); try { testGenerateMojoResources.execute(); fail("Run 'testGenerateMojoInvokeFileUtilsCreateDirectory' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to generate contract", e.getMessage()); assertThat(e.getCause().toString(), containsString("IOException")); } } @Test public void testGenerateMojoInvokeGenerateUtilGenerateCode() throws IllegalAccessException, MojoFailureException, MojoExecutionException, IOException { PowerMockito.mockStatic(GenerateUtil.class); PowerMockito.doThrow(new IOException()).when(GenerateUtil.class); // Powermockito limit: use argument matchers to specify method which would be mock GenerateUtil.generateCode(anyObject(), anyString(), anyString(), any(), anyString()); testGenerateMojoResources.setVariableValueToObject("sourceType", "contract"); testGenerateMojoResources.setVariableValueToObject("outputDirectory", "target/InvokeStaticMethodTest"); testGenerateMojoResources .setVariableValueToObject("contractLocation", testGenerateMojoResources.getContractLocation()); testGenerateMojoResources.setVariableValueToObject("service", new ServiceConfig()); try { testGenerateMojoResources.execute(); fail("Run 'testGenerateMojoInvokeGenerateUtilGenerateCode' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to generate code", e.getMessage()); assertThat(e.getCause().toString(), containsString("IOException")); } PowerMockito.doThrow(new RuntimeException()).when(GenerateUtil.class); GenerateUtil.generateCode(anyObject(), anyString(), anyString(), any(), anyString()); try { testGenerateMojoResources.execute(); fail("Run 'testGenerateMojoInvokeGenerateUtilGenerateCode' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to generate code", e.getMessage()); assertThat(e.getCause().toString(), containsString("RuntimeException")); } } @Test public void testGenerateMojoInvokeGenerateUtilGenerateDocument() throws IllegalAccessException, MojoFailureException, MojoExecutionException, IOException { PowerMockito.mockStatic(GenerateUtil.class); PowerMockito.doThrow(new IOException()).when(GenerateUtil.class); // Powermockito limit: use argument matchers to specify method which would be mock GenerateUtil.generateDocument(anyString(), anyString(), anyString()); testGenerateMojoResources.setVariableValueToObject("sourceType", "contract"); testGenerateMojoResources.setVariableValueToObject("outputDirectory", "target/InvokeStaticMethodTest"); testGenerateMojoResources .setVariableValueToObject("contractLocation", testGenerateMojoResources.getContractLocation()); testGenerateMojoResources.setVariableValueToObject("service", new ServiceConfig()); try { testGenerateMojoResources.execute(); fail( "Run 'testGenerateMojoInvokeGenerateUtilGenerateDocument' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to generate document", e.getMessage()); assertThat(e.getCause().toString(), containsString("IOException")); } PowerMockito.doThrow(new RuntimeException()).when(GenerateUtil.class); GenerateUtil.generateDocument(anyString(), anyString(), anyString()); try { testGenerateMojoResources.execute(); fail( "Run 'testGenerateMojoInvokeGenerateUtilGenerateDocument' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertEquals("Failed to generate document", e.getMessage()); assertThat(e.getCause().toString(), containsString("RuntimeException")); } } } ================================================ FILE: toolkit-maven-plugin/src/test/java/org/apache/servicecomb/toolkit/plugin/MavenPluginUtilTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import org.apache.maven.project.MavenProject; import org.junit.Test; public class MavenPluginUtilTest { @Test public void isParentMavenProject() { MavenProject mavenProject = mock(MavenProject.class); given(mavenProject.getPackaging()).willReturn("pom"); assertEquals(mavenProject.getPackaging(), "pom"); MavenPluginUtil mavenPluginUtil = new MavenPluginUtil(); assertTrue(mavenPluginUtil.isParentProject(mavenProject)); } @Test public void notParentMavenProject() { MavenProject mavenProject = mock(MavenProject.class); given(mavenProject.getPackaging()).willReturn("jar"); assertEquals(mavenProject.getPackaging(), "jar"); MavenPluginUtil mavenPluginUtil = new MavenPluginUtil(); assertFalse(mavenPluginUtil.isParentProject(mavenProject)); } } ================================================ FILE: toolkit-maven-plugin/src/test/java/org/apache/servicecomb/toolkit/plugin/TestResourcesEx.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeoutException; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.MojoRule; import org.apache.maven.plugin.testing.resources.TestResources; import org.apache.servicecomb.toolkit.common.ClassMaker; class TestResourcesEx { private String basedirWithContract; private String basedirWithoutContract; private String contractLocation; private String contractDestination; private String basedirMultiModule; private AbstractMojo testMojo; private MojoRule rule; TestResourcesEx(TestResources resources) throws Exception { this.basedirWithContract = resources.getBasedir("demo-with-contract") + File.separator; this.basedirWithoutContract = resources.getBasedir("demo-without-contract") + File.separator; this.contractLocation = resources.getBasedir("contract-source") + File.separator; this.contractDestination = resources.getBasedir("contract-destination") + File.separator; this.basedirMultiModule = resources.getBasedir("demo-multi-module") + File.separator; } void createMojo(MojoRule rule, String pluginGoal) { this.rule = rule; this.testMojo = mockMojo(pluginGoal); } void setVariableValueToObject(String variable, Object value) throws IllegalAccessException { this.rule.setVariableValueToObject(this.testMojo, variable, value); } String getVariableValueFromObject(@SuppressWarnings("SameParameterValue") String variable) throws IllegalAccessException { return (String) this.rule.getVariableValueFromObject(this.testMojo, variable); } String getBasedirWithContract() { return basedirWithContract; } String getBasedirWithoutContract() { return basedirWithoutContract; } String getBasedirMultiModule() { return basedirMultiModule; } String getContractLocation() { return contractLocation; } String getContractDestination() { return contractDestination; } void execute() throws MojoFailureException, MojoExecutionException { this.testMojo.execute(); } List getRuntimeUrlPath(String basedir) throws InterruptedException, TimeoutException, IOException { ClassMaker.compile(basedir); List runtimeUrlPath = new ArrayList<>(); runtimeUrlPath.add(basedir + "target" + File.separator + "classes"); return runtimeUrlPath; } private AbstractMojo mockMojo(String pluginGoal) { switch (pluginGoal) { case "generate": return new GenerateMojo(); case "verify": return new VerifyMojo(); default: throw new RuntimeException("undefined plugin goal"); } } } ================================================ FILE: toolkit-maven-plugin/src/test/java/org/apache/servicecomb/toolkit/plugin/VerifyMojoTest.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.servicecomb.toolkit.plugin; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import org.apache.maven.plugin.testing.MojoRule; import org.apache.maven.plugin.testing.resources.TestResources; import org.apache.maven.project.MavenProject; import org.junit.Rule; import org.junit.Test; public class VerifyMojoTest { @Rule public MojoRule rule = new MojoRule(); @Rule public TestResources resources = new TestResources(); @Test public void testVerifyMojo() throws Exception { TestResourcesEx testResourcesEx = new TestResourcesEx(resources); String testDirWithContract = testResourcesEx.getBasedirWithContract(); testResourcesEx.createMojo(rule, "verify"); MavenProject project = mock(MavenProject.class); testResourcesEx.setVariableValueToObject("project", project); try { given(project.getRuntimeClasspathElements()).willReturn(testResourcesEx.getRuntimeUrlPath(testDirWithContract)); testResourcesEx.setVariableValueToObject("sourceType", "code"); testResourcesEx.setVariableValueToObject("destinationContractPath", testResourcesEx.getContractDestination()); testResourcesEx.execute(); } catch (RuntimeException e) { fail("Run 'testVerifyMojo' failed, unexpected to catch RuntimeException: " + e.getMessage()); } try { testResourcesEx.setVariableValueToObject("sourceType", "contract"); testResourcesEx.setVariableValueToObject("sourceContractPath", null); testResourcesEx.execute(); fail("Run 'testVerifyMojo' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertThat(e.getMessage(), containsString("Failed to verify contract")); } try { testResourcesEx.setVariableValueToObject("sourceType", "contract"); testResourcesEx.setVariableValueToObject("sourceContractPath", testResourcesEx.getContractLocation()); testResourcesEx.setVariableValueToObject("destinationContractPath", null); testResourcesEx.execute(); fail("Run 'testVerifyMojo' failed, expected to occur RuntimeException but not"); } catch (RuntimeException e) { assertThat(e.getMessage(), containsString("Failed to verify contract")); } try { testResourcesEx.setVariableValueToObject("sourceType", "contract"); testResourcesEx.setVariableValueToObject("sourceContractPath", testResourcesEx.getContractLocation()); testResourcesEx.setVariableValueToObject("destinationContractPath", testResourcesEx.getContractDestination()); testResourcesEx.execute(); } catch (RuntimeException e) { fail("Run 'testVerifyMojo' failed, unexpected to catch RuntimeException: " + e.getMessage()); } } } ================================================ FILE: toolkit-maven-plugin/src/test/projects/contract-destination/HelloEndPoint.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for demo.HelloEndPoint" x-java-interface: "gen.swagger.HelloEndPointIntf" basePath: "/hello" consumes: - "application/json" produces: - "application/json" paths: /sayHello: get: operationId: "sayHello" parameters: - name: "name" in: "query" required: require type: "string" responses: 200: description: "response of 200" schema: type: "string" /sayHi: get: operationId: "sayHi" parameters: - name: "name" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: toolkit-maven-plugin/src/test/projects/contract-source/HelloEndPoint.yaml ================================================ ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- --- swagger: "2.0" info: version: "1.0.0" title: "swagger definition for demo.HelloEndPoint" x-java-interface: "gen.swagger.HelloEndPointIntf" basePath: "/hello" consumes: - "application/json" produces: - "application/json" paths: /sayHello: get: operationId: "sayHello" parameters: - name: "name" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" /sayHi: get: operationId: "sayHi" parameters: - name: "name" in: "query" required: false type: "string" responses: 200: description: "response of 200" schema: type: "string" ================================================ FILE: toolkit-maven-plugin/src/test/projects/demo-multi-module/first-module/pom.xml ================================================ 4.0.0 org.apache.servicecomb.toolkit demo-multi-module 0.3.0-SNAPSHOT first-module ================================================ FILE: toolkit-maven-plugin/src/test/projects/demo-multi-module/pom.xml ================================================ 4.0.0 org.apache.servicecomb.toolkit demo-multi-module 0.3.0-SNAPSHOT demo-multi-module-test pom first-module ================================================ FILE: toolkit-maven-plugin/src/test/projects/demo-with-contract/pom.xml ================================================ 4.0.0 org.apache.servicecomb.toolkit demo-with-contract 0.3.0-SNAPSHOT demo-with-contract-test jar org.springframework.boot spring-boot-starter-parent 1.5.12.RELEASE org.springframework.boot spring-boot-starter org.springframework spring-web ================================================ FILE: toolkit-maven-plugin/src/test/projects/demo-with-contract/src/main/java/demo/Application.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public Application() { } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ================================================ FILE: toolkit-maven-plugin/src/test/projects/demo-with-contract/src/main/java/demo/HelloEndPoint.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package demo; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping({"/hello"}) public class HelloEndPoint { public HelloEndPoint() { } @GetMapping({"/sayHello"}) public String sayHello(String name) { return "Hello, " + name; } @GetMapping({"/sayHi"}) public String sayHi(String name) { return "Hi, " + name; } } ================================================ FILE: toolkit-maven-plugin/src/test/projects/demo-without-contract/pom.xml ================================================ 4.0.0 org.apache.servicecomb.toolkit demo-without-contract 0.3.0-SNAPSHOT demo-without-contract-test jar org.springframework.boot spring-boot-starter-parent 1.5.12.RELEASE org.springframework.boot spring-boot-starter ================================================ FILE: toolkit-maven-plugin/src/test/projects/demo-without-contract/src/main/java/demo/Application.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public Application() { } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ================================================ FILE: toolkit-maven-plugin/src/test/resources/log4j2-test.xml ================================================