question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$ref in parameters is not properly detected, and flagged as error

See original GitHub issue
Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 3.0
Which Swagger-Editor version? 3.1.20 and 3.2.0
How did you install Swagger-Editor? git clone + npm start
Which broswer & version? Chrome 63
Which operating system? MacOS

Demonstration API definition

openapi: 3.0.0
info:
  title: DNSimple API
  version: 2.0.0
  contact:
    name: DNSimple Support
    email: support@dnsimple.com
    url: 'https://dnsimple.com/contact'
  description: >-
    [DNSimple](https://dnsimple.com) provides DNS hosting and domain registration that is simple and friendly.
  termsOfService: 'https://dnsimple.com/terms'
externalDocs:
  url: 'https://developer.dnsimple.com'
servers:
  - url: 'https://api.dnsimple.com/v2'
    description: DNSimple Production API
    variables: {}
paths:
  '/{account}/domains':
    summary: Operations on domain collections.
    parameters:
      - $ref: '#/components/parameters/Account'
    get:
      description: List domains in the account.
      parameters:
        - $ref: '#/components/parameters/Account'
      operationId: listDomains
      tags:
        - domains
      responses:
        '200':
          description: >-
            Depending on how you are authenticated you will see all the accounts
            you have access to or the account you used to authenticate.
components:
  parameters:
    Account:
      name: account
      in: path
      required: true
      description: The account id
      schema:
        type: integer
    Domain:
      name: domain
      in: path
      required: true
      description: The domain name or id
      schema:
        type: string

Configuration (browser query string, constructor, config.yaml)

all default, no query string

Expected Behavior

There should be no validation error for the {account} parameter.

Current Behavior

screen shot 2017-12-26 at 5 08 45 pm
Semantic error at paths./{account}/domains
Declared path parameter "account" needs to be defined as a path parameter at either the path or operation level

Context

According to the specs, an item in the parameters collection can be either a Parameter Object or Reference object. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#fixed-fields-7

However, if we use the Parameter Object itself, it works:

      parameters:
      -  name: account
          in: path
          required: true
          description: The account id
          schema:
            type: integer

If we use a reference, it doesn’t:

      parameters:
        - $ref: '#/components/parameters/Account'

and instead a validation error is shown.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wepposcommented, Dec 28, 2017

Thanks @shockey! I confirm it works great now.

0reactions
scaracommented, Jan 11, 2018

TNX for your reply! 👍 Apologies: I didn’t look at the releases yet, just looked here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ref and out parameters in C# and cannot be marked as variant
ref means "the callee may read or write the aliased variable, and it must be known to be assigned before the call. out...
Read more >
Error Explanations for The W3C Markup Validation Service
An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
GetParameter - AWS Systems Manager
Get information about a single parameter by specifying the parameter name. ... This flag is ignored for String and StringList parameter types. Type:...
Read more >
SyntaxError: Malformed formal parameter - JavaScript | MDN
Admittedly the wording in the error message is slightly strange. "Formal parameter" is a fancy way of saying "function argument".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found