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.

Reusable object properties?

See original GitHub issue

Hi everyone,

I think Swagger UI is a great tool - thanks for making it!

I particularly like the fact that you can reuse definitions, parameters and responses to make the YAML code more modular and was wondering if there’s any way to do the same for object properties? Some of my object properties are the same as parameters I’ve defined elsewhere and it would great if I could use a single reference for both.

Is there any way of doing something like this?

paths:
  /pet:
    get:
      tags:
      - "pet"
      summary: "Add a new pet to the store"
      description: ""
      produces:
      - application/json
      parameters:
      - $ref: "#/parameters/id"
      responses: 
        405:
          description: "Invalid input"
        200:
          schema:
            title: Pet
            type: object
            required: [id, name]
            properties:
              $ref: "#/parameters/id" # Doesn't work :( 
              name:
                type: string
                description: The new pet's name.

parameters:
  id:
    name: id
    in: path
    type: integer
    required: true
    description: The ID.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
webroncommented, Jun 27, 2017

Not OOTB. At some point we plan on introducing a way to hide all models, but not some. You can always write your own plugin to support any behavior you want.

0reactions
thales-gaddinicommented, Jun 27, 2017

Hi webron,

In your example, “id” will appear in the Models. Is there a way to prevent that? Or some other way to make a reusable “object” that is not exposed in the UI?

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are Javascript Objects? Containers for Reusable ...
Javascript objects are containers for properties and behaviors that are reusable, allowing developers to provide complex functionality with ...
Read more >
Reusable Objects - Web Central
JavaScript API Reference/Creating Custom Java Script Objects. Reusable Objects ... if you create many object, or if the objects have many properties.
Read more >
Adding and reusing properties - IBM
Reused properties are properties that have been defined in a solution that has been deployed. Reused properties can be used again in other...
Read more >
Creating a reusable object from the object library
Creating a reusable object from the object library · Right-click the new object in the object library and select Properties. The Properties dialog...
Read more >
How to Build a Reusable Object in Javascript for HTML5 and ...
What if you want to build several objects in Javascript with the same definition? JavaScript supports an idea called a constructor, which allows ......
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