mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[json] IJ-CR-124164 Fixed examples reading in the old JsonSchemaObject mode to ensure that all tests are green in both modes
GitOrigin-RevId: 21f927ee64af5c0430febed9f8f70ff6d1f1f759
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7e2f634eb9
commit
05bcab09f1
@@ -162,7 +162,7 @@ public final class AddMissingPropertyFix implements LocalQuickFix, BatchQuickFix
|
||||
var renderingLanguage = targetLanguage.is(JsonLanguage.INSTANCE) ? JsonSchemaObjectRenderingLanguage.JSON : JsonSchemaObjectRenderingLanguage.YAML;
|
||||
return renderSchemaNode(schemaObject, renderingLanguage);
|
||||
}
|
||||
else if (defaultValueObject instanceof JsonNode jsonNode) {//todo fix properties tests??
|
||||
else if (defaultValueObject instanceof JsonNode jsonNode) {
|
||||
return convertToYamlIfNeeded(targetLanguage, jsonNode);
|
||||
}
|
||||
else if (defaultValueObject instanceof String) {
|
||||
@@ -190,9 +190,10 @@ public final class AddMissingPropertyFix implements LocalQuickFix, BatchQuickFix
|
||||
.build();
|
||||
|
||||
try {
|
||||
return new ObjectMapper(jacksonFactory)
|
||||
var exampleInTargetLanguage = new ObjectMapper(jacksonFactory)
|
||||
.writerWithDefaultPrettyPrinter()
|
||||
.writeValueAsString(jsonNode);
|
||||
return StringUtil.trimEnd(exampleInTargetLanguage, "\n");
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
return null;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.json.JsonBundle;
|
||||
import com.intellij.json.pointer.JsonPointerPosition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -133,10 +134,12 @@ public final class ObjectValidation implements JsonSchemaValidation {
|
||||
JsonSchemaObject propertySchema = resolvePropertySchema(schema, req);
|
||||
Object defaultValue = propertySchema == null ? null : propertySchema.getDefault();
|
||||
if (defaultValue == null) {
|
||||
defaultValue = schema.getExampleByName(req);
|
||||
}
|
||||
if (defaultValue == null) {
|
||||
defaultValue = schema.getExampleByName(req);
|
||||
if (Registry.is("json.schema.object.v2")) {
|
||||
defaultValue = schema.getExampleByName(req);
|
||||
} else {
|
||||
var example = schema.getExample();
|
||||
defaultValue = example == null ? null : example.get(req);
|
||||
}
|
||||
}
|
||||
Ref<Integer> enumCount = Ref.create(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user