mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	using 201 for created entities in etapi
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								db/demo.zip
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								db/demo.zip
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -32,7 +32,7 @@ function register(router) { | ||||
|         try { | ||||
|             const attr = attributeService.createAttribute(params); | ||||
|  | ||||
|             res.json(mappers.mapAttributeToPojo(attr)); | ||||
|             res.status(201).json(mappers.mapAttributeToPojo(attr)); | ||||
|         } | ||||
|         catch (e) { | ||||
|             throw new eu.EtapiError(500, eu.GENERIC_CODE, e.message); | ||||
|   | ||||
| @@ -13,7 +13,7 @@ function register(router) { | ||||
|  | ||||
|         const {authToken} = etapiTokenService.createToken(tokenName || "ETAPI login"); | ||||
|  | ||||
|         res.json({ | ||||
|         res.status(201).json({ | ||||
|             authToken | ||||
|         }); | ||||
|     }); | ||||
|   | ||||
| @@ -33,15 +33,16 @@ function register(router) { | ||||
|         if (existing) { | ||||
|             existing.notePosition = params.notePosition; | ||||
|             existing.prefix = params.prefix; | ||||
|             existing.isExpanded = params.isExpanded; | ||||
|             existing.save(); | ||||
|  | ||||
|             return res.json(mappers.mapBranchToPojo(existing)); | ||||
|             return res.status(200).json(mappers.mapBranchToPojo(existing)); | ||||
|         } | ||||
|  | ||||
|         try { | ||||
|             const branch = new Branch(params).save(); | ||||
|  | ||||
|             res.json(mappers.mapBranchToPojo(branch)); | ||||
|             res.status(201).json(mappers.mapBranchToPojo(branch)); | ||||
|         } | ||||
|         catch (e) { | ||||
|             throw new eu.EtapiError(400, eu.GENERIC_CODE, e.message); | ||||
|   | ||||
| @@ -27,7 +27,7 @@ paths: | ||||
|             schema: | ||||
|               $ref: '#/components/schemas/CreateNoteDef' | ||||
|       responses: | ||||
|         '200': | ||||
|         '201': | ||||
|           description: note created | ||||
|           content: | ||||
|             application/json: | ||||
| @@ -205,7 +205,7 @@ paths: | ||||
|               $ref: '#/components/schemas/Note' | ||||
|       responses: | ||||
|         '200': | ||||
|           description: update note | ||||
|           description: note updated | ||||
|           content: | ||||
|             application/json: | ||||
|               schema: | ||||
| @@ -252,7 +252,10 @@ paths: | ||||
|               schema: | ||||
|                 $ref: '#/components/schemas/Error' | ||||
|     post: | ||||
|       description: create a branch (clone a note to a different location in the tree) | ||||
|       description: > | ||||
|         Create a branch (clone a note to a different location in the tree). | ||||
|         In case there is a branch between parent note and child note already,  | ||||
|         then this will update the existing branch with prefix, notePosition and isExpanded. | ||||
|       operationId: postBranch | ||||
|       requestBody: | ||||
|         required: true | ||||
| @@ -262,11 +265,17 @@ paths: | ||||
|               $ref: '#/components/schemas/Branch' | ||||
|       responses: | ||||
|         '200': | ||||
|           description: update branch | ||||
|           description: branch updated (branch between parent note and child note already existed) | ||||
|           content: | ||||
|             application/json: | ||||
|               schema: | ||||
|                 $ref: '#/components/schemas/Note' | ||||
|                 $ref: '#/components/schemas/Branch' | ||||
|         '201': | ||||
|           description: branch created | ||||
|           content: | ||||
|             application/json: | ||||
|               schema: | ||||
|                 $ref: '#/components/schemas/Branch' | ||||
|         default: | ||||
|           description: unexpected error | ||||
|           content: | ||||
| @@ -284,11 +293,11 @@ paths: | ||||
|               $ref: '#/components/schemas/Branch' | ||||
|       responses: | ||||
|         '200': | ||||
|           description: update branch | ||||
|           description: branch updated | ||||
|           content: | ||||
|             application/json: | ||||
|               schema: | ||||
|                 $ref: '#/components/schemas/Note' | ||||
|                 $ref: '#/components/schemas/Branch' | ||||
|         default: | ||||
|           description: unexpected error | ||||
|           content: | ||||
| @@ -342,8 +351,8 @@ paths: | ||||
|             schema: | ||||
|               $ref: '#/components/schemas/Attribute' | ||||
|       responses: | ||||
|         '200': | ||||
|           description: update attribute | ||||
|         '201': | ||||
|           description: attribute created | ||||
|           content: | ||||
|             application/json: | ||||
|               schema: | ||||
| @@ -365,7 +374,7 @@ paths: | ||||
|               $ref: '#/components/schemas/Attribute' | ||||
|       responses: | ||||
|         '200': | ||||
|           description: update attribute | ||||
|           description: attribute updated | ||||
|           content: | ||||
|             application/json: | ||||
|               schema: | ||||
| @@ -552,7 +561,7 @@ paths: | ||||
|                   type: string | ||||
|                   description: user's password used to e.g. login to Trilium server and/or protect notes | ||||
|       responses: | ||||
|         '200': | ||||
|         '201': | ||||
|           description: auth token | ||||
|           content: | ||||
|             application/json: | ||||
|   | ||||
| @@ -60,7 +60,7 @@ function register(router) { | ||||
|         try { | ||||
|             const resp = noteService.createNewNote(params); | ||||
|  | ||||
|             res.json({ | ||||
|             res.status(201).json({ | ||||
|                 note: mappers.mapNoteToPojo(resp.note), | ||||
|                 branch: mappers.mapBranchToPojo(resp.branch) | ||||
|             }); | ||||
|   | ||||
| @@ -220,7 +220,8 @@ class NoteContext extends Component { | ||||
|     } | ||||
|  | ||||
|     hasNoteList() { | ||||
|         return this.note.hasChildren() | ||||
|         return this.note | ||||
|             && this.note.hasChildren() | ||||
|             && ['book', 'text', 'code'].includes(this.note.type) | ||||
|             && this.note.mime !== 'text/x-sqlite;schema=trilium' | ||||
|             && !this.note.hasLabel('hideChildrenOverview'); | ||||
|   | ||||
| @@ -6,7 +6,7 @@ Content-Type: application/json | ||||
| } | ||||
|  | ||||
| > {% | ||||
|     client.assert(response.status === 200); | ||||
|     client.assert(response.status === 201); | ||||
|  | ||||
|     client.global.set("authToken", response.body.authToken); | ||||
| %} | ||||
| @@ -12,7 +12,7 @@ Content-Type: application/json | ||||
| } | ||||
|  | ||||
| > {% | ||||
|     client.assert(response.status === 200); | ||||
|     client.assert(response.status === 201); | ||||
|     client.assert(response.body.note.noteId.startsWith("forcedId")); | ||||
|     client.assert(response.body.note.title == "Hello"); | ||||
|     client.assert(response.body.branch.branchId.startsWith("forcedId")); | ||||
| @@ -37,7 +37,7 @@ Content-Type: application/json | ||||
| } | ||||
|  | ||||
| > {% | ||||
|     client.assert(response.status === 200); | ||||
|     client.assert(response.status === 201); | ||||
|     client.assert(response.body.parentNoteId == "hidden"); | ||||
|  | ||||
|     client.global.set("clonedBranchId", response.body.branchId); | ||||
| @@ -107,7 +107,7 @@ Authorization: {{authToken}} | ||||
| } | ||||
|  | ||||
| > {% | ||||
|     client.assert(response.status === 200); | ||||
|     client.assert(response.status === 201); | ||||
|     client.assert(response.body.attributeId.startsWith("forcedAttributeId")); | ||||
|  | ||||
|     client.global.set("createdAttributeId", response.body.attributeId); | ||||
|   | ||||
| @@ -6,7 +6,7 @@ Content-Type: application/json | ||||
| } | ||||
|  | ||||
| > {% | ||||
|     client.assert(response.status === 200); | ||||
|     client.assert(response.status === 201); | ||||
|  | ||||
|     client.global.set("testAuthToken", response.body.authToken); | ||||
| %} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user