You can’t. JSON Schema doesn’t allow you to pick fields out of a definition.

You can define the smaller instance, and make the bigger one an extension of 
the smaller one to avoid repetition.

 

 

From: <[email protected]> on behalf of Gabriele Proietti 
Mattia <[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Tuesday, October 17, 2017 at 00:42
To: Swagger <[email protected]>
Subject: OpenAPI reuse part of definition without defining a new one

 

Suppose that I have this definition in a yaml OpenApi definition
definitions:
  User:
    description: "User"
    type: "object"
    properties:
      firstname:
        type: "string"
      lastname:
        type: "string"
      password:
        type: "string"
      email:
        type: "string"
      username:
        type: "string"
If in a parameters specification I need specific fields of a definition how can 
I refer them without defining another model as below?
definitions:
  UserLogin:
    description: "User"
    type: "object"
    properties:
      password:
        type: "string"
      email:
        type: "string"
-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to