Skip to content

Commit

Permalink
Merge pull request #1657 from znsio/debug_logs_for_example_load_stubs
Browse files Browse the repository at this point in the history
Add debug logs for explicit example loading stage in stub
  • Loading branch information
joelrosario authored Mar 6, 2025
2 parents b320d7b + 6ecfed7 commit f983f52
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 136 deletions.
5 changes: 3 additions & 2 deletions application/src/main/kotlin/application/StubCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class StubCommand : Callable<Unit> {
@Autowired
private var specmaticConfig: SpecmaticConfig = SpecmaticConfig()

@Parameters(arity = "0..*", description = ["Contract file paths"])
@Parameters(arity = "0..*", description = ["Contract file paths", "Spec file paths"])
var contractPaths: List<String> = mutableListOf()

@Option(names = ["--data", "--examples"], description = ["Directories containing JSON examples"], required = false)
Expand Down Expand Up @@ -130,8 +130,9 @@ class StubCommand : Callable<Unit> {
try {
contractSources = when (contractPaths.isEmpty()) {
true -> {
logger.debug("No contractPaths specified. Using configuration file named $configFileName")
specmaticConfigPath = File(Configuration.configFilePath).canonicalPath

logger.debug("Using the spec paths configured for stubs in the configuration file '$specmaticConfigPath'")
specmaticConfig.contractStubPathData()
}
else -> contractPaths.map {
Expand Down
4 changes: 1 addition & 3 deletions application/src/main/kotlin/application/StubLoaderEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class StubLoaderEngine {

return when {
dataDirs.isNotEmpty() -> {
loadContractStubsFromFiles(contractPathDataList, dataDirs, specmaticConfig, strictMode).plus(
loadContractStubsFromImplicitPaths(contractPathDataList, specmaticConfig, dataDirs)
)
loadContractStubsFromFiles(contractPathDataList, dataDirs, specmaticConfig, strictMode, withImplicitStubs = true)
}
else -> loadContractStubsFromImplicitPaths(contractPathDataList, specmaticConfig, dataDirs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class OpenApiSpecification(
val data: List<Pair<List<ScenarioInfo>, Map<String, List<Pair<HttpRequest, HttpResponse>>>>> =
openApiPaths().map { (openApiPath, pathItem) ->
val scenariosAndExamples = openApiOperations(pathItem).map { (httpMethod, openApiOperation) ->
logger.debug("\n\nProcessing $httpMethod $openApiPath")
logger.debug("${System.lineSeparator()}Processing $httpMethod $openApiPath")

try {
openApiOperation.validateParameters()
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/kotlin/io/specmatic/core/Feature.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fun parseContractFileToFeature(
overlayContent: String = "",
strictMode: Boolean = false
): Feature {
logger.debug("Parsing contract file ${file.path}, absolute path ${file.absolutePath}")
logger.debug("Parsing spec file ${file.path}, absolute path ${file.canonicalPath}")
return when (file.extension) {
in OPENAPI_FILE_EXTENSIONS -> OpenApiSpecification.fromYAML(
hook.readContract(file.path),
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/kotlin/io/specmatic/core/utilities/Utilities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ fun contractFilePathsFrom(configFilePath: String, workingDirectory: String, sele
it.loadContracts(selector, workingDirectory, configFilePath)
}

logger.debug("Contract file paths in $configFilePath:")
logger.debug(contractPathData.joinToString(System.lineSeparator()) { it.path }.prependIndent(" "))
logger.debug("Spec file paths in $configFilePath:")
logger.debug(contractPathData.joinToString(System.lineSeparator()) { "- ${it.path}" })

return contractPathData
}
Expand Down
Loading

0 comments on commit f983f52

Please sign in to comment.