
001package org.hl7.fhir.r5.openapi; 002 003import org.hl7.fhir.utilities.MarkedToMoveToAdjunctPackage; 004 005/* 006 Copyright (c) 2011+, HL7, Inc. 007 All rights reserved. 008 009 Redistribution and use in source and binary forms, with or without modification, 010 are permitted provided that the following conditions are met: 011 012 * Redistributions of source code must retain the above copyright notice, this 013 list of conditions and the following disclaimer. 014 * Redistributions in binary form must reproduce the above copyright notice, 015 this list of conditions and the following disclaimer in the documentation 016 and/or other materials provided with the distribution. 017 * Neither the name of HL7 nor the names of its contributors may be used to 018 endorse or promote products derived from this software without specific 019 prior written permission. 020 021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 024 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 026 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 029 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 030 POSSIBILITY OF SUCH DAMAGE. 031 032 */ 033 034 035 036import com.google.gson.JsonObject; 037 038@MarkedToMoveToAdjunctPackage 039public class OperationWriter extends BaseWriter { 040 041 public OperationWriter(JsonObject object) { 042 super(object); 043 } 044 045 public OperationWriter summary(String value) { 046 object.addProperty("summary", value); 047 return this; 048 } 049 050 public OperationWriter description(String value) { 051 object.addProperty("description", value); 052 return this; 053 } 054 055 056 public ExternalDocsWriter variable(String name) { 057 return new ExternalDocsWriter(ensureObject("externalDocs")); 058 } 059 060 public OperationWriter operationId(String value) { 061 object.addProperty("operationId", value); 062 return this; 063 } 064 065 public OperationWriter deprecated(boolean value) { 066 object.addProperty("deprecated", value); 067 return this; 068 } 069 070 071 public ServerWriter server(String url) { 072 return new ServerWriter(ensureArrayObject("servers", "url", url)); 073 } 074 075 public ParameterWriter parameter(String name) { 076 JsonObject obj = forceArrayObject("parameters"); 077 obj.addProperty("name", name); 078 return new ParameterWriter(obj); 079 } 080 081 public OperationWriter paramRef(String url) { 082 forceArrayObject("parameters").addProperty("$ref", url); 083 return this; 084 } 085 086 087 public RequestBodyWriter request() { 088 return new RequestBodyWriter(ensureObject("requestBody")); 089 } 090 091 public ResponsesWriter responses() { 092 return new ResponsesWriter(ensureObject("responses")); 093 } 094 095}