Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File and URL names are used in JDK / suggested in IDE auto-import. Rename our classes to avoid conflict #725

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public sealed interface SupportedFormat {
public sealed interface SupportedFormatSample {

@JvmInline
public value class File(public val sampleFile: java.io.File) : SupportedFormatSample
public value class DataFile(public val sampleFile: File) : SupportedFormatSample

@JvmInline
public value class URL(public val sampleUrl: java.net.URL) : SupportedFormatSample
public value class DataUrl(public val sampleUrl: URL) : SupportedFormatSample

@JvmInline
public value class PathString(public val samplePath: String) : SupportedFormatSample
Expand Down Expand Up @@ -138,13 +138,13 @@ internal fun guessFormatForExtension(
internal fun guessFormat(
file: File,
formats: List<SupportedFormat> = supportedFormats,
sample: SupportedFormatSample.File? = SupportedFormatSample.File(file),
sample: SupportedFormatSample.DataFile? = SupportedFormatSample.DataFile(file),
): SupportedFormat? = guessFormatForExtension(file.extension.lowercase(), formats, sample = sample)

internal fun guessFormat(
url: URL,
formats: List<SupportedFormat> = supportedFormats,
sample: SupportedFormatSample.URL? = SupportedFormatSample.URL(url),
sample: SupportedFormatSample.DataUrl? = SupportedFormatSample.DataUrl(url),
): SupportedFormat? = guessFormatForExtension(url.path.substringAfterLast("."), formats, sample = sample)

internal fun guessFormat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public sealed interface SupportedFormat {
public sealed interface SupportedFormatSample {

@JvmInline
public value class File(public val sampleFile: java.io.File) : SupportedFormatSample
public value class DataFile(public val sampleFile: File) : SupportedFormatSample

@JvmInline
public value class URL(public val sampleUrl: java.net.URL) : SupportedFormatSample
public value class DataUrl(public val sampleUrl: URL) : SupportedFormatSample

@JvmInline
public value class PathString(public val samplePath: String) : SupportedFormatSample
Expand Down Expand Up @@ -138,13 +138,13 @@ internal fun guessFormatForExtension(
internal fun guessFormat(
file: File,
formats: List<SupportedFormat> = supportedFormats,
sample: SupportedFormatSample.File? = SupportedFormatSample.File(file),
sample: SupportedFormatSample.DataFile? = SupportedFormatSample.DataFile(file),
): SupportedFormat? = guessFormatForExtension(file.extension.lowercase(), formats, sample = sample)

internal fun guessFormat(
url: URL,
formats: List<SupportedFormat> = supportedFormats,
sample: SupportedFormatSample.URL? = SupportedFormatSample.URL(url),
sample: SupportedFormatSample.DataUrl? = SupportedFormatSample.DataUrl(url),
): SupportedFormat? = guessFormatForExtension(url.path.substringAfterLast("."), formats, sample = sample)

internal fun guessFormat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public class OpenApi : SupportedCodeGenerationFormat {
override fun acceptsSample(sample: SupportedFormatSample): Boolean = try {
when (sample) {
is SupportedFormatSample.DataString -> isOpenApiStr(sample.sampleData)
is SupportedFormatSample.File -> isOpenApi(sample.sampleFile)
is SupportedFormatSample.DataFile -> isOpenApi(sample.sampleFile)
is SupportedFormatSample.PathString -> isOpenApi(sample.samplePath)
is SupportedFormatSample.URL -> isOpenApi(sample.sampleUrl)
is SupportedFormatSample.DataUrl -> isOpenApi(sample.sampleUrl)
}
} catch (_: Exception) {
false
Expand Down