diff --git a/src/index.ts b/src/index.ts index 612cba0..615cc79 100644 --- a/src/index.ts +++ b/src/index.ts @@ -186,6 +186,8 @@ Dir.ready(async () => { const generateRoutes = (app: TemplatedApp) => { Dir.files.forEach(async (endpoints) => { const { contract, path, keys, conf, metadata } = endpoints; + if (metadata.hidden) return; + const LOG = L.getSubLogger({ stylePrettyLogs: true, prettyLogTemplate: diff --git a/src/types.ts b/src/types.ts index dd031c7..6a06730 100644 --- a/src/types.ts +++ b/src/types.ts @@ -42,6 +42,7 @@ export interface Codec { } export interface Metadata { + hidden: boolean; disableGet: boolean; disablePost: boolean; diff --git a/src/utils.ts b/src/utils.ts index f8ea28a..3f26fd2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -123,6 +123,7 @@ export const newMetadata = (configRaw: JSON): Metadata => { errorContentType: configRaw['error_content_type'] || 'plain/text', examples: configRaw['examples'] || {}, tags: configRaw['tags'] || ['📑 Zencodes'], + hidden: configRaw['hidden'] || false, }; }; diff --git a/tests/fixtures/broken_contracts/exec.keys.json b/tests/fixtures/broken_contracts/exec.keys.json new file mode 100644 index 0000000..c4d84f5 --- /dev/null +++ b/tests/fixtures/broken_contracts/exec.keys.json @@ -0,0 +1,3 @@ +{ + "data_1": {} +} diff --git a/tests/fixtures/broken_contracts/exec.metadata.json b/tests/fixtures/broken_contracts/exec.metadata.json new file mode 100644 index 0000000..49f19db --- /dev/null +++ b/tests/fixtures/broken_contracts/exec.metadata.json @@ -0,0 +1,10 @@ +{ + "examples": { + "did": { + "value": { + "did_document": {"description": "sandbox_test_from_js_updated"}, + "id": "did:dyne:sandbox.test:33ZZcaRLvdsvAKTkV8eAHZsvioZSgPcC4ReNXLup7Tj4#ethereum_address" + } + } + } +} diff --git a/tests/fixtures/broken_contracts/exec.schema.json b/tests/fixtures/broken_contracts/exec.schema.json new file mode 100644 index 0000000..dee9888 --- /dev/null +++ b/tests/fixtures/broken_contracts/exec.schema.json @@ -0,0 +1,23 @@ +{ + "type": "object", + "properties": { + "data_1": { + "type": "object" + }, + "id": { + "type": "string" + }, + "did_document": { + "type": "object", + "properties": { + "description": { + "type": "string" + } + } + } + }, + "required": [ + "did_document", + "id" + ] +} diff --git a/tests/fixtures/broken_contracts/exec.zen b/tests/fixtures/broken_contracts/exec.zen new file mode 100644 index 0000000..9f29734 --- /dev/null +++ b/tests/fixtures/broken_contracts/exec.zen @@ -0,0 +1,3 @@ +Given I send object 'data_1' and send sources 'did_document' and manipulate and merge and output into 'data' +Given I have a 'string dictionary' named 'data' +Then print the data diff --git a/tests/fixtures/meta/hidden.metadata.json b/tests/fixtures/meta/hidden.metadata.json new file mode 100644 index 0000000..9279f8f --- /dev/null +++ b/tests/fixtures/meta/hidden.metadata.json @@ -0,0 +1,3 @@ +{ + "hidden": true +} \ No newline at end of file diff --git a/tests/fixtures/meta/hidden.zen b/tests/fixtures/meta/hidden.zen new file mode 100644 index 0000000..77bbdd7 --- /dev/null +++ b/tests/fixtures/meta/hidden.zen @@ -0,0 +1,2 @@ +Given nothing +Then print the string 'hidden' \ No newline at end of file diff --git a/tests/workflow.stepci.yml b/tests/workflow.stepci.yml index f793f45..3cb768a 100644 --- a/tests/workflow.stepci.yml +++ b/tests/workflow.stepci.yml @@ -241,4 +241,33 @@ tests: status: 201 json: output: - - "mimmolo" \ No newline at end of file + - "mimmolo" + + - name: HIDDEN POST + http: + url: http://${{env.host}}/meta/hidden + method: POST + json: {} + check: + status: 404 + + - name: HIDDEN RAW + http: + url: http://${{env.host}}/meta/hidden/raw + method: GET + check: + status: 404 + + - name: HIDDEN APP + http: + url: http://${{env.host}}/meta/hidden/app + method: GET + check: + status: 404 + + - name: HIDDEN GET + http: + url: http://${{env.host}}/meta/hidden + method: GET + check: + status: 404 \ No newline at end of file