Skip to content

Commit

Permalink
json url test
Browse files Browse the repository at this point in the history
  • Loading branch information
elifKurtay committed Nov 28, 2024
1 parent 7917264 commit c0e175b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 79,060 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.micronaut.inject.processing.ProcessingException;
import io.micronaut.inject.visitor.VisitorContext;
import io.micronaut.jsonschema.generator.aggregator.AnnotationsAggregator;
import io.micronaut.jsonschema.generator.utils.FileProcessor;
import io.micronaut.jsonschema.generator.utils.GeneratorContext;
import io.micronaut.jsonschema.generator.utils.SourceGeneratorConfig;
import io.micronaut.jsonschema.model.Schema;
Expand Down Expand Up @@ -66,7 +67,7 @@
@Internal
public final class SourceGenerator {

private static String inputFileName = "";
private static String inputFileName = null;

private enum ObjectType { CLASS, RECORD, INTERFACE, ENUM }
private final io.micronaut.sourcegen.generator.SourceGenerator sourceGenerator;
Expand Down Expand Up @@ -119,7 +120,7 @@ public File generate(SourceGeneratorConfig config) throws IOException {
} else {
Schema jsonSchema = getJsonSchema(config);
assert jsonSchema != null;
inputFileName = config.getInputName();
inputFileName = getInputFileName() != null ? getInputFileName() : config.getInputName();
if (config.outputFileName() != null && !config.outputFileName().isBlank()) {
var outputFileName = config.outputFileName();
if (config.outputFileName().contains(".")) { // remove extension from file name
Expand All @@ -140,7 +141,7 @@ public File generate(SourceGeneratorConfig config) throws IOException {
*
* @param config The SourceGeneratorConfig
*/
public void generateFolder(SourceGeneratorConfig config) throws IOException {
private void generateFolder(SourceGeneratorConfig config) throws IOException {
HashMap<Schema, String> schemas = new HashMap<>();
Path jsonFolder = config.inputFolder();
// Walk through the directory to find all json files
Expand Down Expand Up @@ -589,4 +590,16 @@ private TypeDef getListTypeDef(ObjectDefBuilder objectBuilder, String propertyNa
public static String getInputFileName() {
return inputFileName;
}

public static void setInputFileName(String inputFileName) {
SourceGenerator.inputFileName = inputFileName;
}

public static List<String> getAllowedUrlPatterns() {
return FileProcessor.getAllowedUrlPatterns();
}

public static void setAllowedUrlPatterns(List<String> allowedUrlPatterns) {
FileProcessor.setAllowedUrlPatterns(allowedUrlPatterns);
}
}
4 changes: 2 additions & 2 deletions test-suite-generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ def foodGenerator = tasks.register("generateFood", BeanGeneratorTask) {
def githubGenerator = tasks.register("generateGithub", BeanGeneratorTask) {
language = "java"
classpath.from(configurations.beanGenerator)
jsonFile.convention(layout.projectDirectory.file("src/test/resources/github-workflow.schema.json"))
jsonURL.convention("https://json.schemastore.org/github-workflow.json")
outputDirectory.convention(layout.buildDirectory.dir("generated/jsonSchema"))
packageName.convention("io.micronaut.jsonschema.generator.github")
}

def fhirGenerator = tasks.register("generateFhir", BeanGeneratorTask) {
language = "java"
classpath.from(configurations.beanGenerator)
jsonFile.convention(layout.projectDirectory.file("src/test/resources/fhir.schema.json"))
jsonURL.convention("https://www.hl7.org/fhir/fhir.schema.json")
outputDirectory.convention(layout.buildDirectory.dir("generated/jsonSchema"))
packageName.convention("io.micronaut.jsonschema.generator.fhir")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.jsonschema.generator.animals;
package io.micronaut.jsonschema.generator;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.json.JsonMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.micronaut.jsonschema.generator.animals;
package io.micronaut.jsonschema.generator;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -46,7 +46,7 @@ void fhirGenerator() {
} catch (IOException e) {
Assertions.fail("Failed to list files in the folder: " + e.getMessage());
}
Assertions.assertEquals(864, generatedFiles);
Assertions.assertTrue(generatedFiles > 800);

// Assert that the expected files exist
String[] expectedFileNames = {
Expand Down
Loading

0 comments on commit c0e175b

Please sign in to comment.