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.

Support model references directly to primitives

See original GitHub issue

A model like this:

swagger: '2.0'
definitions:
  User:
    $ref: 'BaseUser'
  BaseUser:
    type: string

Is legal but currently not supported in the parser.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jbx1commented, Mar 18, 2018

While direct references to primitives are supported, none of the validation specifiers associated with it are carried over.

For example:

     email:
        type: string
        pattern: '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$'
        description: Email address of the customer.
     mobile:
        $ref: '#/definitions/Mobile'

with the definition:

 Mobile:
    type: string
    pattern: '^\\+[1-9][0-9]{3,14}$'
    description: The mobile number in E.164 format.

Using swagger-codegen version 2.3.1 for spring-boot generates the right validation annotations and javadoc for email:

  /**
   * Email address of the customer.
   * @return email
  **/
  @ApiModelProperty(value = "Email address of the customer.")
@Pattern(regexp="^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$") 
  public String getEmail() {
    return email;
  }

But not for the mobile property:

/**
   * Get mobile
   * @return mobile
  **/
  @ApiModelProperty(required = true, value = "")
  @NotNull
  public String getMobile() {
    return mobile;
  }
1reaction
jimvmathewscommented, Mar 20, 2017

@fehguy - Can you point us to the PR or test that has fixed this issue? I have pulled this latest version into the swagger-codegen and the problem https://github.com/swagger-api/swagger-codegen/issues/3483 is not resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Primitive and reference variables - Java Programming - Mooc.fi
From the programmer's perspective, a primitive variable's information is stored as the value of that variable, whereas a reference variable holds a reference...
Read more >
Part library primitives reference | Netfabb 2020
Part library primitives reference ; Resolution, Defines the resolution of the part's surface. The higher the number, the finer the surfaces are ...
Read more >
State of Valhalla
Reference and primitive types differ in almost every conceivable way. Reference types have members (methods and fields) and supertypes (superclasses and ...
Read more >
Primitives - SideFX
In Houdini, primitives refer to a unit of geometry, lower-level than an object but above points. Houdini supports several different types of primitives:....
Read more >
Object references and copying - The Modern JavaScript Tutorial
One of the fundamental differences of objects versus primitives is that objects are stored and copied “by reference”, whereas primitive ...
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