Skip to content

Commit

Permalink
Prettified Code!
Browse files Browse the repository at this point in the history
  • Loading branch information
egekorkan authored and actions-user committed Dec 12, 2024
1 parent fada185 commit 8c39102
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 181 deletions.
170 changes: 85 additions & 85 deletions proposals/initial-connection/tooling/schema-new.schema.json
Original file line number Diff line number Diff line change
@@ -1,95 +1,95 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type":"object",
"definitions": {
"singleSecurityDefinition":{
"type":"object",
"properties": {
"scheme":{
"type":"string"
}
}
},
"singleConnectionDefinition": {
"type": "object",
"properties": {
"base": {
"type": "string"
}
}
},
"singleFormDefinition": {
"type": "object",
"properties": {
"contentType": {
"type": "string"
},
"connection":{
"$ref": "#/definitions/singleConnectionDefinition"
}
}
},
"singleSchemaDefinition": {
"type": "object"
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"definitions": {
"singleSecurityDefinition": {
"type": "object",
"properties": {
"scheme": {
"type": "string"
}
}
},
"properties": {
"security": {
"oneOf": [
{
"$ref": "#/definitions/singleSecurityDefinition"
},
{
"type": "string",
"$comment": "Reference to a securityDefinitions object key"
}
]
},
"form": {
"oneOf": [
{
"$ref": "#/definitions/singleFormDefinition"
},
{
"type": "string",
"$comment": "Reference to a formDefinitions object key"
}
]
"singleConnectionDefinition": {
"type": "object",
"properties": {
"base": {
"type": "string"
}
}
},
"singleFormDefinition": {
"type": "object",
"properties": {
"contentType": {
"type": "string"
},
"connection": {
"oneOf": [
{
"$ref": "#/definitions/singleConnectionDefinition"
},
{
"type": "string",
"$comment": "Reference to a connectionDefinitions object key"
}
]
},
"securityDefinitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/singleSecurityDefinition"
}
"$ref": "#/definitions/singleConnectionDefinition"
}
}
},
"singleSchemaDefinition": {
"type": "object"
}
},
"properties": {
"security": {
"oneOf": [
{
"$ref": "#/definitions/singleSecurityDefinition"
},
"connectionDefinitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/singleConnectionDefinition"
}
{
"type": "string",
"$comment": "Reference to a securityDefinitions object key"
}
]
},
"form": {
"oneOf": [
{
"$ref": "#/definitions/singleFormDefinition"
},
"formDefinitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/singleFormDefinition"
}
{
"type": "string",
"$comment": "Reference to a formDefinitions object key"
}
]
},
"connection": {
"oneOf": [
{
"$ref": "#/definitions/singleConnectionDefinition"
},
"schemaDefinitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/singleSchemaDefinition"
}
{
"type": "string",
"$comment": "Reference to a connectionDefinitions object key"
}
]
},
"securityDefinitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/singleSecurityDefinition"
}
},
"connectionDefinitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/singleConnectionDefinition"
}
},
"formDefinitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/singleFormDefinition"
}
},
"schemaDefinitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/singleSchemaDefinition"
}
}
}
}
}
5 changes: 2 additions & 3 deletions proposals/initial-connection/tooling/td-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ let tdOutput = {};

// Find if there is a default in the root level

if (Object.hasOwn(tdInput,"form")){
const defaultForm = tdInput.form;

if (Object.hasOwn(tdInput, "form")) {
const defaultForm = tdInput.form;
}

// Go into the forms and try to find each reference or inline
Expand Down
170 changes: 84 additions & 86 deletions proposals/initial-connection/tooling/tds.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,106 +2,104 @@
// However, please do not remove JSON serialization so that they can be copy pasted easily

const validTDs = [
// Inline (no definitions objects)
// Separate Defaults
{
"title": "test1",
"connection":{
// Inline (no definitions objects)
// Separate Defaults
{
"title": "test1",
"connection": {
"base": "https://example.com"
},
"form":{
"contentType":"application/json"
},
"security":{
"scheme":"nosec"
},
"properties": {
"prop1": {
"type":"string",
"forms": [
{
"href": "/props/prop1"
}
]
},
"prop2": {
"type":"string",
"forms": [
{
"href": "/props/prop2"
}
]
}
}
},
// All Defaults in a Form but still with connection
{
"title": "test2",
"form":{
"contentType":"application/json",
"connection":{
"base": "https://example.com",
"security":{
"scheme":"nosec"
},
"form": {
"contentType": "application/json"
},
"security": {
"scheme": "nosec"
},
"properties": {
"prop1": {
"type": "string",
"forms": [
{
"href": "/props/prop1"
}
]
},
"prop2": {
"type": "string",
"forms": [
{
"href": "/props/prop2"
}
]
}
}
},
"properties": {
"prop1": {
"type":"string",
"forms": [
{
"href": "/props/prop1"
// All Defaults in a Form but still with connection
{
"title": "test2",
"form": {
"contentType": "application/json",
"connection": {
"base": "https://example.com",
"security": {
"scheme": "nosec"
}
}
]
},
"prop2": {
"type":"string",
"forms": [
{
"href": "/props/prop2"
},
"properties": {
"prop1": {
"type": "string",
"forms": [
{
"href": "/props/prop1"
}
]
},
"prop2": {
"type": "string",
"forms": [
{
"href": "/props/prop2"
}
]
}
]
}
}
},
// All defaults in a form and flattened without connection
{
"title": "test3",
"form":{
"contentType":"application/json",
"base": "https://example.com",
"security":{
"scheme":"nosec"
}
},
"properties": {
"prop1": {
"type":"string",
"forms": [
{
"href": "/props/prop1"
// All defaults in a form and flattened without connection
{
"title": "test3",
"form": {
"contentType": "application/json",
"base": "https://example.com",
"security": {
"scheme": "nosec"
}
]
},
"prop2": {
"type":"string",
"forms": [
{
"href": "/props/prop2"
},
"properties": {
"prop1": {
"type": "string",
"forms": [
{
"href": "/props/prop1"
}
]
},
"prop2": {
"type": "string",
"forms": [
{
"href": "/props/prop2"
}
]
}
]
}
}
}
}
]


];

// TODO: Invalid TDs are not detected yet
const invalidTDs = [
// Inline (no definitions objects)
// Missing Connection
// Missing Connection
{
"title": "test1",
"form": {
Expand Down Expand Up @@ -133,5 +131,5 @@ const invalidTDs = [

module.exports = {
validTDs,
invalidTDs,
invalidTDs
};
Loading

0 comments on commit 8c39102

Please sign in to comment.