/** * Writes a string array property. */ default JsonWriter property(String key, String[] a) { return key(key).array(a); }
/** * Writes a long array property. */ default JsonWriter property(String key, long[] a) { return key(key).array(a); }
/** * Writes an object array property. */ default JsonWriter property(String key, Iterable<Object> a) { return key(key).array(a); }
/** * Writes an int array property. */ default JsonWriter property(String key, int[] a) { return key(key).array(a); }
/** * Writes a number array property. */ default JsonWriter property(String key, Number[] a) { return key(key).array(a); }
/** * Writes an object array property. */ default JsonWriter property(String key, Object[] a) { return key(key).array(a); }
protected void writeParameters(WriteContext context, ApiMetadata m, JsonWriter w, MApiParameter[] ps) { w.array(ps, p -> writeParameter(context, m, w, p)); }
@Override public void toJson(JsonWriter writer) { writer.startObject(); writer.property("name", name) .key("columns").array(columnNames); writer.endObject(); }
@Override public void toJson(JsonWriter writer) { writer.startObject(); writer.property("name", name); if(unique){ writer.property("unique", unique); } writer.key("columnNames").array(columnNames); writer.endObject(); } }
protected void writeTags(WriteContext context, ApiMetadata m, JsonWriter w) { w.array(m.getTags(), (tag) -> { w.startObject(); w.property(NAME, tag.getName()); w.propertyOptional(DESCRIPTION, tag.descOrSummaryOrTitle()); w.endObject(); }); }
@Override public void write(Object o, Type type, MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { if(type instanceof Class) { writeInternal(o, outputMessage); }else { try (OutputStream os = outputMessage.getBody()){ try (OutputStreamWriter writer = new OutputStreamWriter(os, getCharset(outputMessage))) { JsonWriter jsonWriter = JSON.writer(writer).create(); if(null == o) { jsonWriter.startArray().endArray(); return; } Collection c = (Collection)o; jsonWriter.array(c, item -> { ((JsonStringable)item).toJson(jsonWriter); }); } } } }
protected void writeDefaultSecurity(WriteContext context, ApiMetadata m, JsonWriter w) { if(null == context.defaultSecurity){ return; } w.property(SECURITY, () -> { w.startArray(); w.startObject(); w.property(context.defaultSecurity, () -> { w.array(m.getPermissions(), (p) -> w.value(p.getValue())); }); w.endObject(); w.endArray(); }); }
if(o.getSecurity().length > 0 && m.getSecurityDefs().length > 0) { w.property(SECURITY, () -> { w.array(o.getSecurity(), (sc) -> writeSecurity(context, m, w, sc)); });