Defining conditional attributes in OpenAPI
I need to define a request for a searching service in JSON. Request can have either geographical coordinates (longitude and latitude) or postal code. Either one must be present. If longitude is present, then latitude is required and vice versa. If both are omitted, postal code must be present. If geo coordinates present, postal code is optional (will be ignored if present). I am having trouble defining such request in swagger editor. If someone can help me, I will appreciate it greatly. We are using v.3.0.3 and the swagger file will be used to generate client code.SolvedHow to express an array in a swagger definition
How can I express an array of objects in a defition. Here's the sample json { "resourceType": "Patient", "extension": [{ "url": "http://hl7.org/fhir/StructureDefinition/us-core-race", "extension": [{ "url": "ombCategory", "valueCoding": { "system": "http://hl7.org/fhir/v3/Race", "code": "2106-3", "display": "White" } }] }, { "url": "http://hl7.org/fhir/StructureDefinition/us-core-ethnicity", "extension": [{ "url": "ombCategory", "valueCoding": { "system": "http://hl7.org/fhir/v3/Ethnicity", "code": "2135-2", "display": "Hispanic or Latino" } }] } ] }SolvedHow to hide Model Information
I described Schema information like below in my swagger.yaml. I want to show the only B to Swagger UI. But, this will also show A. How to hide A from Swagger UI? components: schemas: B: allOf: - type: object properties: bbb: type: string - $ref: '#/components/schemas/A' A: - type: object properties: aaa: type: stringSolvedHow to set default values into Swagger form
Hi, I have a Swagger ui and a C# Controller with a GET. Tha GET need's a json File as atribute. Each time I will test my Api I have to write surtain values into the form (json). Because it is allways the same value, I would like to have a prefilled field. How can I set default values into this Swagger form? Thanks for help. FrankHow to add a JSON example in a POST Request Body? (without a schema reference)
I came across this spec exampleon the OpenAPI Spec Github where there is a JSON example pasted directly into the GET response: Is it possible to do something similar for the POST request body? I have tried replicating this, but receive a render error on the UI: I know that I can use a schema reference to define the JSON request, but it would be very nice to be able to directly paste a JSON example into the YAML file. Note sure why this would be possible for a response body but not a request body. Any input would be appreciated!SolvedSwagger $ref gives "Could not resolve reference: undefined undefined"
so I'm trying to separate the objects that we give in the responses body into separate yaml, or json, files and it gives all the time the same error. Errors Resolver error at paths./api/thing.get.responses.200.content.application/json.schema.$ref Could not resolve reference: undefined undefined This is my Main.yaml file: openapi: 3.0.0 info: version: '0.0.1' title: 'thing-services' license: name: MIT tags: - name: thingReturn description: ''" paths: /api/thing: get: tags: - thingReturn description: 'Recovers things' responses: '200': description: 'Returns a list of things.' content: application/json: schema: $ref: 'ThingList.yaml#components/schemas/ThingList' '204': description: No Content. There was no content found. This is my ThingList.yaml file: components: schemas: ThingList: type: array items: $ref: 'Thing.yaml#/components/schemas/Thing' This is my Thing.yaml file: components: schemas: Thing: type: object properties: id: type: string property1: type: integer format: int32 property2: type: integer format: int32 Lets just say that everything is in the same folder (the original idea is to have the objects in a "object-schemas" folder), it doesn't work either. If I put the objects inside the Main.yaml file with the "#/components/schemas/...", it works fine but it beats the purpose of having everything organized in separate files. I don't know if I'm overlooking something. Any help is appreciated.Swagger api to generate HTML from yaml
I am trying to generate HTML from YAML file using .https://generator3.swagger.io/api/generateenpoint but if my yaml file has markdown text it does not seem to support and the html file which is generated does not parse markdown text . How can I parse markdown text ?Redirect URL for OAuth2 is missing in Spec!
Hello, I'm trying to login to SF API's with Oauth2 and get mismatch in redirect URL error The spec: components: securitySchemes: OAuth2: type: oauth2 flows: authorizationCode: authorizationUrl: https://qa-x.cs82.force.com/services/oauth2/authorize tokenUrl: https://qa-x.cs82.force.com/services/oauth2/token scopes: api: Grant access to API clients web: Grant access to Web clients Did anyone manage to fix the redirect URL issue? I've seen it in other thread without any valid solution Thanks so much!!Multiple Multipart Part File upload using Swagger 2 / OpenAPI 3
We have Spring Boot Rest Controller which accepts data and array of multipart files. We are using swagger 2.9.2. Postman works fine. But when swagger.json from api-docs url is placed in editor.swagger.io, it is giving a lot of "Structural errors". Rest Controller @PostMapping (consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE}) @ApiOperation(value = "Report REST Service", notes = "This sends an email notification based on the criteria added", response = RestReportVO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = RestServiceConstants.MSG_200), @ApiResponse(code = 400, message = RestServiceConstants.MSG_400, response = RestVO.class), @ApiResponse(code = 500, message = RestServiceConstants.MSG_500, response = RestVO.class) }) public ResponseEntity<?> eReport(@RequestParam(value = "login_id", required = true) String loginId,, @RequestParam(value = "uploaded_files", required = false) MultipartFile[] upFiles) Structural Errors Structural errorat paths./error_report.post.parameters.0should NOT have additional properties additionalProperty: schema Jump to line 36 Structural errorat paths./error_report.post.parameters.0should have required property 'type' missingProperty: type Jump to line 36 Structural errorat paths./error_report.post.parameters.7.items.typeshould be equal to one of the allowed values allowedValues: string, number, integer, boolean, array Jump to line 84 Excerpts from Swagger.json consumes: - multipart/form-data produces: - application/json parameters: - in: formData name: login_id description: login_id required: true schema: type: string - name: uploaded_files in: formData description: uploaded_files required: false type: array items: type: file collectionFormat: multi