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 example on 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/generate enpoint 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!!Dynamic/Variable servers URLs in the swagger document
I was trying to find out how I could specify my server URLs inside my swagger.json file so that when we deploy the documentation to the different servers (i.e., production, staging, dev, etc), each link points to the right server without user involvement. Currently, I have the following setup which works fine: "servers": [ { "url": "https://.../api/.../v1", "description": "Staging server" }, { "url": "https://.../api/.../v1", "description": "Production server" } ] I am looking to do something like this: "servers": [ { "url": process.env.serverUrl, "description": process.env.serverName } ] I am using swagger-ui-express in a Vue CLI project.